# Exchange Rate API: agents start here

Steps for AI coding agents that add Exchange Rate API to a project.

## 1. Get an API key

A person creates the account: an agent cannot sign up. Sign up at https://app.apilayer.com/signup/exchangerate/ and subscribe to Exchange Rate API. The Free plan includes 100 requests / month and needs no credit card.

Copy the API key from the APILayer dashboard and give it to the agent as an environment variable (step 2).

## 2. Keep the key out of code

Read the key from an environment variable named `APILAYER_ACCESS_KEY`. Do not write the key into source code, commit it to git, or paste it into a chat.

Call Exchange Rate API from server code. The key travels in the request URL, so a request sent from a browser shows the key to every visitor.

```
# add .env to .gitignore
APILAYER_ACCESS_KEY=your_api_key
```

## 3. Make the first request

- Base URL: `https://api.apilayer.net/exchangerate`
- Auth: `access_key` query parameter
- Formats: JSON
- Endpoints:
  - `/latest` Latest rates
  - `/symbols` Symbols

```sh
curl "https://api.apilayer.net/exchangerate/latest?access_key=$APILAYER_ACCESS_KEY&base=EUR&symbols=USD,GBP,JPY"
```

## 4. Check the plan before you use a feature

Each plan adds features to the plan before it. Check that the account's plan includes a feature before writing code that uses it.

| Plan | Requests / month | Adds |
|---|---|---|
| Free | 100 | Update frequency: hourly, Historical data, SSL encryption |
| Starter | 10,000 | Base currency switching, Conversion endpoint, Commercial use, Standard support |
| Professional | 100,000 | Update frequency: 10 minutes, Time series endpoint, Bid ask spread data |
| Enterprise | 500,000 | Update frequency: 60 seconds, Fluctuation endpoint |

Prices: https://apilayer.com/products/exchange-rate-api/#pricing

## 5. Use the machine-readable docs

- Exchange Rate API documentation: https://docs.apilayer.com/apilayer/docs/exchange-rate-api
- APILayer llms.txt: https://apilayer.com/llms.txt
