Gene2AI APIv1.0

API Documentation

Gene2AI Genomics Analysis API — Integrate AI-powered genetic analysis into your applications.

Base URL
https://gene2aiapi-mjdnfevz.manus.space

All REST endpoints are accessible at this base URL. Use /api/upload-url and /api/query-result for production.

Authentication

All API calls require HMAC-MD5 authentication via HTTP Headers. Three headers are required:

idVerify ID — "UP02" for upload, "GE01" for query
tokenHMAC-MD5 token (16 hex chars)
timeUTC time string in format "YYYY-MM-DD HH:MM"

Token Generation Algorithm

# Token = md5(verify_id + secret + time)[4:20]
# Time format: "YYYY-MM-DD HH:MM" (UTC)

import hashlib
from datetime import datetime, timezone

verify_id = "UP02"
secret = "your_secret_here"
time_str = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M")

raw = f"{verify_id}{secret}{time_str}"
full_hash = hashlib.md5(raw.encode()).hexdigest()
token = full_hash[4:20]  # 16 hex chars
Tokens are valid for a 5-minute window around the specified time. Ensure your system clock is synchronized.
POST
/api/upload-url

Creates an analysis job and returns an upload URL for the genetic data file.

Request Headers

id: UP02
token: a1b2c3d4e5f6g7h8
time: 2026-03-02 14:30
Content-Type: application/json

Request Body

{
  "key": "gene2ai_user12345_1709389800",
  "type": "txt",           // "txt" | "zip"
  "format": "23andme"      // "23andme" | "ancestry"
}

Response (Success)

{
  "code": 0,
  "msg": "success",
  "data": {
    "key": "gene2ai_user12345_1709389800",
    "url": "https://api.gene2.ai/api/genomics/upload/gene2ai_user12345_..."
  }
}

Error Codes

code: 0Job created successfully
code: 1HMAC token validation failed
code: 2key, type, or format missing
code: 3Unsupported format or type value

cURL Example

curl -X POST 'https://gene2aiapi-mjdnfevz.manus.space/api/upload-url' \
  -H 'Content-Type: application/json' \
  -H 'id: UP02' \
  -H 'token: YOUR_TOKEN' \
  -H 'time: 2026-03-02 14:30' \
  -d '{
    "key": "gene2ai_user12345_1709389800",
    "type": "txt",
    "format": "23andme"
  }'
AI-Ready JSON Result Schema

The analysis result contains five categories of findings, each enriched by our LLM layer for user-friendly descriptions.

health_risks

Fields: condition, risk, confidence, snps, description

Values: low | average | slightly_elevated | elevated | high

drug_response

Fields: drug, sensitivity, gene, recommendation, snps

Values: normal | increased | reduced

traits

Fields: trait, value, confidence, snps

Values: confidence: 0.0–1.0

nutrition

Fields: nutrient, need, confidence, snps

Values: decreased | normal | increased

ancestry

Fields: regions[].region, regions[].percentage

Values: percentage: 0–100

Full Integration Example (Python)
import hashlib, time, requests
from datetime import datetime, timezone

BASE_URL = "https://gene2aiapi-mjdnfevz.manus.space"

def make_token(verify_id, secret):
    t = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M")
    raw = f"{verify_id}{secret}{t}"
    h = hashlib.md5(raw.encode()).hexdigest()
    return h[4:20], t

# Step 1: Request upload URL
token, time_str = make_token("UP02", "your_upload_secret")
resp = requests.post(f"{BASE_URL}/api/upload-url",
    headers={
        "Content-Type": "application/json",
        "id": "UP02",
        "token": token,
        "time": time_str
    },
    json={
        "key": "gene2ai_user001_" + str(int(time.time())),
        "type": "txt",
        "format": "23andme"
    }
)
data = resp.json()
assert data["code"] == 0
job_key = data["data"]["key"]
upload_url = data["data"]["url"]

# Step 2: Upload the file
with open("genome_data.txt", "rb") as f:
    requests.put(upload_url, data=f.read(),
                 headers={"Content-Type": "text/plain"})

# Step 3: Poll for results
while True:
    token, time_str = make_token("GE01", "your_query_secret")
    resp = requests.post(f"{BASE_URL}/api/query-result",
        headers={
            "Content-Type": "application/json",
            "id": "GE01",
            "token": token,
            "time": time_str
        },
        json={"key": job_key}
    )
    result = resp.json()
    status = result["data"]["status"]
    if status in ("succeeded", "failed"):
        print(result["data"]["result"])
        break
    time.sleep(5)