Your First API Call
August 28, 2025 ยท View on GitHub
Ready to experience the power of BondMCP's health AI? This guide will walk you through making your first API call and understanding the response format.
๐ Quick Start
Let's start with a simple health question using curl:
curl -X POST https://api.bondmcp.com/ask \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "What are the health benefits of drinking green tea?"
}'
Replace YOUR_API_KEY with your actual API key from app.bondmcp.com/settings/api-keys.
๐ Understanding the Response
Here's what you'll get back:
{
"success": true,
"data": {
"answer": "Green tea offers numerous health benefits due to its rich antioxidant content, particularly catechins like EGCG. Regular consumption may help reduce the risk of heart disease, support brain health, aid in weight management, and provide anti-inflammatory effects. Studies suggest 2-3 cups daily can be beneficial for most adults.",
"confidence": 0.92,
"sources": [
{
"title": "Green tea consumption and mortality due to cardiovascular disease",
"url": "https://pubmed.ncbi.nlm.nih.gov/...",
"type": "peer_reviewed",
"relevance": 0.89
}
],
"related_topics": [
"antioxidants",
"cardiovascular health",
"weight management",
"brain health"
],
"follow_up_questions": [
"How much green tea should I drink daily?",
"Are there any side effects of green tea?",
"What's the best time to drink green tea?"
]
},
"metadata": {
"request_id": "req_abc123def456",
"timestamp": "2025-01-28T10:30:00Z",
"processing_time_ms": 245,
"api_version": "2.1.0",
"model_version": "health-ai-v3.2"
}
}
๐ฏ Response Fields Explained
Core Response Data
answer: The main AI-generated response to your questionconfidence: How confident the AI is in the answer (0.0 to 1.0)sources: Scientific sources supporting the answerrelated_topics: Related health topics you might be interested infollow_up_questions: Suggested follow-up questions
Metadata
request_id: Unique identifier for this request (useful for support)timestamp: When the request was processedprocessing_time_ms: How long it took to generate the responseapi_version: API version usedmodel_version: AI model version used
๐ง Adding Context for Better Results
Provide context to get more personalized answers:
curl -X POST https://api.bondmcp.com/ask \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "Should I take vitamin D supplements?",
"context": {
"age": 35,
"gender": "female",
"location": "Seattle, WA",
"health_goals": ["bone health", "immune support"],
"current_medications": ["birth control"],
"dietary_restrictions": ["vegetarian"]
}
}'
Available Context Fields
age: Your age (helps with age-specific recommendations)gender: Your gender (for gender-specific health advice)location: Your location (for regional health considerations)health_goals: What you're trying to achievecurrent_medications: Medications you're takingdietary_restrictions: Any dietary limitationsactivity_level: How active you arehealth_conditions: Any existing health conditions
๐งช Lab Result Analysis
Analyze lab results with the /labs/interpret endpoint:
curl -X POST https://api.bondmcp.com/labs/interpret \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"lab_results": [
{
"test_name": "Total Cholesterol",
"value": 220,
"unit": "mg/dL",
"reference_range": "< 200 mg/dL"
},
{
"test_name": "HDL Cholesterol",
"value": 45,
"unit": "mg/dL",
"reference_range": "> 40 mg/dL (men), > 50 mg/dL (women)"
}
],
"patient_context": {
"age": 42,
"gender": "male",
"health_history": ["family history of heart disease"]
}
}'
๐ฅ Nutrition Analysis
Analyze foods and meals:
curl -X POST https://api.bondmcp.com/nutrition/analyze \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"food_items": [
"1 cup cooked quinoa",
"4 oz grilled salmon",
"1 cup steamed broccoli",
"1 tbsp olive oil"
],
"analysis_type": "meal",
"dietary_goals": ["high protein", "anti-inflammatory"]
}'
๐ Supplement Recommendations
Get personalized supplement advice:
curl -X POST https://api.bondmcp.com/supplements/recommend \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"health_goals": ["immune support", "energy", "stress management"],
"current_supplements": ["multivitamin"],
"dietary_restrictions": ["vegan"],
"budget": "moderate",
"context": {
"age": 28,
"gender": "female",
"activity_level": "moderate",
"stress_level": "high"
}
}'
๐ฉบ Symptom Checking
Analyze symptoms (not a replacement for medical advice):
curl -X POST https://api.bondmcp.com/symptoms/check \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"symptoms": [
{
"symptom": "headache",
"severity": "moderate",
"duration": "3 days",
"frequency": "daily"
},
{
"symptom": "fatigue",
"severity": "mild",
"duration": "1 week",
"frequency": "constant"
}
],
"context": {
"age": 30,
"gender": "female",
"recent_changes": ["started new job", "less sleep"]
}
}'
๐ Error Handling
Handle errors gracefully:
{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "The question field is required",
"details": {
"missing_fields": ["question"],
"provided_fields": ["context"]
}
},
"metadata": {
"request_id": "req_error_123",
"timestamp": "2025-01-28T10:30:00Z"
}
}
Common Error Codes
INVALID_REQUEST: Missing or invalid parametersUNAUTHORIZED: Invalid or missing API keyRATE_LIMIT_EXCEEDED: Too many requestsINSUFFICIENT_CREDITS: Not enough API creditsINTERNAL_ERROR: Server error (contact support)
๐ SDK Examples
Python
import requests
def ask_health_question(question, api_key):
url = "https://api.bondmcp.com/ask"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
data = {"question": question}
response = requests.post(url, headers=headers, json=data)
return response.json()
# Usage
result = ask_health_question(
"What foods are good for brain health?",
"your_api_key_here"
)
print(result["data"]["answer"])
JavaScript/Node.js
const axios = require('axios');
async function askHealthQuestion(question, apiKey) {
try {
const response = await axios.post('https://api.bondmcp.com/ask', {
question: question
}, {
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
});
return response.data;
} catch (error) {
console.error('Error:', error.response.data);
throw error;
}
}
// Usage
askHealthQuestion("What are the benefits of meditation?", "your_api_key_here")
.then(result => console.log(result.data.answer))
.catch(error => console.error(error));
CLI Tool
# Install the CLI
pip install bondmcp-cli
# Authenticate
bondmcp auth login
# Ask questions
bondmcp ask "What supplements should I take for joint health?"
# Analyze labs
bondmcp labs analyze --file my_lab_results.json
# Get nutrition info
bondmcp nutrition analyze "1 cup oatmeal with blueberries"
๐ฏ Best Practices
Request Optimization
- Be Specific: More specific questions get better answers
- Provide Context: Age, gender, and health goals improve responses
- Use Follow-ups: Build on previous questions for deeper insights
- Batch Related Questions: Group related queries when possible
Error Handling
- Check Response Status: Always check the
successfield - Implement Retry Logic: Use exponential backoff for rate limits
- Log Request IDs: Save request IDs for debugging
- Handle Timeouts: Set appropriate timeout values
Security
- Secure API Keys: Never expose keys in client-side code
- Use HTTPS: Always use secure connections
- Rotate Keys: Regularly rotate API keys
- Monitor Usage: Track API usage for unusual patterns
๐ What's Next?
Now that you've made your first API call, explore these advanced features:
- Complete API Reference - All available endpoints
- SDK Documentation - Language-specific libraries
- Health AI Examples - Real-world use cases
- Integration Guides - Building health applications
Congratulations! ๐ You've successfully made your first API call to BondMCP. Start building amazing health applications with our powerful AI platform!