# Rate Limits

The API applies rate limits to each external application. The limits keep the API stable for all users. Each limit uses a fixed 60-second window.

## Limits

| Endpoint | Limit | Window |
|----------|-------|--------|
| `GET /api/v1/courses` | 100 requests | 60s |
| `POST /api/v1/courses` | 20 requests | 60s |
| `GET /api/v1/courses/:id` | 200 requests | 60s |

Each endpoint has its own limit. List, create, and read requests are counted separately.

## Response Headers

Every API response shows your rate limit status:

```
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 42
X-RateLimit-Reset: 1679529600
```

- **`X-RateLimit-Limit`** — the maximum requests allowed in the current window.
- **`X-RateLimit-Remaining`** — requests remaining in the current window.
- **`X-RateLimit-Reset`** — Unix timestamp (seconds) of the next window reset.

## Rate Limit Exceeded

When you exceed a limit, the API responds with `429 Too Many Requests`. The `Retry-After` header shows the seconds until you can retry:

**Response**: `429 Too Many Requests`

```
Retry-After: 30
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1679529600
```

```json
{
  "error": "rate_limit_exceeded",
  "message": "Too many requests. Please retry later."
}
```

## Best Practices

- ✅ Read the `X-RateLimit-Remaining` header to control your request rate.
- ✅ Wait for the time in the `Retry-After` header. Do not retry immediately.
- ✅ Use exponential backoff for retries.
- ✅ Cache responses when you can.
- ✅ Use webhooks instead of polling for updates.
- ✅ Combine requests when you can.

## Next Steps

- [**API Endpoints**](https://parkdly.com/docs/parkdly-api/endpoints) - API endpoints
- [**Error Handling**](https://parkdly.com/docs/parkdly-api/errors) - Errors
