Developer Documentation
PharmKit API
Programmatic access to 54+ PK/PD calculators. Integrate into your R scripts, Python pipelines, Jupyter notebooks, and clinical pharmacology workflows.
Quick Start
1
Upgrade to Team Tier
API access is available on Team ($99/seat/month) and Enterprise plans. View pricing
2
Generate an API Key
Go to /dashboard/api-keys and create a new key. Store it securely.
3
Make Requests
Authenticate with the X-API-Key header.
bash
curl -X POST https://api.pharmkit.dev/api/v1/api/calculate/half-life-calculator \
-H "X-API-Key: phrz_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"method": "two-points",
"concentration1": 10,
"concentration2": 2.5,
"time1": 2,
"time2": 8
}'Response Format
All responses follow a consistent envelope format:
json
{
"success": true,
"data": {
"tool": "half-life-calculator",
"inputs": {
"method": "two-points",
"concentration1": 10,
"concentration2": 2.5,
"time1": 2,
"time2": 8
},
"outputs": {
"halfLife": 3.0,
"eliminationRate": 0.2310
},
"interpretation": null
},
"meta": {
"credits_used": 0
}
}Code Examples
Python
python
import requests
API_KEY = "phrz_your_key_here"
BASE_URL = "https://api.pharmkit.dev/api/v1"
response = requests.post(
f"{BASE_URL}/api/calculate/half-life-calculator",
headers={
"X-API-Key": API_KEY,
"Content-Type": "application/json",
},
json={
"method": "two-points",
"concentration1": 10,
"concentration2": 2.5,
"time1": 2,
"time2": 8,
},
)
data = response.json()
print(f"Half-life: {data['data']['outputs']['halfLife']} hours")
print(f"Ke: {data['data']['outputs']['eliminationRate']} hr⁻¹")R
r
library(httr)
library(jsonlite)
api_key <- "phrz_your_key_here"
base_url <- "https://api.pharmkit.dev/api/v1"
response <- POST(
paste0(base_url, "/api/calculate/half-life-calculator"),
add_headers(
"X-API-Key" = api_key,
"Content-Type" = "application/json"
),
body = toJSON(list(
method = "two-points",
concentration1 = 10,
concentration2 = 2.5,
time1 = 2,
time2 = 8
), auto_unbox = TRUE),
encode = "raw"
)
result <- fromJSON(content(response, "text"))
cat("Half-life:", result$data$outputs$halfLife, "hours\n")API Reference
POST
/api/v1/api/calculate/{tool_slug}Run a calculation programmatically. Accepts the same inputs as the web tool.
Headers:
X-API-Key: phrz_...(required)Content-Type: application/json
Body: Tool-specific input parameters (JSON)
Optional:
include_interpretation: true — triggers AI analysis (1 credit)POST
/api/v1/api-keysCreate a new API key. Returns the raw key once (store securely).
GET
/api/v1/api-keysList your API keys (prefix only, never full key).
DELETE
/api/v1/api-keys/{key_id}Revoke an API key. Permanently disables it.
Rate Limiting
Each API key has a configurable rate limit (default: 60 requests/minute).
Rate limit info is returned in response headers:
X-RateLimit-Limit— Maximum requests per minuteX-RateLimit-Remaining— Remaining requests in windowX-RateLimit-Reset— Unix timestamp when window resets
When rate limited, you receive a 429 Too Many Requests response.
Security Best Practices
- Store API keys in environment variables, never in source code
- Use separate keys for different applications or environments
- Rotate keys periodically — revoke old keys after creating new ones
- Set rate limits appropriate for your use case
- Monitor the "last used" timestamp to detect unauthorized use
- Revoke immediately if you suspect a key has been compromised
Ready to integrate?
Start with a Team subscription and generate your first API key.