API DocumentationPython examples for interacting with the Genus Codes API
https://genuscodes.comAll API endpoints require authentication via a Bearer token. Generate a token from your Account page.
Include this header with every request.
import requests
API_TOKEN = "gc_your_token_here"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
# Use headers with every request
response = requests.post(
"https://genuscodes.com/search/function",
json={"function_hash": "..."},
headers=headers
)
Search for binaries containing a specific function by its UUID5 hash.
import requests
API_TOKEN = "gc_your_token_here"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
# Function hash (UUID5 format)
function_hash = "e935d66e-4777-579f-9278-e4c6d955b79b"
response = requests.post(
"https://genuscodes.com/search/function",
json={
"function_hash": function_hash,
"limit": 100 # Optional: max results
},
headers=headers
)
data = response.json()
print(f"Found in {data.get('total_binaries', 0)} binaries")
{
"function_hash": "e935d66e-4777-579f-9278-e4c6d955b79b",
"total_binaries": 52,
"binaries": [
{"sha256": "abc123...", "malicious": true, "source": "VirusShare_00001"},
{"sha256": "def456...", "malicious": false, "source": "Win10"}
],
"from_cache": true
}
Search for a binary by its SHA256 hash and find similar binaries.
import requests
API_TOKEN = "gc_your_token_here"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
sha256 = "b99d61d874728edc0918ca0eb10eab93d381e7367e377406e65963366c874450"
response = requests.post(
"https://genuscodes.com/search/binary",
json={
"hash_value": sha256,
"hash_type": "sha256"
},
headers=headers
)
data = response.json()
# If processing, poll for results
if data.get("status") == "processing":
job_id = data["job_id"]
print(f"Job submitted: {job_id}")
# Poll /job/{job_id} for completion
Submit a PE binary for analysis. Returns a presigned S3 URL for upload.
import requests
API_TOKEN = "gc_your_token_here"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
# Read your PE file
with open("sample.exe", "rb") as f:
file_content = f.read()
# Submit for validation
response = requests.post(
"https://genuscodes.com/submit/binary",
files={"file": ("sample.exe", file_content)},
headers=headers
)
data = response.json()
if data.get("status") == "duplicate":
print(f"Binary already exists: {data['results_url']}")
else:
job_id = data["job_id"]
upload_url = data["upload_url"]
print(f"Validated! Job ID: {job_id}")
# Upload the file using the presigned URL
upload_resp = requests.put(
upload_url,
data=file_content,
headers={"Content-Type": "application/octet-stream"}
)
if upload_resp.status_code == 200:
print("Upload successful")
# Tell the server to process the uploaded file
response = requests.post(
"https://genuscodes.com/submit/confirm-upload",
json={"job_id": job_id},
headers=headers
)
data = response.json()
print(f"Status: {data['status']}")
print(f"Results will be at: {data['results_url']}")
Check the status of an async job.
import requests
import time
API_TOKEN = "gc_your_token_here"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
job_id = "your-job-id-here"
# Poll until complete
while True:
response = requests.get(f"https://genuscodes.com/job/{job_id}", headers=headers)
data = response.json()
status = data.get("status")
print(f"Status: {status}")
if status in ["completed", "failed"]:
break
time.sleep(5) # Wait 5 seconds between polls
print(f"Result: {data}")
View analysis results for a binary (HTML page).
This endpoint returns an HTML page. For programmatic access, use:
Get analysis results as JSON.
import requests
API_TOKEN = "gc_your_token_here"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
sha256 = "b99d61d874728edc0918ca0eb10eab93d381e7367e377406e65963366c874450"
response = requests.get(
f"https://genuscodes.com/api/binary/{sha256}/results",
headers=headers
)
data = response.json()
print(f"Total functions: {data['summary']['total_functions']}")
print(f"Unique functions: {data['summary']['unique_functions']}")
print(f"Malicious matches: {data['summary']['functions_with_malicious_matches']}")
# Binary similarity
similarity = data.get("similarity", {})
for threshold, info in similarity.get("thresholds", {}).items():
print(f"{threshold}: {info['count']} similar binaries")
Check your current plan, usage counts, and remaining quota.
import requests
API_TOKEN = "gc_your_token_here"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
response = requests.get(
"https://genuscodes.com/billing/usage",
headers=headers
)
data = response.json()
print(f"Plan: {data['plan']}")
print(f"Binary ops: {data['binary_ops']} / {data['binary_limit']} ({data['binary_remaining']} remaining)")
print(f"Function ops: {data['function_ops']} / {data['function_limit']} ({data['function_remaining']} remaining)")
{
"plan": "free",
"binary_ops": 12,
"binary_limit": 50,
"binary_remaining": 38,
"function_ops": 1500,
"function_limit": 36000,
"function_remaining": 34500,
"is_lifetime": true,
"status": "active"
}
Track the progress of function fetching for a binary analysis.
import requests
API_TOKEN = "gc_your_token_here"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
sha256 = "b99d61d874728edc0918ca0eb10eab93d381e7367e377406e65963366c874450"
response = requests.get(
f"https://genuscodes.com/api/binary/{sha256}/progress",
headers=headers
)
data = response.json()
print(f"Progress: {data['fetched']} / {data['total']}")
{
"fetched": 150,
"total": 500
}
Re-run analysis for a binary to pick up newly indexed samples. Subject to a cooldown period.
import requests
API_TOKEN = "gc_your_token_here"
headers = {"Authorization": f"Bearer {API_TOKEN}"}
sha256 = "b99d61d874728edc0918ca0eb10eab93d381e7367e377406e65963366c874450"
response = requests.post(
f"https://genuscodes.com/api/binary/{sha256}/refresh-cache",
headers=headers
)
data = response.json()
print(f"Status: {data['status']}")
{
"status": "refreshed",
"message": "Binary analysis has been refreshed"
}
{
"status": "too_recent",
"message": "Binary was analyzed recently. Please wait before refreshing."
}
Check server health and service connectivity. No authentication required.
import requests
response = requests.get("https://genuscodes.com/health")
data = response.json()
print(f"Status: {data['status']}")
{
"status": "healthy",
"rabbitmq": "connected",
"cache_api": "connected",
"active_jobs": 3
}
The API returns standard HTTP status codes:
try:
response = requests.post(...)
response.raise_for_status() # Raise exception for 4xx/5xx
data = response.json()
except requests.exceptions.HTTPError as e:
print(f"HTTP Error: {e.response.status_code}")
print(f"Details: {e.response.text}")