RESTful API for TOTP generation and validation
2FA.PW API allows you to generate and validate TOTP codes programmatically. All endpoints return JSON responses.
Base URL: https://2fa.pw/api
Rate Limit: 100 requests per minute
Currently, no authentication is required. Rate limiting is based on IP address.
/api?endpoint=generate
Generate a TOTP code from a secret key
| Parameter | Type | Required | Description |
|---|---|---|---|
| secret | string | ✅ | Base32 encoded secret key |
| timeStep | integer | ❌ | Time step in seconds (default: 30) |
| digits | integer | ❌ | Number of digits (default: 6) |
/api?endpoint=validate
Validate a TOTP code against a secret key
| Parameter | Type | Required | Description |
|---|---|---|---|
| secret | string | ✅ | Base32 encoded secret key |
| code | string | ✅ | TOTP code to validate |
| window | integer | ❌ | Time window tolerance (default: 1) |
/api?endpoint=batch
Generate TOTP codes for multiple secret keys at once
When an error occurs, the API returns a JSON response with error details:
| Code | Description |
|---|---|
| 400 | Bad Request - Invalid parameters |
| 404 | Not Found - Invalid endpoint |
| 429 | Too Many Requests - Rate limit exceeded |