An Introduction To Rest Api: Presented By: Aniruddh Bhilvare 22 April, 2017
An Introduction To Rest Api: Presented By: Aniruddh Bhilvare 22 April, 2017
REST API
Presented By:
Aniruddh Bhilvare
22 April, 2017
What is it ?
JSON GET RESPONSE
POST
WEB RESPONSE
URL
INTERNET HEADER
API
METHOD
REQUEST
HTTP
What is it ?
REST means
REpresentational
State
Transfer
REpresentational ? State ? Transfer ?
It represent the state of database at a time. But how???
You typically have a REST server which provides access to the resources and
a REST client which accesses and modifies the REST resources.
REpresentational ? State ? Transfer ?
Every resource should support the HTTP common operations.
Resources are identified by global IDs (which are typically URIs or URLs).
REST allows that resources have different representations, e.g., text, XML,
JSON etc.
{"status":"success","message":"City
List","data":[{"city_name":"Visakhapatnam"},{"city_name":"Vijayawada"}]}
GET /users/711?activate or
GET /users/711/activate
Use sub-resources for relation:
If a resource is related to another resource use subresources
Use a simple ordinal number and avoid dot notation such as 2.5
We are using the url for the API versioning starting with the letter “v”
/blog/api/v1
Handle Errors with HTTP Status code:
200 OK (Everything is working) 403 Forbidden (The server understood the
request, but is refusing it or the access is
not allowed)
201 OK (New resource has been created) 404 Not found (There is no resource behind the
URI)
400 Bad Request (The request was invalid or 408 Request timeout
cannot be served. The exact error should
be explained in the error payload. E.g.
„The JSON is not valid“)
GET /cars?sort=-manufacturer,+model
GET /cars?offset=10&limit=5
Aliases for common queries:
To make the API experience more pleasant for the average consumer,
consider packaging up sets of conditions into easily accessible RESTful
paths.
POST /users/login (User Login: Creates auth token for user authentication)
Want to develop REST APIs easily???
Documentation: https://www.slimframework.com/docs/
Thanks for your Time & Patience!
Any Question?