API stands for Application Programming Interface and basically its something that allows one piece of software to talk to another.
When you here people talking about Twitter API, Face-book API they mean REST API.
HTTP is the foundation of REST service.
Postman is a Chrome extension. It’s an HTTP client for testing web services. It can only run on the Chrome browser. It supports number of HTTP methods. Some of frequently used methods are as below:
1. GET : This method is used to retrieve some data from the server
2. PUT: This method is used to update or add data to our application or on to a database.
3. HEAD : This method is same as GET except that their is no response body. Their will be only header in the response.
4. POST: This method is used to create new entity on to a database. It is often used when uploading a file or submitting a completed web form.
5. DELETE: This method used to delete the resource identified by the Request-URI.
Install Postman
- Go to Google Chrome’s Web Store
- If you already have Chrome installed, head over to Postman’s page on the Chrome Webstore – https://chrome.google.com/webstore/detail/postman-rest-client-packa/fhbjgbiflinjbdggehcddcbncdddomop?hl=en, and click ‘Add to Chrome’.
How to use Advanced Rest Client
- One installed, launch the extension
- Enter the URL of the API in the URL textbox
- Select the radio button for the type of HTTP method to hit- e.g. POST
- Provide Headers (if required), in the Headers textbox
- Under Payload, pass the request body of the API in the form of key-value pairs e.g. {{“key1″:”value1″,”key2″:”value2”}
- Set the required content type e.g. application/json
- Hit the send button
Here is an example of Uploading an image using postman.
In this example, uploading an image and giving the correct data which returns success as response:
In case of empty image, returns error message (Bad request : 400)
Collection in Postman
A collection group the individual requests together. These requests can store sample responses when saved in a collection. We can add metadata like name and description too so that all the information that a developer needs to use API is available easily.
Creating a collection
To create a new collection, click on “New collection” button under the collections side bar tab and give the collection name with description.
Collections are also created –
- If you have a request loaded in the request editor already, click “Add to collection”. Enter a new collection name instead of selecting an existing collection. The collection will be created and the request will be added to the collection.
- You can import a collection file. Click on the ‘Import’ button on the top bar, and paste a URL to the collection, or the collection JSON itself, and click ‘Import’.
We can also perform operations on collection, we can edit, delete or share our collection. We are also able to add folder in the collection.