# Algotrade.io Signals API Quick Start

The Signals API returns the latest BUY and SELL signals for BTC
to subscribers.

## Access

1. Create an account with **Get started** at the top of any page, and verify your email address.
2. Subscribe on the [Subscription](https://algotrade.io/subscription) page.
3. Sign in and copy your API key from the Auth section of the [API Docs](https://algotrade.io/docs#auth) page.

## Request

Send the key in the `X-API-Key` header:

```sh
curl -H "X-API-Key: $API_KEY" https://api.algotrade.io/signals
```

## API Key

Every request needs your API key. It is in the Auth section of the [API Docs](https://algotrade.io/docs#auth) page once you sign in. Each account has one key.

- Your key also arrives in the `X-API-Key` header of every webhook alert sent to you, so anything that logs your webhook requests holds your key.
- You are responsible for keeping your password and account confidential.
- If your key may have leaked, replace it. See [Key Rotation](#key-rotation).

A missing or unknown key gets a `401`. See [Errors](#errors).

## Response

A successful request returns status `200` and JSON like this example,
whose values are illustrative:

```json
{
  "message": "You have 4 requests left / 1 day(s).",
  "data": [
    {"Date": "2020-01-01", "Signal": "BUY", "Day": "Wed", "Asset": "BTC"},
    {"Date": "2020-01-02", "Signal": "SELL", "Day": "Thu", "Asset": "BTC"}
  ]
}
```

- `message`: how many requests are left in the current 24 hours.
- `data`: the latest signals, up to 7, oldest first.
- `Date`: the date of the signal, as `YYYY-MM-DD`.
- `Signal`: `BUY` or `SELL`.
- `Day`: the day of the week of `Date`, such as `Mon`.
- `Asset`: the asset the signal is for, `BTC`.

## Errors

Errors return JSON with a `message`:

- `401` `Provide a valid API key.`: the `X-API-Key` header is missing or holds an unknown key. Send the key from the Auth section of the [API Docs](https://algotrade.io/docs#auth) page.
- `402` `This endpoint is for subscribers only.`: the account has no subscription. Subscribe on the [Subscription](https://algotrade.io/subscription) page.
- `403` `You have reached your quota of 5 requests / 1 day(s).`: the quota is used up. Wait until 24 hours after the oldest of your last 5 requests.

## Quota

Each account can make 5 requests in any 24 hours.
A request is allowed again 24 hours after the oldest of the last 5.
Each request answered with `200` counts, and its `message` says how many requests are left.
Requests answered with `401`, `402`, or `403` do not count.
The API sends CORS headers for the Algotrade.io site only, so call it from a server or a script.

## Webhooks

Subscribers can also get each new signal as a webhook alert.
Set an https URL on the [Alerts](https://algotrade.io/alerts) page. Its host must resolve to public addresses only.
When a new signal is detected (00:00 to 00:10 UTC), Algotrade.io sends a `POST` to the URL
with a JSON array that holds the signal:

```json
[{"Date": "2020-01-03", "Signal": "BUY", "Day": "Fri", "Asset": "BTC", "Perf": 0.1}]
```

- The fields are those of `data`, plus `Perf`, a number.
- The `X-API-Key` header holds your API key, so your server can check that the alert came from Algotrade.io.
- Each alert is sent once, with a 5 second timeout, and redirects are not followed.

## Webhook Setup

1. Sign in and open the [Alerts](https://algotrade.io/alerts) page.
2. Enter an https URL whose host resolves to public addresses only.

- **Sent once.** A failed alert is not sent again. `GET /signals` still returns the latest signals.
- **5 second timeout.** Answer within 5 seconds, and do any slow work after you answer.
- **No redirects.** Your URL must answer directly. If it answers with a redirect, the alert does not reach the new address.
- **Check the key.** Reject any alert whose `X-API-Key` header does not match your API key.

To check your own server, send it a request shaped like an alert. This calls only your server, not Algotrade.io, and the values are illustrative:

```sh
curl -i -m 5 -X POST "$WEBHOOK_URL" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $API_KEY" \
  -d '[{"Date":"2020-01-03","Signal":"BUY","Day":"Fri","Asset":"BTC","Perf":0.1}]'
```

Check that:

- your server answers within 5 seconds (`-m 5`) and without a redirect;
- a request with a wrong `X-API-Key` is rejected;
- your parser reads `Signal` as the string `BUY` or `SELL` (see [Side Encoding](#side-encoding)).

Webhook alerts are information. What your server does with an alert is set up and controlled by you.

## Key Rotation

**Replace key** in the Auth section of the [API Docs](https://algotrade.io/docs#auth) page gives the account a new API key.
The old key stops working at once.
Webhook alerts carry the new key in their `X-API-Key` header from then on, so update the key your server checks.

## MCP Server

`https://api.algotrade.io/mcp` is a read-only remote MCP server for AI agents, over Streamable HTTP.
Its one tool, `get_signals`, takes no arguments and returns the `message` and `data` that `GET /signals` returns.
Send the API key in the `X-API-Key` header, as with the API.
Each call that returns signals counts toward the same 5 requests in any 24 hours.
The API's error messages come back as tool errors, and listing the tools needs no key.
A client that reads an `mcpServers` config takes the server like this, though the field names vary by client:

```json
{
  "mcpServers": {
    "algotrade": {
      "type": "http",
      "url": "https://api.algotrade.io/mcp",
      "headers": {"X-API-Key": "YOUR_API_KEY"}
    }
  }
}
```

## Side Encoding

`Signal` is the string `BUY` or `SELL` in API responses and webhook alerts.
Webhook alerts sent before 2026-11-26 could carry `true` or `false` instead, and `false` could stand for a BUY.

- Treat `Signal` as `BUY` or `SELL`. Reject or log any other value instead of guessing.
- Do not infer a side from `true` or `false` in alerts stored before the change.
- `GET /signals` returns the latest signals, up to 7, with `Date` and `Signal` as `BUY` or `SELL`. Use it to correct stored records for those dates.

## Machine-Readable Docs

- [OpenAPI description](https://algotrade.io/openapi.yaml) of the Signals API
- [This guide in Markdown](https://algotrade.io/docs.md)
- [llms.txt](https://algotrade.io/llms.txt), a summary of the site for AI agents, and [llms-full.txt](https://algotrade.io/llms-full.txt) with this guide and the OpenAPI description
