# Positionstack: agents start here

Steps for AI coding agents that add Positionstack 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/positionstack and subscribe to Positionstack. 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 Positionstack 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/positionstack/v1`
- Auth: `access_key` query parameter
- Formats: JSON, XML, GeoJSON
- Endpoints:
  - `/forward` Forward geocoding
  - `/reverse` Reverse geocoding

```sh
curl "https://api.apilayer.net/positionstack/v1/forward?access_key=$APILAYER_ACCESS_KEY&query=1600%20Pennsylvania%20Ave%20NW,%20Washington%20DC"
```

## 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 | Forward Geocoding, Reverse Geocoding, HTTPS Encryption, Country Module, Sun Module, Timezone Module, Bounding Box Module, Specify Response Fields |
| Starter | 100,000 | Commercial License, Extended Rate Limits, XML & GeoJSON Output, Embeddable Maps, Multiple Languages Support, Standard Support included |
| Professional | 1,000,000 | Batch Requests |
| Enterprise | 3,000,000 | Same features as Professional |

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

## 5. Use the machine-readable docs

- Positionstack documentation: https://docs.apilayer.com/apilayer/docs/positionstack
- APILayer llms.txt: https://apilayer.com/llms.txt
