Copy these scripts and change them. The curl versions need bash, curl 7.76 or later, and jq. The Python versions use only the standard library.
We run every script on this page, in both languages, against a test server built from our API routes and contracts each time these docs are built. That checks the routes, parameters and response fields each script uses. It doesn’t call the live API, and the test data is made up, so your output will differ.
Set these first. Get the values from Get started. Each script gets its own token and asks only for the scopes it needs, so the client must hold those scopes.
SURESHAKE_API_KEY Your company or personal API key (sk_...), used by lookup-company
SURESHAKE_CLIENT_ID Your firm client's ID (cli_...)
SURESHAKE_CLIENT_SECRET Its secret (sec_...)
SURESHAKE_ENTITY_ID Your firm's ID
SURESHAKE_COMPANY_ID The ID of the company you're asking aboutA script uses https://api.sureshake.com unless you set SURESHAKE_API_URL. A failed call stops it with a non-zero exit. A token lasts an hour, and the token route allows 30 requests per minute, so a long-running system should keep its token rather than fetch one per run.
Get a token and list metrics
Gets a firm token with metrics:read, then lists one company’s metrics. Set SURESHAKE_COMPANY_ID to the company. Without a published report from a connected accounting system or a manual write, a private company has none, so try a company with SEC filings first.
#!/usr/bin/env bash
# Get a firm token, then list one company's metrics.
set -euo pipefail
API="${SURESHAKE_API_URL:-https://api.sureshake.com}"
TOKEN=$(curl -sS --fail-with-body "$API/v2/oauth/token" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_id=$SURESHAKE_CLIENT_ID" \
--data-urlencode "client_secret=$SURESHAKE_CLIENT_SECRET" \
--data-urlencode "scope=metrics:read" | jq -er .access_token)
curl -sS --fail-with-body --get "$API/v2/metrics" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "entityId=$SURESHAKE_COMPANY_ID" \
--data-urlencode "limit=100" |
jq -r '.data[] | [.fiscalPeriod, .periodEnd, .statement, .concept, .value, .currency, .provenance.source] | @tsv'#!/usr/bin/env python3
"""Get a firm token, then list one company's metrics."""
import json
import os
import urllib.parse
import urllib.request
API = os.environ.get("SURESHAKE_API_URL", "https://api.sureshake.com")
def call(path, data=None, token=None):
headers = {"User-Agent": "sureshake-cookbook"}
if token:
headers["Authorization"] = f"Bearer {token}"
request = urllib.request.Request(API + path, data=data, headers=headers)
with urllib.request.urlopen(request) as response:
return json.load(response)
def firm_token(scope):
body = urllib.parse.urlencode(
{
"grant_type": "client_credentials",
"client_id": os.environ["SURESHAKE_CLIENT_ID"],
"client_secret": os.environ["SURESHAKE_CLIENT_SECRET"],
"scope": scope,
}
)
return call("/v2/oauth/token", data=body.encode())["access_token"]
token = firm_token("metrics:read")
query = urllib.parse.urlencode(
{"entityId": os.environ["SURESHAKE_COMPANY_ID"], "limit": 100}
)
for row in call(f"/v2/metrics?{query}", token=token)["data"]:
print(
row["fiscalPeriod"],
row["periodEnd"],
row["statement"],
row["concept"],
row["value"],
row["currency"],
row["provenance"]["source"],
sep="\t",
)Sync only what changed
Asks for rows changed since the last run with updatedSince, and follows meta.nextCursor until meta.hasMore is false. It keeps the newest updatedAt in a file, so run it from the same directory each time, or set SURESHAKE_SYNC_STATE. The page size of 2 is there to show paging, so raise it, up to 500.
#!/usr/bin/env bash
# Fetch only what changed since the last run, following the cursor to the end.
# The next run starts from the newest updatedAt seen, kept in a state file.
set -euo pipefail
API="${SURESHAKE_API_URL:-https://api.sureshake.com}"
STATE="${SURESHAKE_SYNC_STATE:-metrics.updated-since}"
TOKEN=$(curl -sS --fail-with-body "$API/v2/oauth/token" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_id=$SURESHAKE_CLIENT_ID" \
--data-urlencode "client_secret=$SURESHAKE_CLIENT_SECRET" \
--data-urlencode "scope=metrics:read" | jq -er .access_token)
SINCE=$(cat "$STATE" 2>/dev/null || true)
NEWEST="$SINCE"
CURSOR=""
while :; do
PAGE=$(curl -sS --fail-with-body --get "$API/v2/metrics" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "entityId=$SURESHAKE_COMPANY_ID" \
--data-urlencode "limit=2" \
${SINCE:+--data-urlencode "updatedSince=$SINCE"} \
${CURSOR:+--data-urlencode "cursor=$CURSOR"})
# Replace this line with an upsert keyed on entityId, statement, concept,
# fiscalPeriod and periodEnd. updatedSince is inclusive, so rows can repeat.
jq -r '.data[] | [.concept, .value, .updatedAt] | @tsv' <<<"$PAGE"
NEWEST=$(jq -r --arg newest "$NEWEST" '[.data[].updatedAt, $newest] | max' <<<"$PAGE")
[ "$(jq -r .meta.hasMore <<<"$PAGE")" = "true" ] || break
CURSOR=$(jq -er .meta.nextCursor <<<"$PAGE")
done
printf '%s' "$NEWEST" >"$STATE"#!/usr/bin/env python3
"""Fetch only what changed since the last run, following the cursor to the end.
The next run starts from the newest updatedAt seen, kept in a state file.
"""
import json
import os
import pathlib
import urllib.parse
import urllib.request
API = os.environ.get("SURESHAKE_API_URL", "https://api.sureshake.com")
STATE = pathlib.Path(os.environ.get("SURESHAKE_SYNC_STATE", "metrics.updated-since"))
def call(path, data=None, token=None):
headers = {"User-Agent": "sureshake-cookbook"}
if token:
headers["Authorization"] = f"Bearer {token}"
request = urllib.request.Request(API + path, data=data, headers=headers)
with urllib.request.urlopen(request) as response:
return json.load(response)
def firm_token(scope):
body = urllib.parse.urlencode(
{
"grant_type": "client_credentials",
"client_id": os.environ["SURESHAKE_CLIENT_ID"],
"client_secret": os.environ["SURESHAKE_CLIENT_SECRET"],
"scope": scope,
}
)
return call("/v2/oauth/token", data=body.encode())["access_token"]
token = firm_token("metrics:read")
since = STATE.read_text() if STATE.exists() else ""
newest = since
cursor = None
while True:
params = {"entityId": os.environ["SURESHAKE_COMPANY_ID"], "limit": 2}
if since:
params["updatedSince"] = since
if cursor:
params["cursor"] = cursor
page = call(f"/v2/metrics?{urllib.parse.urlencode(params)}", token=token)
for row in page["data"]:
# Replace this line with an upsert keyed on entityId, statement, concept,
# fiscalPeriod and periodEnd. updatedSince is inclusive, so rows can repeat.
print(row["concept"], row["value"], row["updatedAt"], sep="\t")
newest = max(newest, row["updatedAt"])
if not page["meta"]["hasMore"]:
break
cursor = page["meta"]["nextCursor"]
STATE.write_text(newest)Write a manual metric
Writes a self-reported period for your firm with on_conflict=skip. The first run prints created, and later runs print skipped. This creates real data. Change the values and the period before you run it. Needs metrics:write.
#!/usr/bin/env bash
# Write a self-reported period for your own firm. on_conflict=skip leaves an
# existing manual period alone; the default, overwrite, replaces it.
set -euo pipefail
API="${SURESHAKE_API_URL:-https://api.sureshake.com}"
TOKEN=$(curl -sS --fail-with-body "$API/v2/oauth/token" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_id=$SURESHAKE_CLIENT_ID" \
--data-urlencode "client_secret=$SURESHAKE_CLIENT_SECRET" \
--data-urlencode "scope=metrics:write" | jq -er .access_token)
BODY=$(jq -n --arg entityId "$SURESHAKE_ENTITY_ID" '{
entityId: $entityId,
fiscalYear: 2026,
fiscalPeriod: "Q3",
periodStart: "2026-07-01",
periodEnd: "2026-09-30",
currency: "USD",
values: [
{ statement: "income_statement", concept: "revenue", value: "1250000.00" },
{ statement: "income_statement", concept: "netIncome", value: "85000.00" }
]
}')
curl -sS --fail-with-body "$API/v2/metrics?on_conflict=skip" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "$BODY" |
jq -r '.data | [.outcome, .source, .fiscalPeriod, .periodEnd] | @tsv'#!/usr/bin/env python3
"""Write a self-reported period for your own firm.
on_conflict=skip leaves an existing manual period alone; the default, overwrite,
replaces it.
"""
import json
import os
import urllib.parse
import urllib.request
API = os.environ.get("SURESHAKE_API_URL", "https://api.sureshake.com")
def call(path, data=None, token=None, content_type=None):
headers = {"User-Agent": "sureshake-cookbook"}
if token:
headers["Authorization"] = f"Bearer {token}"
if content_type:
headers["Content-Type"] = content_type
request = urllib.request.Request(API + path, data=data, headers=headers)
with urllib.request.urlopen(request) as response:
return json.load(response)
def firm_token(scope):
body = urllib.parse.urlencode(
{
"grant_type": "client_credentials",
"client_id": os.environ["SURESHAKE_CLIENT_ID"],
"client_secret": os.environ["SURESHAKE_CLIENT_SECRET"],
"scope": scope,
}
)
return call("/v2/oauth/token", data=body.encode())["access_token"]
token = firm_token("metrics:write")
period = {
"entityId": os.environ["SURESHAKE_ENTITY_ID"],
"fiscalYear": 2026,
"fiscalPeriod": "Q3",
"periodStart": "2026-07-01",
"periodEnd": "2026-09-30",
"currency": "USD",
"values": [
{"statement": "income_statement", "concept": "revenue", "value": "1250000.00"},
{"statement": "income_statement", "concept": "netIncome", "value": "85000.00"},
],
}
result = call(
"/v2/metrics?on_conflict=skip",
data=json.dumps(period).encode(),
token=token,
content_type="application/json",
)["data"]
print(
result["outcome"],
result["source"],
result["fiscalPeriod"],
result["periodEnd"],
sep="\t",
)List holdings
Lists your firm’s portfolio companies, and whether this token can read each one’s private metrics. Needs portfolio:read.
#!/usr/bin/env bash
# List your firm's portfolio companies, and whether this token can read each
# company's private metrics.
set -euo pipefail
API="${SURESHAKE_API_URL:-https://api.sureshake.com}"
TOKEN=$(curl -sS --fail-with-body "$API/v2/oauth/token" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_id=$SURESHAKE_CLIENT_ID" \
--data-urlencode "client_secret=$SURESHAKE_CLIENT_SECRET" \
--data-urlencode "scope=portfolio:read" | jq -er .access_token)
curl -sS --fail-with-body "$API/v2/entities/$SURESHAKE_ENTITY_ID/holdings" \
-H "Authorization: Bearer $TOKEN" |
jq -r '.data[] | [.name, .companyEntityId, .access, .linkState] | @tsv'#!/usr/bin/env python3
"""List your firm's portfolio companies.
Also shows whether this token can read each company's private metrics.
"""
import json
import os
import urllib.parse
import urllib.request
API = os.environ.get("SURESHAKE_API_URL", "https://api.sureshake.com")
def call(path, data=None, token=None):
headers = {"User-Agent": "sureshake-cookbook"}
if token:
headers["Authorization"] = f"Bearer {token}"
request = urllib.request.Request(API + path, data=data, headers=headers)
with urllib.request.urlopen(request) as response:
return json.load(response)
def firm_token(scope):
body = urllib.parse.urlencode(
{
"grant_type": "client_credentials",
"client_id": os.environ["SURESHAKE_CLIENT_ID"],
"client_secret": os.environ["SURESHAKE_CLIENT_SECRET"],
"scope": scope,
}
)
return call("/v2/oauth/token", data=body.encode())["access_token"]
token = firm_token("portfolio:read")
firm = os.environ["SURESHAKE_ENTITY_ID"]
for holding in call(f"/v2/entities/{firm}/holdings", token=token)["data"]:
print(
holding["name"],
holding["companyEntityId"],
holding["access"],
holding["linkState"],
sep="\t",
)Create and read an information request
Asks a company for information on behalf of your firm, then reads the request back. This notifies the company’s administrators, so change the message and use a real company. Needs requests:read and requests:write.
#!/usr/bin/env bash
# Ask a company for information on behalf of your firm, then read the request back.
set -euo pipefail
API="${SURESHAKE_API_URL:-https://api.sureshake.com}"
TOKEN=$(curl -sS --fail-with-body "$API/v2/oauth/token" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_id=$SURESHAKE_CLIENT_ID" \
--data-urlencode "client_secret=$SURESHAKE_CLIENT_SECRET" \
--data-urlencode "scope=requests:read requests:write" | jq -er .access_token)
BODY=$(jq -n \
--arg firm "$SURESHAKE_ENTITY_ID" \
--arg company "$SURESHAKE_COMPANY_ID" '{
requesterEntityId: $firm,
companyEntityId: $company,
message: "Please share your Q3 results.",
requestedMetrics: ["revenue", "netIncome"],
requestedDocuments: ["Q3 board report"],
dueAt: "2026-12-31T00:00:00Z"
}')
ID=$(curl -sS --fail-with-body "$API/v2/information-requests" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "$BODY" | jq -er .data.id)
curl -sS --fail-with-body "$API/v2/information-requests/$ID" \
-H "Authorization: Bearer $TOKEN" |
jq -r '.data | [.status, .companyEntityName, .message] | @tsv'#!/usr/bin/env python3
"""Ask a company for information on behalf of your firm, then read the request back."""
import json
import os
import urllib.parse
import urllib.request
API = os.environ.get("SURESHAKE_API_URL", "https://api.sureshake.com")
def call(path, data=None, token=None, content_type=None):
headers = {"User-Agent": "sureshake-cookbook"}
if token:
headers["Authorization"] = f"Bearer {token}"
if content_type:
headers["Content-Type"] = content_type
request = urllib.request.Request(API + path, data=data, headers=headers)
with urllib.request.urlopen(request) as response:
return json.load(response)
def firm_token(scope):
body = urllib.parse.urlencode(
{
"grant_type": "client_credentials",
"client_id": os.environ["SURESHAKE_CLIENT_ID"],
"client_secret": os.environ["SURESHAKE_CLIENT_SECRET"],
"scope": scope,
}
)
return call("/v2/oauth/token", data=body.encode())["access_token"]
token = firm_token("requests:read requests:write")
body = {
"requesterEntityId": os.environ["SURESHAKE_ENTITY_ID"],
"companyEntityId": os.environ["SURESHAKE_COMPANY_ID"],
"message": "Please share your Q3 results.",
"requestedMetrics": ["revenue", "netIncome"],
"requestedDocuments": ["Q3 board report"],
"dueAt": "2026-12-31T00:00:00Z",
}
created = call(
"/v2/information-requests",
data=json.dumps(body).encode(),
token=token,
content_type="application/json",
)["data"]
request = call(f"/v2/information-requests/{created['id']}", token=token)["data"]
print(request["status"], request["companyEntityName"], request["message"], sep="\t")Read a report fulfilled to your firm
Finds your firm’s fulfilled requests, then reads each report through GET /v2/reports. It prints nothing until a company has fulfilled a request. Needs requests:read and reports:read.
#!/usr/bin/env bash
# Read the reports companies have fulfilled to your firm. A firm token reads them
# through GET /v2/reports: GET /v2/reports/{id} does not accept firm tokens.
set -euo pipefail
API="${SURESHAKE_API_URL:-https://api.sureshake.com}"
TOKEN=$(curl -sS --fail-with-body "$API/v2/oauth/token" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_id=$SURESHAKE_CLIENT_ID" \
--data-urlencode "client_secret=$SURESHAKE_CLIENT_SECRET" \
--data-urlencode "scope=requests:read reports:read" | jq -er .access_token)
FULFILLED=$(curl -sS --fail-with-body --get "$API/v2/information-requests" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "role=requester" \
--data-urlencode "status=fulfilled" \
--data-urlencode "limit=100")
jq -r '.data[] | [.companyEntityId, .fulfilledReportId] | @tsv' <<<"$FULFILLED" |
while IFS=$'\t' read -r COMPANY REPORT; do
curl -sS --fail-with-body --get "$API/v2/reports" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "entityId=$COMPANY" \
--data-urlencode "limit=100" |
jq -r --arg report "$REPORT" \
'.data[] | select(.id == $report) | [.id, .title, .status] | @tsv'
done#!/usr/bin/env python3
"""Read the reports companies have fulfilled to your firm.
A firm token reads them through GET /v2/reports: GET /v2/reports/{id} does not
accept firm tokens.
"""
import json
import os
import urllib.parse
import urllib.request
API = os.environ.get("SURESHAKE_API_URL", "https://api.sureshake.com")
def call(path, data=None, token=None):
headers = {"User-Agent": "sureshake-cookbook"}
if token:
headers["Authorization"] = f"Bearer {token}"
request = urllib.request.Request(API + path, data=data, headers=headers)
with urllib.request.urlopen(request) as response:
return json.load(response)
def firm_token(scope):
body = urllib.parse.urlencode(
{
"grant_type": "client_credentials",
"client_id": os.environ["SURESHAKE_CLIENT_ID"],
"client_secret": os.environ["SURESHAKE_CLIENT_SECRET"],
"scope": scope,
}
)
return call("/v2/oauth/token", data=body.encode())["access_token"]
token = firm_token("requests:read reports:read")
query = urllib.parse.urlencode({"role": "requester", "status": "fulfilled", "limit": 100})
for fulfilled in call(f"/v2/information-requests?{query}", token=token)["data"]:
query = urllib.parse.urlencode({"entityId": fulfilled["companyEntityId"], "limit": 100})
for report in call(f"/v2/reports?{query}", token=token)["data"]:
if report["id"] == fulfilled["fulfilledReportId"]:
print(report["id"], report["title"], report["status"], sep="\t")Look up a company and verify a billing email
Calls POST /v2/companies/lookup using SURESHAKE_API_KEY (prefer a Company API Key for your company’s membership quotas), checks whether SURESHAKE_KNOWN_EMAIL matches the company’s current contact record, and prints the verified billing email and remaining monthly database lookups.
#!/usr/bin/env bash
# Look up a company by domain and check whether a known billing email matches
# its verified Sureshake profile.
set -euo pipefail
API="${SURESHAKE_API_URL:-https://api.sureshake.com}"
DOMAIN="${SURESHAKE_LOOKUP_DOMAIN:-acme.example}"
KNOWN_EMAIL="${SURESHAKE_KNOWN_EMAIL:-old-billing@acme.example}"
BODY=$(jq -n --arg domain "$DOMAIN" --arg knownEmail "$KNOWN_EMAIL" '{
domain: $domain,
knownEmail: $knownEmail
}')
curl -sS --fail-with-body "$API/v2/companies/lookup" \
-H "X-API-Key: $SURESHAKE_API_KEY" \
-H "Content-Type: application/json" \
-d "$BODY" |
jq -r '.data | [
.company.name,
.source,
(.isSourceOfTruth | tostring),
(.billing.email // ""),
(.knownEmailCheck.status // ""),
(.quota.db.remaining | tostring)
] | @tsv'#!/usr/bin/env python3
"""Look up a company by domain and check a known billing email."""
import json
import os
import urllib.request
API = os.environ.get("SURESHAKE_API_URL", "https://api.sureshake.com")
DOMAIN = os.environ.get("SURESHAKE_LOOKUP_DOMAIN", "acme.example")
KNOWN_EMAIL = os.environ.get("SURESHAKE_KNOWN_EMAIL", "old-billing@acme.example")
def lookup(domain, known_email):
headers = {
"User-Agent": "sureshake-cookbook",
"X-API-Key": os.environ["SURESHAKE_API_KEY"],
"Content-Type": "application/json",
}
body = json.dumps({"domain": domain, "knownEmail": known_email}).encode()
request = urllib.request.Request(f"{API}/v2/companies/lookup", data=body, headers=headers)
with urllib.request.urlopen(request) as response:
return json.load(response)["data"]
result = lookup(DOMAIN, KNOWN_EMAIL)
print(
result["company"]["name"],
result["source"],
str(result["isSourceOfTruth"]).lower(),
(result.get("billing") or {}).get("email") or "",
(result.get("knownEmailCheck") or {}).get("status") or "",
result["quota"]["db"]["remaining"],
sep="\t",
)