The API client

Sending HTTP and GraphQL requests, opening WebSockets, filing them in collections, and varying them from one environment to another.

Checked on DevNotes 0.12

The HTTP area (Ctrl3) keeps your requests in collections, sealed like your notes. A request goes to the server you name, and nowhere else.

Starting a request

+ New request, at the end of the tabs or in a collection’s menu, asks what you are starting:

  • HTTP request: a method, a URL, headers and a body.
  • GraphQL request: a query and its variables, sent as a POST.
  • WebSocket: an open connection, messages both ways.

Each request opens in a tab. CtrlEnter sends it (or connects the WebSocket), CtrlS saves it in a collection.

The parts of a request

  • Parameters and Headers: key / value tables, each row can be switched off. Those DevNotes adds by itself are shown apart.
  • Auth: Inherited, None, Basic, Bearer or API key, sent in a header or in the query.
  • Body: JSON, text, form, multipart or file. A file is read when the request is sent, its bytes are never kept.
  • Settings: the timeout, redirects, TLS certificate verification and cookies.

The response

The status, the duration and the size, then the body Formatted or Raw; a JSON also reads as a Graph or a Tree. Beside it, the Headers, the Cookies set and the Timeline of the exchange. A response is saved to a file or kept as a note.

Collections and folders

A collection files requests, in folders if you like. Its Settings… pass down to its requests: a request whose auth is Inherited takes its folder’s or its collection’s, and their headers are added to its own.

In the collections rail
KeysAction
Alt↑↓Move a row among its neighbours
Alt→File it in the folder just above
Alt←Take it out of its folder
F2Rename
DeleteDelete, after confirmation

Variables and environments

A variable is written between double braces, anywhere in the request:

A URL that varies with the environment
GET {{base_url}}/v1/invoices?status=paid

It is resolved when the request is sent, from nearest to farthest: the request, its folder, its collection, the active environment, then the globals. Under the URL, each name shows where its value comes from. A name nothing defines blocks the send rather than going out as it is, and Set in … opens the place to define it.

  1. Manage environments… creates Local, Staging, Production: each a set of variables, with a colour.
  2. The active environment is chosen at the end of the tabs. None keeps the globals alone.
  3. A variable is Text, a Number or a Secret: a secret is masked on screen and never written to the history.

A protected environment asks before sending anything other than a GET, a HEAD or an OPTIONS, and before opening a WebSocket. Put it on production.

A snippet’s {{fields}} and a request’s variables are written alike, but do not mix: the former are asked for on copy, the latter resolved on send.

History

Every send is recorded in the History, encrypted like your notes: 30 days, 500 sends at most. A send can be read again, reopened in its request or as a draft, and erased. Secrets are masked before they are written.

A request’s code

The </> Code button writes the request for twenty targets, from cURL and PowerShell to fetch, axios or Angular’s HttpClient. Variables can be resolved in it; secrets stay as variables, unless you ask to include them.

WebSockets

A WebSocket connects, then exchanges: the log shows every message sent and received, with its time. Messages can be kept to send again. Switching library closes the open connections.