Getting Started
The RxSnap API lets you integrate AI-powered medicine identification and drug interaction checking into your healthcare application. All endpoints return JSON.
Base URL
https://your-deployment-url.com
Request Format
The /api/analyze endpoint accepts multipart/form-data (for image upload). The /api/interactions endpoint accepts application/json. All requests must include your API key in the x-api-key header.
Authentication
Every request to a protected endpoint must include your API key in the x-api-key HTTP header.
x-api-key: pp_live_your_api_key_here
Key Format
All RxSnap API keys follow the format pp_live_ followed by 24 hexadecimal characters — e.g. pp_live_a3f9c2d1e8b047...
POST /api/analyze
Identify a medicine from an image. Returns structured medicine information including generic alternatives, food interactions, and FDA safety data.
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| medicine | File (image/*) | Required | Photo of the medicine packaging or pill. JPEG, PNG, or WebP. |
| conditions | JSON string | Optional | JSON array of patient conditions to check. Values: "high_bp", "low_bp", "diabetes", "thyroid", "kidney" |
Example Response
{
"name": "Metformin HCl",
"manufacturer": "Sun Pharmaceutical Industries",
"dosage": "500mg",
"usage": "Treatment of type 2 diabetes mellitus",
"confidence": "high",
"warnings": "Risk of lactic acidosis. Contraindicated in patients with renal impairment...",
"adverse_reactions": "Diarrhea, nausea, vomiting, flatulence, indigestion, abdominal discomfort...",
"contraindications": "Contraindicated in patients with renal impairment (eGFR below 30)...",
"drug_interactions": "Carbonic anhydrase inhibitors may increase the risk of lactic acidosis...",
"generic_alternatives": [
"Glycomet 500mg — ₹30–₹50 for 20 tablets",
"Bigomet 500mg — ₹25–₹45 for 20 tablets",
"Walaphage 500mg — ₹20–₹40 for 20 tablets"
],
"food_interactions": [
"Alcohol — increases risk of lactic acidosis when combined with metformin",
"High-carb meals — may reduce the effectiveness of blood sugar control"
],
"condition_flags": [
{
"condition": "diabetes",
"label": "Diabetes",
"flagged": false,
"reason": "No relevant keywords found"
},
{
"condition": "kidney",
"label": "Kidney",
"flagged": true,
"reason": "Found keyword: renal"
}
],
"disclaimer": "This is general medicine information only and not medical advice. Consult a doctor or pharmacist before making any health decisions."
}
POST /api/interactions
Check for clinically significant drug interactions between two medicines. Returns severity, effects, and a patient recommendation.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| medicine1 | string | Required | Name of the first medicine (brand or generic) |
| medicine2 | string | Required | Name of the second medicine (brand or generic) |
{
"medicine1": "Aspirin",
"medicine2": "Warfarin"
}
Example Response
{
"severity": "severe",
"summary": "Aspirin significantly increases the anticoagulant effect of Warfarin, raising the risk of serious bleeding.",
"effects": [
"Increased risk of gastrointestinal bleeding",
"Prolonged bleeding time and elevated INR levels",
"Risk of intracranial hemorrhage in elderly patients",
"Platelet inhibition compounding anticoagulation"
],
"recommendation": "Avoid combining Aspirin with Warfarin unless explicitly directed by your physician; if both are necessary, monitor INR closely and watch for signs of bleeding."
}
Severity Levels
| Value | Meaning |
|---|---|
| none | No clinically significant interaction found |
| mild | Minor interaction; generally safe with monitoring |
| moderate | Significant interaction; dosage adjustment may be needed |
| severe | Dangerous combination; avoid or use under strict supervision |
Rate Limits & Plans
Usage is counted per API key, per calendar month. Limits reset on the 1st of each month. When your limit is exceeded, the API returns a 429 response.
All plans billed monthly. Cancel anytime.
View Full Pricing →Error Codes
The API uses standard HTTP status codes. All errors return a JSON body with an error field.
| Status | Code / Meaning | Resolution |
|---|---|---|
| 400 | Bad Request — missing required field | Check that all required parameters are included in your request |
| 401 | API key required | Add the x-api-key header to your request |
| 403 | Invalid or inactive API key | Verify your key is correct; contact support if recently issued |
| 429 | Monthly limit exceeded | Upgrade your plan or wait for the monthly reset. Response includes limit and used fields |
| 500 | Internal server error | Retry after a short delay; contact support if the issue persists |
Error Response Format
{
"error": "Monthly limit exceeded",
"limit": 500,
"used": 500
}
Code Examples
Analyze a Medicine — JavaScript (fetch)
const analyzeMedicine = async (imageFile, conditions = []) => { const formData = new FormData(); formData.append('medicine', imageFile); formData.append('conditions', JSON.stringify(conditions)); const response = await fetch('https://your-deployment-url.com/api/analyze', { method: 'POST', headers: { 'x-api-key': 'pp_live_your_api_key_here', }, body: formData, }); if (!response.ok) { const err = await response.json(); throw new Error(err.error); } return response.json(); }; // Usage const result = await analyzeMedicine(file, ['diabetes', 'kidney']); console.log(result.name, result.warnings);
Check Drug Interactions — JavaScript (fetch)
const checkInteractions = async (medicine1, medicine2) => { const response = await fetch('https://your-deployment-url.com/api/interactions', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': 'pp_live_your_api_key_here', }, body: JSON.stringify({ medicine1, medicine2 }), }); return response.json(); }; const result = await checkInteractions('Aspirin', 'Warfarin'); console.log(result.severity, result.summary);
Analyze a Medicine — Python (requests)
import requests import json def analyze_medicine(image_path, conditions=None): url = "https://your-deployment-url.com/api/analyze" headers = {"x-api-key": "pp_live_your_api_key_here"} with open(image_path, "rb") as img: files = {"medicine": img} data = {"conditions": json.dumps(conditions or [])} response = requests.post(url, headers=headers, files=files, data=data) response.raise_for_status() return response.json() # Usage result = analyze_medicine("medicine.jpg", conditions=["high_bp", "diabetes"]) print(result["name"], result["dosage"])
Check Drug Interactions — Python (requests)
import requests def check_interactions(medicine1, medicine2): url = "https://your-deployment-url.com/api/interactions" headers = { "Content-Type": "application/json", "x-api-key": "pp_live_your_api_key_here", } payload = {"medicine1": medicine1, "medicine2": medicine2} response = requests.post(url, headers=headers, json=payload) response.raise_for_status() return response.json() # Usage result = check_interactions("Aspirin", "Ibuprofen") print(result["severity"], result["recommendation"])