RESTful API


NodeJS

What is RESTful API?

  • Based on HTTP Protocol
  • Resource represent URI(Uniform Resource Identifiers) and should be “Unique”
  • Simple URI
  • We identify Resource status using HTTP Methods
  • Send a data with xml/json

CRUD Action to manage web resource through network.
We have 4 HTTP methods (POST, GET, PUT, DELETE)

  • Create (POST)
  • Retrieve (GET)
  • Update (PUT)
  • Delete (DELETE)

API Design

  • use a plural noun (e.g, /movies)
  • if needed, mention sub-resouce to URL (/movies/23)
  • you can also use filter condition (/movies?state=active)

Example

URLMethodsDescription
/MoviesGETget all movie list
/MoviesPOSTadd movie
/movies/:titlegetget title of the movie
/movies/:titleDELETEdelete title of the moive
/movies/:titlePUTupdate title of the movie
/movies?min=9GETMovie list which is currently running





© 2017. by isme2n

Powered by aiden