---
title: Test APIs with .api files
project: Code
version: 2.0
section: guides
language: en
license: MIT
url: https://totaljs.es/docs/code/2-0/guides/api-requests/
updated: 2026-11-19T04:32:04.377Z
---

# Test APIs with .api files

> Write HTTP requests in a file and send them from the editor.

A file with the `.api` extension holds HTTP requests that you can send from the editor.

## Write a request

Create a file such as `requests.api`:

```text
// Requests of my application
$host : https://www.example.com

GET $host/ping/

POST $host/api/items/
Content-Type: application/json

{ "name": "Demo item" }
```

- A line with `$name : value` defines a variable.
- `$name` in a request is replaced by its value.
- Lines that start with `//` are comments.
- Headers go under the first line of the request, and the body comes after them.

## Send a request

1. Select the lines of one request.
2. Press `Ctrl+B`, or `Cmd+B` on macOS.

The **Output panel** opens with the status, the headers and the response.

![An .api file with a selected request and its response in the Output panel](/files/JanvrY21R60f.webp)

Click **Clear output** to empty the panel.
