Skip to content

How To Use Postman In Chrome Extension

API Testing Blog

Seamless API Testing with Postman Chrome Extension

Postman is a popular tool for API testing, and its Chrome extension offers a powerful yet convenient way to interact with APIs directly from your browser. This guide demonstrates how to leverage this extension for your testing needs.

1. Installation and Setup

  1. Download and Install: Visit the Chrome Web Store and search for “Postman”. Click “Add to Chrome” to install the extension.
  2. Sign Up (Optional): Postman offers both free and paid plans. Signing up allows you to sync your collections across devices and collaborate with team members.
  3. Launch the Extension: Access the extension through the Chrome extensions icon (usually found in the top-right corner of your browser).

2. Creating and Managing Collections

Collections in Postman act as containers for your API requests and responses.

  1. Create a New Collection: In the Postman interface, click the ”+” button and choose “Create Collection.” Give your collection a descriptive name.
  2. Add Requests: Click the “Add Request” button to add a new request to the collection.
  3. Organize Your Requests: Use folders within a collection to group related requests. This helps maintain order for complex APIs.

Example:

Collection Name: Weather API
Folder: Current Weather
Request: Get Current Weather (GET /weather?q=London)
Folder: Forecast
Request: Get 5 Day Forecast (GET /forecast?q=NewYork)

3. Crafting Your API Requests

  1. Choose HTTP Method: Select the appropriate HTTP method (GET, POST, PUT, DELETE, etc.) from the dropdown menu.
  2. Enter Request URL: Provide the full URL of the API endpoint you wish to interact with.
  3. Add Headers: Headers provide additional information about the request. You can add headers like “Content-Type” or “Authorization” to specify the request type and include authentication details.
  4. Send Requests: Click the “Send” button to execute the request.

Example: Getting weather information for London:

Request:

  • Method: GET
  • URL: https://api.openweathermap.org/data/2.5/weather?q=London&appid=YOUR_API_KEY
  • Headers:
    • Content-Type: application/json
    • Accept: application/json

Response:

{
"coord": {
"lon": -0.1257,
"lat": 51.5074
},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01d"
}
],
"main": {
"temp": 282.55,
"feels_like": 278.89,
"temp_min": 280.15,
"temp_max": 284.15,
"pressure": 1018,
"humidity": 77
},
"visibility": 10000,
"wind": {
"speed": 4.6,
"deg": 280
},
"clouds": {
"all": 0
},
"dt": 1690037418,
"sys": {
"type": 1,
"id": 1422,
"country": "GB",
"sunrise": 1690004038,
"sunset": 1690052494
},
"timezone": 3600,
"id": 2643743,
"name": "London",
"cod": 200
}

4. Working with Parameters and Variables

Postman offers functionalities to manage variables and parameters, making your requests more dynamic.

Parameters:

  1. URL Parameters: Use ”?” followed by key=value pairs to append parameters to the URL.
  2. Query Parameters: Specify parameters within the “Params” tab of a request.

Example: Searching for a movie by title:

Request:

  • Method: GET
  • URL: https://api.themoviedb.org/3/search/movie?api_key=YOUR_API_KEY&query=Avengers

Variables:

  1. Environment Variables: Define global variables for shared values across multiple requests.
  2. Collection Variables: Define variables at the collection level, specific to the collection your requests are in.

Example: Storing API keys as environment variables:

  • Environment Name: “Movie API”
  • Variable Name: “api_key”
  • Variable Value: “YOUR_API_KEY”

5. Test Assertions for Validation

Postman allows you to add tests to your requests to validate the responses against specific criteria. This helps automate your tests, ensuring your API behaves as expected.

  1. Create a Test Script: Click the “Tests” tab in a request to write your test scripts.
  2. Utilize Assertions: Postman offers various built-in assertions to evaluate different aspects of the response.

Example: Verifying the response status code in the Weather API example:

pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});

6. Running Collections and Generating Reports

  1. Run a Collection: Right-click on a collection and select “Run”. Postman executes all requests in order, providing feedback on each request.
  2. Generate Reports: Postman can generate reports that summarize your test results, including pass/fail rates, response times, and more. This helps you identify potential issues and track API performance over time.

Conclusion

Postman’s Chrome extension provides a powerful and user-friendly way to conduct API testing directly from your browser. By mastering its features, you can streamline your testing process, ensuring the quality and reliability of your APIs.

API Testing Blog