Welcome to Eleroui Stories API! This API offers simple access to a collection of stories, each featuring a title, content, date, and YouTube video link. It's perfect for developers who want to add story content easily to their applications.
- 📚 Fetch all stories
- ℹ️ Retrieve details of a single story
- 🎥 Access associated YouTube videos
- 🔥 Example integration with Angular
Follow these steps to set up Eleroui Stories API locally:
-
Clone the Repository:
git clone https://github.com/h-chayma/abdelaziz-elaroui-stories-api.git cd abdelaziz-elaroui-stories-api
-
Install Dependencies:
npm install
-
Start the Server:
npm start
This will start the API server on
http://localhost:3000
.
Fetch a list of all stories available.
-
Endpoint:
GET /stories
-
Example Response:
[ { "id": 1, "title": "Sample Story", "date": "2023-01-01", "content": "Story content here.", "youtubeVideoId": "abcd1234" } // Additional stories here ]
Retrieve details of a specific story using its unique ID.
-
Endpoint:
GET /stories/:id
-
Example Response:
{ "id": 1, "title": "Sample Story", "date": "2023-01-01", "content": "Story content here.", "youtubeVideoId": "abcd1234" }
The API returns data in the following structure:
interface Story {
id: number;
title: string;
date: string;
content: string;
youtubeVideoId: string;
}
If you’re using Angular, here’s a quick example of setting up a service to fetch stories:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class StoriesService {
private apiUrl = 'http://localhost:3000/stories';
constructor(private http: HttpClient) {}
getAllStories(): Observable<any> {
return this.http.get(`${this.apiUrl}`);
}
getStoryById(id: number): Observable<any> {
return this.http.get(`${this.apiUrl}/${id}`);
}
}
Now, you're all set to explore and integrate the Eleroui Stories API into your projects. Enjoy building!
Contributions are welcome! If you'd like to contribute to the Eleroui Stories API, please fork the repository and submit a pull request. Feel free to open issues for any bug reports or feature requests.
This project is licensed under the MIT License. You are free to use, modify, and distribute this software in accordance with the license.