An open API service indexing awesome lists of open source software.

https://github.com/rahul-ghadge/node-superhero-api

Super hero apis - get data related to marvel super heros in json format using node express JS
https://github.com/rahul-ghadge/node-superhero-api

expressjs json nodejs restful-api

Last synced: 3 months ago
JSON representation

Super hero apis - get data related to marvel super heros in json format using node express JS

Awesome Lists containing this project

README

          

# node-superhero-api
Super hero apis - get data related to marvel super heros

This application exposes REST APIs for Super heros data

It will provide out the json response in return for success.

Features Implemented :

* `package.json` file constains information about application and dependencies.
* `server.js` file conntains configuration of application like port, body parsing, express, importing routing.
* `routers.js` form `app > routers` directory contains routing for API Endpoints, and calls respective functions from **controller.js**.
* `controller.js` form `app > controller` directory contains functions which returns data on-demand related to super heros in JSON format.
* `superHeros.js` form `app > models` directory holding static data for Super Heros.

---------------------------------------------------------

Run server which will listen requests coming on port: 3000

> node server.js

---------------------------------------------------------
## API Endpoints
Get all super heros via `http://host:port/super-heros`

http://localhost:3000/super-heros **(GET Method)**
  - This API will return all super heros from `superHeros.js`

http://localhost:3000/super-heros/Tony **(GET Method)**
  - This API will return Iron Mans data

http://localhost:3000/super-heros **(POST Method)**
Request- ```{
"name": "Black panther",
"superName": "Black panther",
"profession": "King",
"age": 30,
"canFly": false
}```
  - This API will return success message along with all super hero present in team

http://localhost:3000/super-heros/Wade **(PUT Method)**
Request:- ```{
"name": "Wade",
"superName": "Deadpool",
"profession": "Street fighter",
"age": 28,
"canFly": false
}```
  - This API will update Deadpools data from flying to non-flying
Response:- ```{
"message": "Super hero's data updated secretly",
"superHero": {
"name": "Wade",
"superName": "Deadpool",
"profession": "Street fighter",
"age": 28,
"canFly": false
}
}```

http://localhost:3000/super-heros/Wade **(DELETE Method)**
  - This API will remove Wade from super heros and return back all other heros