GETTING STARTED / LESSON 01

Your first request

Talk to a real API, change its input, and see what comes back. Start with a little ASCII art.

An API lets one program ask another program to do something. We’ll start with FIGlet, an API that turns a short message into large letters made from ordinary text characters.

Ask for some text

curl is a command-line tool for making HTTP requests. Run the command below. The command is editable, and the output comes from the live FIGlet server.

The URL has a path, /api/figlet, and a query parameter, text. The %20 represents a space in the message. With no method specified, curl sends a GET request.

Your turn: Replace This%20too%20shall%20pass with your name and run it again. Then add -i after curl to reveal the response headers.

The same request, with a form

You can also make the request using an API explorer. Select a method, edit the URL, and press Send. The server receives the same kind of HTTP request.

Request headers 0

Click Show headers after sending. Look for content-type: this API returns text/plain, so the explorer preserves its spaces and line breaks. Not every API returns JSON.

Try a smaller response

The Numbers API accepts two integers and returns their sum. Both values are query parameters; & separates them. Keep the URL quoted in curl so a shell would treat it as one argument.

Experiment: Change a=3 to a=hello. What status do you get? What does the response body tell you? Add -i to inspect the status and headers.

You have now sent requests to two real APIs. Next, we’ll inspect JSON and send data in a request body.