# Using HTTP

> Call the methods that answer once over plain HTTP, and how params go in a URL.

This page is part of the Intear API docs. The Intear API is at `https://api.intea.rs` and `wss://api.intea.rs/ws`, with no API key. https://docs.intear.tech/api/llms-full.txt has all of its pages in one file, and https://docs.intear.tech/llms.txt lists every page of the Intear docs.

Every method that answers once, except `tokens.update` and `unsubscribe`, is plain HTTP too, on `https://api.intea.rs`, for clients that don't need anything live:

| Path | Method |
| --- | --- |
| `/tokens` | [`tokens.get`](https://docs.intear.tech/api/reference/tokens.md#tokensget) |
| `/tokens/search` | [`tokens.search`](https://docs.intear.tech/api/reference/tokens.md#tokenssearch) |
| `/trades` | [`trades.query`](https://docs.intear.tech/api/reference/trades.md#tradesquery) |
| `/transfers` | [`transfers.query`](https://docs.intear.tech/api/reference/transfers.md) |
| `/candles` | [`candles.get`](https://docs.intear.tech/api/reference/candles.md#candlesget) |
| `/prices/at` | [`prices.at`](https://docs.intear.tech/api/reference/prices.md#pricesat) |
| `/balances` | [`balances.get`](https://docs.intear.tech/api/reference/balances.md#balancesget) |
| `/holders` | [`holders.get`](https://docs.intear.tech/api/reference/holders.md#holdersget) |
| `/positions` | [`positions.get`](https://docs.intear.tech/api/reference/positions.md#positionsget) |
| `/traders` | [`traders.get`](https://docs.intear.tech/api/reference/traders.md#tradersget) |
| `/accounts/search` | [`accounts.search`](https://docs.intear.tech/api/reference/accounts.md#accountssearch) |
| `/schema` | [`schema`](https://docs.intear.tech/api/reference/messages.md#schema) |

The response's body is what the method's `result` would be on the WebSocket.

Some paths are HTTP only, with no method on the WebSocket: [`/public_key/{key}`](https://docs.intear.tech/api/reference/accounts.md#accounts-by-public-key), [`/stats`](https://docs.intear.tech/api/reference/accounts.md#key-stats), [`/cosmetics`](https://docs.intear.tech/api/reference/trades.md#referrers-names-and-icons) token icons at [`/icon/<icon_hash>.webp`](https://docs.intear.tech/api/guides/live-token-lists.md#icons), and banners at [`/banner/<banner_hash>.webp`](https://docs.intear.tech/api/reference/token-fields.md#metadata).

## GET or POST

A `GET` takes the params in its URL. A `POST` takes them as a JSON body, exactly as `params` on the WebSocket, for what's too long for a URL:

```sh
curl -X POST https://api.intea.rs/tokens \
  -d '{"fields": ["symbol", "price_usd"], "ids": ["wrap.near", "usdt.tether-token.near"]}'
```

## Params in a URL

- A list is comma-separated: `fields=symbol,price_usd`.
- An object's keys are dotted: `min_change.price_usd=0.1%25` (`%` is URL-encoded).
- `where`'s params go without `where`: `min_reputation=NotFake`, `min.liquidity_usd=1000`.
- `sort=volume_usd_24h` sorts ascending, and `sort=-volume_usd_24h` descending.
- `prices.at`'s queries are `at=<token>:<timestamp_millis>`, comma-separated.
- A param given twice, or one the method doesn't take, is a `bad_request`. `/schema`, `/stats` and `/cosmetics` take none, and ignore unknown ones.

For example, the 10 `NotFake` or `Reputable` tokens with the most volume in the last 24 hours:

```
GET https://api.intea.rs/tokens?fields=symbol,price_usd,volume_usd_24h&sort=-volume_usd_24h&limit=10&min_reputation=NotFake
```

## Errors

An error is `{ "error": { "code": "...", "message": "..." } }`, with the status:

| Status | Codes |
| --- | --- |
| `404` | `not_found`, and `unknown_method` for a path nothing is served at |
| `500` | `internal` |
| `503` | `not_indexed` |
| `400` | every other code |

See [Errors](https://docs.intear.tech/api/reference/errors.md) for what each code means.

## Caching and compression

Responses can be cached for a second (`Cache-Control: public, max-age=1`), `/stats` for 10 seconds, and `/cosmetics` for a minute. Responses only about the past can be cached for a day (`max-age=86400`):
- history with a `cursor` (newest first), with a `before_millis` the latest block has passed, or oldest first with a `next_cursor`;
- candles up to a `to_millis` whose candle has closed;
- `prices.at` of times the latest block has passed.

Candles and `prices.at` aren't cached for a day when a token asked about doesn't exist, since it may yet. A cached response keeps the `height` and `latest_id` it was first answered with.

Responses allow any origin (CORS), and are compressed with `gzip` or `zstd` when the request's `Accept-Encoding` allows it. The `X-Credits-Used` header has the [credits](https://docs.intear.tech/api/reference/limits.md#credits) a method's response would cost.
