🔐 2FA API Documentation

Get TOTP verification codes through our simple REST API.

Base URL: https://2faotp.live/api/2fa

Authentication

All API requests require authentication using an API key. Get your API key from the Dashboard.

Header Authentication (Recommended)

curl -H "X-API-Key: your_api_key_here" \
     https://2faotp.live/api/2fa/generate

Query Parameter

curl "https://2faotp.live/api/2fa/generate?api_key=your_api_key_here"

Generate 2FA Code

POST /api/2fa/generate

Get the current valid TOTP code for a given secret key.

Request Parameters

NameTypeDescription
secretrequired string The Base32-encoded secret key (e.g., JBSWY3DPEHPK3PXP)

Example Request

curl -X POST "https://2faotp.live/api/2fa/generate" \
     -H "X-API-Key: your_api_key_here" \
     -H "Content-Type: application/x-www-form-urlencoded" \
     -d "secret=JBSWY3DPEHPK3PXP"
import requests

url = "https://2faotp.live/api/2fa/generate"
headers = {
    "X-API-Key": "your_api_key_here"
}
data = {
    "secret": "JBSWY3DPEHPK3PXP"
}

response = requests.post(url, headers=headers, data=data)
result = response.json()

print(f"2FA Code: {result['data']['code']}")
print(f"Remaining: {result['data']['remaining_time']}s")
package main

import (
    "encoding/json"
    "fmt"
    "net/http"
    "net/url"
    "strings"
)

func main() {
    apiURL := "https://2faotp.live/api/2fa/generate"
    data := url.Values{}
    data.Set("secret", "JBSWY3DPEHPK3PXP")

    req, _ := http.NewRequest("POST", apiURL, strings.NewReader(data.Encode()))
    req.Header.Set("X-API-Key", "your_api_key_here")
    req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    fmt.Println(result)
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class TwoFAExample {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();

        String body = "secret=JBSWY3DPEHPK3PXP";

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://2faotp.live/api/2fa/generate"))
            .header("X-API-Key", "your_api_key_here")
            .header("Content-Type", "application/x-www-form-urlencoded")
            .POST(HttpRequest.BodyPublishers.ofString(body))
            .build();

        HttpResponse<String> response = client.send(
            request, HttpResponse.BodyHandlers.ofString()
        );

        System.out.println(response.body());
    }
}
<?php
$url = "https://2faotp.live/api/2fa/generate";
$apiKey = "your_api_key_here";

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        "X-API-Key: " . $apiKey,
        "Content-Type: application/x-www-form-urlencoded",
    ],
    CURLOPT_POSTFIELDS     => http_build_query([
        "secret" => "JBSWY3DPEHPK3PXP",
    ]),
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
echo "2FA Code: " . $result['data']['code'] . "\n";
echo "Remaining: " . $result['data']['remaining_time'] . "s\n";

Success Response

{
    "code": 200,
    "message": "Code generated successfully",
    "data": {
        "code": "123456",
        "remaining_time": 18,
        "timestamp": 1772035200,
        "valid_until": 1772035218
    }
}

Response Fields

FieldTypeDescription
code string The 6-digit TOTP verification code
remaining_time integer Seconds until this code expires
timestamp integer Current server UNIX timestamp
valid_until integer UNIX timestamp when this code expires

Rate Limits

API rate limits are determined by your subscription plan:

PlanPer MinutePer HourPer Day
Free5100Unlimited
Pro301,00010,000
Ultra1005,000Unlimited
Rate Limit Exceeded (429):
{
    "code": 429,
    "message": "Rate limit exceeded",
    "data": { "retry_after": 45 }
}

Error Codes

CodeDescription
200Success
400Bad Request - Invalid or missing secret
401Unauthorized - Invalid or missing API key
429Too Many Requests - Rate limit exceeded
500Internal Server Error