Snake Dex API
JSON endpoints served from snakeindex.com. Every response is sent with Cache-Control: no-store, and the endpoints send no CORS headers, so call them from a server or script. Always send a User-Agent header: Python's default one is rejected with error code: 1010.
GET /api/pgp/challenge?handle=
Ask for a one-time challenge for a handle that has an OpenPGP public key on file. Sign it with the matching private key, then send it to the recovery endpoint.
Hostsnakeindex.com
Sign-innot needed
Limit10 failed lookups per 5 minutes per address and handle
Challenge life300 seconds
Request
curl -s -i "https://snakeindex.com/api/pgp/challenge?handle=your-handle"const res = await fetch("https://snakeindex.com/api/pgp/challenge?handle=your-handle");
console.log(res.status, await res.json());import json
import urllib.request
import urllib.error
req = urllib.request.Request(
"https://snakeindex.com/api/pgp/challenge?handle=your-handle",
headers={"User-Agent": "snake-api-client/1.0"},
)
try:
with urllib.request.urlopen(req) as r:
status, body = r.status, r.read()
except urllib.error.HTTPError as e:
status, body = e.code, e.read()
print(status, json.loads(body))Response
200Key on file
{
"ok": true,
"handle": "your-handle",
"challenge": "…",
"nonce": "…",
"expires_in": 300
}404No key for that handle
{"error":"No OpenPGP public key is on file for that handle."}429Limit reached
{"error":"Too many attempts. Try again in a few minutes."}POST /api/pgp/recover
Send the challenge back, signed with your OpenPGP private key, to receive a password reset token.
Hostsnakeindex.com
Sign-innot needed
Limit5 failed attempts per 5 minutes per address and handle; a success clears the count
BodyJSON: handle, nonce, signature
Request
curl -s -i -X POST https://snakeindex.com/api/pgp/recover \
-H "Content-Type: application/json" \
-d '{"handle":"your-handle","nonce":"CHALLENGE","signature":"SIGNED_CHALLENGE"}'const res = await fetch("https://snakeindex.com/api/pgp/recover", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ handle: "your-handle", nonce: "CHALLENGE", signature: "SIGNED_CHALLENGE" }),
});
console.log(res.status, await res.json());import json
import urllib.request
import urllib.error
req = urllib.request.Request(
"https://snakeindex.com/api/pgp/recover",
data=json.dumps({"handle": "your-handle", "nonce": "CHALLENGE", "signature": "SIGNED_CHALLENGE"}).encode(),
headers={
"Content-Type": "application/json",
"User-Agent": "snake-api-client/1.0",
},
method="POST",
)
try:
with urllib.request.urlopen(req) as r:
status, body = r.status, r.read()
except urllib.error.HTTPError as e:
status, body = e.code, e.read()
print(status, json.loads(body))Response
200Signature accepted
{
"ok": true,
"reset_token": "…",
"token": "…"
}400Signature, nonce or handle not accepted
{"error":"That signed challenge could not be verified."}429Limit reached
{"error":"Too many attempts. Try again in a few minutes."}POST /api/pgp/pubkey
Publish the public half of your OpenPGP key to your account. Private keys are refused.
Hostsnakeindex.com
Sign-insigned-in session, or a signup token with the handle
Token headerX-Signup-Token
BodyJSON: public_key, optional fingerprint and handle
Request
curl -s -i -X POST https://snakeindex.com/api/pgp/pubkey \
-H "Content-Type: application/json" \
-H "X-Signup-Token: SIGNUP_TOKEN" \
-d '{"handle":"your-handle","public_key":"-----BEGIN PGP PUBLIC KEY BLOCK-----..."}'const res = await fetch("https://snakeindex.com/api/pgp/pubkey", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Signup-Token": "SIGNUP_TOKEN",
},
body: JSON.stringify({ handle: "your-handle", public_key: "-----BEGIN PGP PUBLIC KEY BLOCK-----..." }),
});
console.log(res.status, await res.json());import json
import urllib.request
import urllib.error
req = urllib.request.Request(
"https://snakeindex.com/api/pgp/pubkey",
data=json.dumps({"handle": "your-handle", "public_key": "-----BEGIN PGP PUBLIC KEY BLOCK-----..."}).encode(),
headers={
"Content-Type": "application/json",
"User-Agent": "snake-api-client/1.0",
"X-Signup-Token": "SIGNUP_TOKEN",
},
method="POST",
)
try:
with urllib.request.urlopen(req) as r:
status, body = r.status, r.read()
except urllib.error.HTTPError as e:
status, body = e.code, e.read()
print(status, json.loads(body))Response
200Key stored
{
"ok": true,
"handle": "your-handle",
"fingerprint": "…"
}401Token or sign-in missing
{"error":"A valid signup token is required."}400Key refused
{"error":"A private key was submitted. Send only the public key."}POST /api/save-search
Save a search to the signed-in account.
Hostsnakeindex.com
Sign-inrequired: the snake_dex_session cookie of a signed-in browser
BodyJSON: q, category
Request
curl -s -i -X POST https://snakeindex.com/api/save-search \
-H "Content-Type: application/json" \
-b "snake_dex_session=SESSION_COOKIE" \
-d '{"q":"snakeindex.com","category":""}'const res = await fetch("https://snakeindex.com/api/save-search", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Cookie": "snake_dex_session=SESSION_COOKIE",
},
body: JSON.stringify({ q: "snakeindex.com", category: "" }),
});
console.log(res.status, await res.json());import json
import urllib.request
import urllib.error
req = urllib.request.Request(
"https://snakeindex.com/api/save-search",
data=json.dumps({"q": "snakeindex.com", "category": ""}).encode(),
headers={
"Content-Type": "application/json",
"User-Agent": "snake-api-client/1.0",
"Cookie": "snake_dex_session=SESSION_COOKIE",
},
method="POST",
)
try:
with urllib.request.urlopen(req) as r:
status, body = r.status, r.read()
except urllib.error.HTTPError as e:
status, body = e.code, e.read()
print(status, json.loads(body))Response
200Search saved
{"id": 12, "ok": true}401No valid session
{"error":"Sign in to save a search."}400Search refused
{"error":"…"}GET /api/item/{id}/reveal
Return the stored value of a secret Snake Dex item, with the contexts it was seen in.
Hostsnakeindex.com
Sign-inrequired: the snake_dex_session cookie of a signed-in browser
Pathid is the item number
Request
curl -s -i -b "snake_dex_session=SESSION_COOKIE" https://snakeindex.com/api/item/1/revealconst res = await fetch("https://snakeindex.com/api/item/1/reveal", {
headers: { Cookie: "snake_dex_session=SESSION_COOKIE" },
});
console.log(res.status, await res.json());import json
import urllib.request
import urllib.error
req = urllib.request.Request(
"https://snakeindex.com/api/item/1/reveal",
headers={
"Cookie": "snake_dex_session=SESSION_COOKIE",
"User-Agent": "snake-api-client/1.0",
},
)
try:
with urllib.request.urlopen(req) as r:
status, body = r.status, r.read()
except urllib.error.HTTPError as e:
status, body = e.code, e.read()
print(status, json.loads(body))Response
200Signed in
{
"value": "…",
"contexts": ["…"]
}401No valid session
{"error":"Sign in to reveal this value."}