REST[Representational State Transfer]: Click this link for REST API Basics
A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.
- A RESTful API — also referred to as a RESTful web service — is based on representational state transfer (REST) technology, an architectural style and approach to communications often used in web services development.
- A Rest API Works the same way normal Client Server Application Works.
Example 1 Facebook API:
- Access the Facebook API by accessing the url https://developers.facebook.com/tools/explorer/ in a browser.
- Fetch the Access Token by clicking on GetToken->Get User Token->Provide credentials of Facebook. Automatically the Access Token is updated in the text box.
- Provide the Query Params as mentioned below :
GET graph.facebook.com/me?fields=id,name,picture
- Retrieve up to five albums created by someone, and the last five posts in their feed.
GET graph.facebook.com/me?fields=albums.limit(5),posts.limit(5)
- Retrieve the photos
GET graph.facebook.com/me/photos
Example 2 Google Maps API:
- Open Chrome Browser
- Provide the following url and verify the JSON[Java Script Object Notation]
http://maps.google.com/maps/api/geocode/json?address=newyork
Validating the JSON Response:
- Access jsonpath.com
- Provide the response and verify the content as mentioned below:
Accessing the Facebook API from Postman
- Download postman plugin in chrome.
-
Launch Postman and update the following
- URL https://graph.facebook.com/me
- method type GET
-
query params
- access_token=<access_token from Example 1 Facebook API Step2 as mentioned above>
- fields=id,name,picture
Accessing the Facebook API from WebBrower
- Open the browser
-
Enter the following url
https://graph.facebook.com/me?access_token=<access_token from Example 1 Facebook API Step2 as mentioned above>&fields=id,name,picture