Skip to main content

Command Palette

Search for a command to run...

Cheat Sheet #day20 - Postman

Published
3 min readView as Markdown
Cheat Sheet #day20 - Postman

Postman Cheat Sheet

Postman is a popular tool used for API testing and development. It provides a user-friendly interface to send requests, inspect responses, and automate testing. Below is a cheat sheet to help you navigate the essential features and functionalities of Postman.

Basic Operations

  • Create a New Request

    • Click the + button next to the existing tab or use Ctrl+T (Cmd+T on Mac).

    • Enter the request URL and select the HTTP method (GET, POST, PUT, DELETE, etc.).

  • Save a Request

    • Click the Save button, choose a collection, and name your request.
  • Send a Request

    • Fill in the required details and click the Send button.

Request Components

  • URL Parameters

    • Add query parameters by clicking on Params and entering key-value pairs.
  • Headers

    • Click on Headers and add necessary headers by entering key-value pairs.
  • Body

    • Select the Body tab and choose the appropriate format (raw, form-data, x-www-form-urlencoded, binary, GraphQL).
  • Authorization

    • Select the Authorization tab to choose an authorization type (No Auth, Basic Auth, Bearer Token, API Key, etc.).

Collections and Folders

  • Create a New Collection

    • Click the New button and select Collection. Name your collection.
  • Add a Request to a Collection

    • After creating or opening a request, click the Save button and select the collection to save it in.
  • Create a Folder in a Collection

    • Right-click on a collection and choose Add Folder. Name your folder.

Environment Variables

  • Create an Environment

    • Click the gear icon in the top-right corner and select Manage Environments. Click Add to create a new environment.
  • Add Variables to an Environment

    • Inside your environment, add key-value pairs. Use {{variableName}} in your requests to reference these variables.
  • Switch Environments

    • Click the environment dropdown at the top right and select your desired environment.

Pre-Request and Test Scripts

  • Add a Pre-Request Script

    • Open a request and select the Pre-request Script tab. Write JavaScript code to run before the request is sent.
  • Add a Test Script

    • Open a request and select the Tests tab. Write JavaScript code to run after the response is received.

Running Collections

  • Collection Runner

    • Click the Runner button at the top left, select the collection, and configure the run (environment, iterations, delay, etc.).
  • Newman CLI

    • Install Newman via npm:

        npm install -g newman
      
    • Run a collection using Newman:

        newman run path/to/collection.json -e path/to/environment.json
      

Response Components

  • View Response

    • After sending a request, view the response in the Body, Headers, Cookies, and Test Results tabs.
  • Response Status and Time

    • Check the status code, response time, and size in the response area.
  • Save Response

    • Click the Save Response button to save the response to a file.

Advanced Features

  • Monitor

    • Click on a collection, then Monitor Collection to create a monitor that runs your collection at defined intervals.
  • Mock Servers

    • Click the New button, select Mock Server, and configure your mock server.
  • Documentation

    • Click on a collection and choose Publish Docs to generate and share API documentation.

Shortcuts

  • New Tab: Ctrl+T (Cmd+T on Mac)

  • Close Tab: Ctrl+W (Cmd+W on Mac)

  • Save Request: Ctrl+S (Cmd+S on Mac)

  • Toggle Sidebar: Ctrl+\ (Cmd+\ on Mac)

  • Send Request: Ctrl+Enter (Cmd+Enter on Mac)

  • Find: Ctrl+F (Cmd+F on Mac)

This cheat sheet covers the fundamental aspects of Postman to help you get started and work efficiently with APIs. For more detailed information, refer to the official Postman documentation.