Free 2FA code API
Get the current code for a secret key as JSON. Free, no sign-up, CORS enabled.
GET https://api.code2fa.co/tok/JBSWY3DPEHPK3PXP
→ {"token":"123456"}
GET https://api.code2fa.co/totp/JBSWY3DPEHPK3PXP?digits=6&period=30&algorithm=SHA1
→ {"token":"123456","next":"654321","remaining":17,"period":30,"digits":6}
POST https://api.code2fa.co/bulk (body: one key or ID|Pass|KEY per line, max 500)
→ {"remaining":17,"results":[{"token":"123456"},{"error":"invalid secret key"}]}
GET https://api.code2fa.co/time
→ {"now":1795255000000,"timezone":"Asia/Ho_Chi_Minh","country":"VN"}
curl https://api.code2fa.co/tok/JBSWY3DPEHPK3PXP
# Python
import requests
print(requests.get("https://api.code2fa.co/tok/JBSWY3DPEHPK3PXP").json()["token"])Notes
/tok/returns the same JSON shape as 2fa.live, so existing tools only need the new host name.- Options for
/totp/and/bulk:digits(6–8),period(5–300),algorithm(SHA1, SHA256, SHA512),type=steam. - Privacy: unlike the web tool, the API has to receive your key. It is used in memory to compute the code and is not stored or logged by us. For valuable accounts, use the web tool instead.
- Please keep usage reasonable. Abusive traffic may be limited.