# TOTP Generator API

> TOTP Generator creates time-based one-time passwords compatible with authenticator apps using standard TOTP algorithms.

**Endpoint:** `POST https://api.apiverve.com/v1/totpgenerator`  
**Category:** Data Generation  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/totpgenerator

## Overview

A TOTP generator API: send a Base32 secret and get the current TOTP token, the same 6-digit code Google Authenticator and other authenticator apps show. You can set 6 to 8 digits, a period of 1 to 300 seconds, SHA1, SHA256 or SHA512, and a fixed time. The same TOTP API also verifies a code a user typed, with a window for clock drift, and creates a new secret and the otpauth:// URI an authenticator app scans. Paid plans add the expiry time and the seconds left on each token.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/totpgenerator" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"secret":"JBSWY3DPEHPK3PXP","digits":6,"period":30,"algorithm":"value","time":1}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `secret` | string | Yes | Base32-encoded shared secret |
| `digits` | integer | No | Number of digits in token. default 6. range 6-8 |
| `period` | integer | No | Time period in seconds. default 30. range 1-300 |
| `algorithm` | string | No | HMAC algorithm: SHA1 (default, what most authenticator apps use), SHA256 or SHA512. default SHA1. One of: SHA1, SHA256, SHA512 |
| `time` | integer | No | Unix time in seconds to use instead of now. range 0-inf |

## Response fields

- `token` — string · Generated time-based one-time password token
- `digits` — number · Number of digits in the generated token
- `period` — number · Time period configured for token generation
- `timeRemaining` — number · Seconds remaining until token expires · (premium)
- `expiresAt` — string · ISO 8601 timestamp when token expires · (premium)
- `algorithm` — string · HMAC algorithm used

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "token": "260025",
    "digits": 6,
    "period": 30,
    "timeRemaining": 25,
    "expiresAt": "2026-01-01T00:00:30.000Z",
    "algorithm": "SHA1"
  }
}
```

## Use cases

- **2FA Implementation** — Implement two-factor authentication systems with TOTP token generation
- **Authentication Testing** — Test TOTP-based authentication flows in development and QA environments
- **Security Integration** — Integrate time-based one-time passwords into security workflows
- **MFA Systems** — Build multi-factor authentication systems with standardized TOTP tokens

## SDKs

- **npm** — `npm install @apiverve/totpgenerator` (https://www.npmjs.com/package/@apiverve/totpgenerator)
- **NuGet** — `dotnet add package APIVerve.API.TOTPGenerator` (https://www.nuget.org/packages/APIVerve.API.TOTPGenerator)
- **Source** — https://github.com/apiverve/totpgenerator-api

## More

- Full reference: https://docs.apiverve.com/ref/totpgenerator
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
