API-gränssnitt

Postman

bild.png

First 5 things to try if you’re new to Postman

#1 Send a request

Most everybody knows Postman as an HTTP client—a handy way to and receive a response. If you haven’t already done this, go ahead and try it out. Hit your favorite endpoint and inspect your response. Play around with different HTTP verbs, headers, and auth types.
If you don’t have a favorite endpoint at the ready, the is included in your Postman app download. It’s a good way to try out different request types.
image.png

#2 Write a test

For a lot of people, Postman is synonymous with API testing. For some, that might mean sending and inspecting a response like we did in Step #1. It could also mean writing assertions to validate that an endpoint is returning the appropriate responses. It can also mean setting up logic to mirror your workflow and automating the tests.
The easiest way to get started with is to take a look at the snippets on the right side of the Tests tab. Clicking on a snippet will append the JavaScript code into the editor. If you’re comfortable writing your own tests, or updating the boilerplate code, the world is your oyster!
Send your request again, and now you can see the results of your test on the bottom, under the corresponding Tests tab in the response viewer.
image.png
Dig deeper with this blog post about .

#3 Create and run a collection

Collections are the cornerstone for all advanced Postman features. At its simplest, a collection is a way to group together requests and run those requests in a pre-determined sequence. In all its glory, a collection is an executable description of an API.
, and maybe add a few more if you feel like it. Click on the chevron (>) next to the collection name, and hit the blue Run button to open the collection runner in a new window.
When you run your collection in the Postman app with the , you will see the requests being sent and the tests running.
image.gif
Dig deeper with this blog post about the .

#4 Chain your requests

You can chain requests so that you can use the first request’s response in the next request. Is it magic? No, it’s the .
Once you create and select an , you can store information in key-value pairs within a Postman environment. Let’s try it out.
Use the pm.* API to set and get environment variables in the scripting sections. Under the Tests tab, set an environment variable with pm.environment.set("variableName", variableValue). Now that you’ve initialized the variable, you can use this value in any subsequent requests in the text sections like {{variableName}} or in the scripting sections like pm.environment.get("variableName").
image.png
Dig deeper with this blog post about .

#5 Take it further

Once you’ve mastered those Postman basics, try these out for further study:
Or level up your Postman game with one of our advanced features:
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.