Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahmnouira/express-restful-api-movies
Express RESTfull API for movies
https://github.com/ahmnouira/express-restful-api-movies
api-rest body-parser express express-js film http htttp-request imdb imdb-api json-api machine movies python request rest restful-api standalone underscore
Last synced: about 2 months ago
JSON representation
Express RESTfull API for movies
- Host: GitHub
- URL: https://github.com/ahmnouira/express-restful-api-movies
- Owner: ahmnouira
- License: mit
- Created: 2019-08-24T20:01:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T11:55:17.000Z (about 1 year ago)
- Last Synced: 2024-05-21T03:03:42.441Z (7 months ago)
- Topics: api-rest, body-parser, express, express-js, film, http, htttp-request, imdb, imdb-api, json-api, machine, movies, python, request, rest, restful-api, standalone, underscore
- Language: JavaScript
- Size: 182 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-restful-api-movies
Express RESTful API for movies.
# Running this app
1. As a standalone app running on your machine.
## I. As a standalone app
1. install [node.js](https://nodejs.org/en/) or run `sudo apt-get install nodejs`.
2. `git clone` the project then `cd` into the directory.
3. run `npm install` to install the application dependencies.### 1. running the app
After installing, run the server using `npm start`.
Access the running app in a browser at the URL written to the console (http://0.0.0.0:5000).### 2. Testing the API
To test the API implementation I will use **python** along with `requests` and `json` modules.
1. check if you have python installed in your machine `python`.
2. `pip install requests` to install requests module.#### 2.1 **GET** request
* run the application.
* open another Terminal session `Ctrl + Shift + T` and run `python`, then enter the following code:``` python
import requests
import jsonres = requests.get('http://0.0.0.0:5000/')
res.json()
```
![GET](/img/GET.png)
#### 2.2 **POST** request
* run the application.
* open another Terminal session `Ctrl+Shift+T` and run `python`, then enter the following code:``` python
import requests
import jsonmovie = {"Id": "5", "Title": "Avengers:Endgame", "Director": "['Anthony Russo', 'Joe Russo']", "Year": "2019", "Rating": "8.6"}
res = requests.post('http://localhost:5000/', data=json.dumps(movie), headers={'Content-Type': 'application/json'})
res.json()
```
![POST](/img/POST.png)
#### 2.3 **PUT** request
* run the application.
* open another Terminal session `Ctrl+Shift+T` and run `python`, then enter the following code:**Note:** I gonna to update the **film Killer Klowns from Outer Space** film with **The Lord of the Rings: The Two Towers**.
```python
import requests
import jsonmovie = {"Title": "The Lord of the Rings: The Two Towers", "Director": "Peter Jackson", "Year": "2002", "Rating": "8.7"}
res = requests.put('http://0.0.0.0:5000/3', data=json.dumps(movie), headers={'Content-Type': 'application/json'})
res.json()
```
![PUT](img/PUT.png)
#### 2.4 **DELETE** request
* run the application.
* open another Terminal session `Ctrl+Shift+T` and run `python`, then enter the following code:**Note:** I gonna to delete the **Aliens** film.
```python
import requests
import jsonres = requests.delete('http://192.168.1.5:5000/1')
res.json()
```
![DELETE](img/DELETE.png)
### 3. Customize the API representation
* Nagivate to (http://localhost:5000/external) and see the customized API representaion.
![customized](img/customized.png)
### 4. [IMDb]('https://www.imdb.com/') API request
* Navigate to (http://localhost:5000/imdb) and see the customized API collected from IMDb.
![IMDb](img/imdb.png)