# Countrylayer: agents start here

Steps for AI coding agents that add Countrylayer 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/countrylayer/ and subscribe to Countrylayer. 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 Countrylayer 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/countrylayer/v2`
- Auth: `access_key` query parameter
- Formats: JSON
- Endpoints:
  - `/name/{name}` Search by name
  - `/all` All countries

```sh
curl "https://api.apilayer.net/countrylayer/v2/name/Germany?access_key=$APILAYER_ACCESS_KEY"
```

## 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 | SSL Encryption (HTTPS), Access to /all endpoint: limited data |
| Starter | 250 | Access to /name endpoint: limited data, Access to /currency endpoint: limited data, Access to /alpha endpoint: limited data, Standard Support |
| Professional | 5,000 | Access to /language endpoint: limited data, Access to /capital endpoint: limited data |
| Enterprise | 20,000 | Access to /all endpoint: full data, Access to /name endpoint: full data, Access to /currency endpoint: full data, Access to /alpha endpoint: full data, Access to /language endpoint: full data, Access to /capital endpoint: full data, Access to /region endpoint: full data, Access to /regionalbloc endpoint: full data, Access to /callingcode endpoint: full data, Full Data Access |

Prices: https://apilayer.com/products/countrylayer/#pricing

## 5. Use the machine-readable docs

- Countrylayer documentation: https://docs.apilayer.com/apilayer/docs/countrylayer
- APILayer llms.txt: https://apilayer.com/llms.txt
