Here’s a cheat sheet for using Postman, a popular API testing and development tool:
Request Basics
- Create a New Request:
- Click on the “New” button and select “Request.”
- Set Request Type:
- Choose the HTTP method (GET, POST, PUT, DELETE, etc.) from the dropdown.
- Enter Request URL:
- Enter the API endpoint URL in the address bar.
- Add Headers:
- Click on the “Headers” tab to add key-value pairs for request headers.
- Set Request Body (for POST and PUT):
- Click on the “Body” tab to add parameters or raw data.
Authentication
- Basic Authentication:
- In the “Authorization” tab, select “Basic Auth” and provide username/password.
- Bearer Token Authentication:
- In the “Authorization” tab, select “Bearer Token” and provide the token.
- API Key Authentication:
- In the “Headers” tab, add a key-value pair for the API key.
Parameters
- URL Parameters:
- Add parameters directly to the URL or use the “Params” tab.
- Query Parameters:
- Add parameters in the “Params” tab for GET requests.
Request Body
- Form Data:
- In the “Body” tab, select “form-data” to send key-value pairs.
- x-www-form-urlencoded:
- Choose this option in the “Body” tab to send URL-encoded data.
- Raw Data:
- Select “raw” in the “Body” tab to send data in raw format (JSON, XML, etc.).
Response
- View Response:
- After sending the request, view the response in the “Body” tab.
- Formatting Response:
- Use the “Pretty” button to format JSON/XML responses.
- Status Code and Headers:
- Check the status code and headers in the “Headers” tab.
Collections
- Create a Collection:
- Click on the “New” button and select “Collection.”
- Add Requests to Collection:
- Drag requests into a collection or use the “Add to” button.
- Run Collections:
- Click on the “Runner” button to execute multiple requests in a collection.
Testing
- Write Tests:
- In the “Tests” tab, write JavaScript tests using the Postman test scripting syntax.
- Test Automation:
- Integrate with Postman Monitors or Newman for automated testing.
Variables and Environments
- Use Variables:
- Set variables to reuse values across requests.
- Manage Environments:
- Create environments for different sets of variables.
- Switch Environments:
- Change the environment in the top-right corner.
Newman (Command-Line Tool)
Install Newman:
npm install -g newman
Run a Collection:
newman run collection_name.json
Keyboard Shortcuts
- Send Request:
- Press
Ctrl + Enter
to send the request.
- Press
- Toggle Sidebar:
- Press
Ctrl + Alt + S
to show/hide the sidebar.
- Press
- Save Request:
- Press
Ctrl + S
to save the request.
- Press
- Toggle Console:
- Press
Ctrl +
to toggle the console.
- Press
This cheat sheet covers basic Postman functionalities. Explore Postman’s documentation for more advanced features and capabilities: Postman Documentation.