Get started · Lesson 1 of 20

Send your first request

Open the app, send a request, read what came back and keep the request for later.

Beginner · 2 min · Updated

Pick an environment, send a REST request, read the JSON response and see every test pass.
Pick an environment, send a REST request, read the JSON response and see every test pass.

An API request is a message to a server: a method (what you want to do, such as GET to read or POST to create), a URL (where), and optionally headers and a body. The server answers with a status code, its own headers and a body. In this lesson you send one and learn to read the answer.

Open the app

Create a free account with GitHub or an email address, then go to swastik.codes/app. Your requests are saved in the cloud and available on every device. Want something to stay on this computer only? Use the Scratch Pad, a local workspace whose data never leaves your browser. Prefer a desktop app? Download it for Windows or Linux; everything in these lessons works the same there.

Send a request

  1. Click New at the top, then HTTP request (or press Ctrl+T).
  2. Leave the method as GET and type this URL: https://httpbin.org/get?hello=world
  3. Press Send (or Ctrl+Enter).

The response appears below the request (or beside it on a wide screen).

Read the response

  • Status: 200 OK means it worked. 4xx codes mean the request was wrong (for example 401 not signed in, 404 not found); 5xx codes mean the server failed.
  • Time and size: how long the answer took and how big it was. Hover over the time to see where it went: DNS, connecting, TLS, waiting for the first byte and downloading.
  • Body: the data. JSON is formatted and coloured; switch to Raw to see it exactly as it arrived, or use the tree view to fold big objects.
  • Headers and Cookies: what the server sent besides the body.

Notice that hello=world from the URL also appears in the Params tab of the request. Editing either one updates the other.

Send data with POST

  1. Change the method to POST and the URL to https://httpbin.org/post.
  2. Open the Body tab, choose raw and JSON, and type:
JSON
{ "name": "Ada", "role": "admin" }
  1. Press Send. httpbin echoes your JSON back under json, which proves the server received it.

Swastik Codes adds the Content-Type: application/json header for you. You can see it, and add your own, in the Headers tab.

Save the request

Press Ctrl+S. The first time, Swastik Codes asks where to save: create a collection (call it My first API) and give the request a name such as Create user. Collections are folders for requests; the next lessons use them for variables, tests and runs.

What you learned

  • A request is a method, a URL, headers and a body; a response is a status, headers and a body.
  • Ctrl+Enter sends, Ctrl+S saves, and History keeps everything you sent.

Next: stop typing the same server address in every request by using variables.

Try it on your own API

Swastik Codes runs in the browser and is free to use. Create an account to send requests, sync your workspaces and invite your team.