Sending your first request
Create a draft, send it, read the response and save the request.
Overview
The quickest way to try an endpoint is with a draft. A draft is a request that isn't saved in a collection yet. It's kept between launches, so you don't lose it, and you can save it to a collection whenever you decide it's worth keeping.
This article walks through sending a GET request to a public API, reading its response and saving it.
Create a draft
-
Choose File > New Draft Request, or press Shift-Command-N.
The new request appears in the Drafts section of the sidebar and opens in the request editor.
-
In the URL bar, enter
https://api.github.com/repos/apple/swift.
New drafts use GET. To use another method, click the method at the start of the URL bar and choose one. You can change the default method in Relay > Settings > Requests.
Tip
Send the request
Click Send, or press Command-Return.
While the request is in progress, the Send button becomes Stop. To cancel the request, click Stop or press Command-Period.
Read the response
The response appears in the response inspector. At the top, the status badge shows the status code and reason, such as 200 OK.
- Click Body to read the response body. JSON is indented for reading. Click Raw to see it exactly as it arrived.
- Click Headers to see the headers Relay sent and the headers the server returned.
- Click Timeline to see how long the request took, from looking up the host to receiving the last byte.
The request also appears at the top of History in the sidebar. You can select it there later to see this response again.
Save the request to a collection
To keep the request with related ones, save it to a collection.
- If the workspace doesn't have a collection yet, click the Add button (+) at the bottom of the sidebar and choose New Collection. Enter a name and click Create.
- Select the draft in the sidebar.
- Click the Save to Collection button at the end of the URL bar, then choose a collection.
The request moves out of Drafts and into the collection. You can also drag a draft onto a collection in the sidebar, or choose Request > Save to Collection.
To give the request a name, click its title in the toolbar, enter a name and click Rename.
See Also
- Creating and managing requests: Keep requests as drafts or save them in collections, and rename, duplicate and open them in their own windows.
- Inspecting responses: Read a response's status, body and headers, and copy or save what you need.
- Using variables: Insert values into requests with
{{name}}tokens and see where each value comes from.