API Documentation

Integrate 2FA.yachts into your applications with our simple API.

TOTP Generation API

Generate time-based one-time passwords (TOTP) for a given secret key.

GET/api/totp

Query Parameters

ParameterTypeRequiredDescription
secretStringYesThe TOTP secret key

Try it yourself

A sample valid Base32 encoded secret is pre-filled.

{
  "otp": "123456",
  "remainingSeconds": 25,
  "expiresAt": "2023-04-01T12:30:25.000Z"
}

Example Usage

fetch('https://2fa.yachts/api/totp?secret=YOUR_SECRET')
  .then(response => response.json())
  .then(data => {
    console.log('OTP:', data.otp);
    console.log('Remaining seconds:', data.remainingSeconds);
    console.log('Expires at:', data.expiresAt);
  });

Error Responses

Status CodeDescription
400Missing or invalid secret
500Server error

2FA Code Page

Access a user-friendly TOTP code generator UI by using a direct URL with your secret.

URL/{secret}/code

URL Parameters

ParameterTypeRequiredDescription
secretStringYesThe TOTP secret key (will be URL encoded)

Features

  • Automatically refreshing TOTP code with visual countdown
  • One-click copy functionality
  • QR code for easy import to mobile authenticator apps
  • Works offline once loaded
  • Client-side only - your secret never leaves your browser

Example Usage

// Redirect users to the 2FA code page for a seamless experience
const secretKey = "JBSWY3DPEHPK3PXP";
const encodedSecret = encodeURIComponent(secretKey);
window.location.href = `https://2fa.yachts/${encodedSecret}/code`;