Quickstart Guide¶
Get up and running with the Sherpai Partner API in under 5 minutes. This guide will walk you through making your first API call.
What You'll Learn¶
- How to authenticate with the API
- How to make your first API request
- How to handle responses and errors
Step 1: Get Your Access Token¶
First, you'll need to authenticate and get an access token. Replace the api_client_key and api_secret_key with your credentials:
curl -X POST https://partner-api.sherp.ai/auth/login \
-H "Content-Type: application/json" \
-d '{
"api_client_key": "your-client-key",
"api_secret_key": "your-secret-key"
}'
Expected Response:
{
"access_token": "eyJhbGciOiJSUzI1NiIs...",
"token_type": "bearer",
"expires_in": 3600,
"user_id": "firebase_user_uid"
}
Save the access_token - you'll need it for the next step.
Step 2: Make Your First API Call¶
Now let's get your user profile using the access token:
Expected Response:
{
"name": "Your Name",
"brands": [
{
"brand_id": 101,
"brand_name": "Example Brand"
}
],
"next_cursor": null
}
🎉 Congratulations! You've successfully made your first API call.
Step 3: Explore More Endpoints¶
Try these popular endpoints to see what data is available:
Get Brand Analytics¶
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
"https://partner-api.sherp.ai/analytics/?brand_id=1&limit=5"
Get Advanced Analytics¶
# Get daily analytics breakdown
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
"https://partner-api.sherp.ai/analytics/?type=daily&brand_id=101&since=2025-01-15&until=2025-01-22"
# Get aggregated analytics using account_id
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
"https://partner-api.sherp.ai/analytics/?type=agg&account_id=4&since=2025-01-15&until=2025-01-22&platform=fb"
# Get all accessible posts
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
https://partner-api.sherp.ai/posts/
-->
### Check API Health
```bash
curl https://partner-api.sherp.ai/health
Common Patterns¶
Error Handling¶
Always check the response status code and handle errors appropriately:
# Check if the request was successful
response=$(curl -s -w "%{http_code}" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
https://partner-api.sherp.ai/me)
http_code="${response: -3}"
if [[ $http_code -eq 200 ]]; then
echo "Success!"
else
echo "Error: HTTP $http_code"
fi
Pagination¶
Different endpoints use different pagination methods:
Cursor-Based Pagination (Posts Endpoint)¶
The endpoints uses cursor-based pagination :
# Get first page of posts
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
"https://partner-api.sherp.ai/posts/?limit=20"
# Response includes: "next_cursor": "eyJpZCI6MTIzLCJjcmVhdGVkX3RpbWUiOiIyMDI0LTAxLTE1VDEwOjMwOjAwWiJ9"
# Get next page using the cursor
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
"https://partner-api.sherp.ai/posts/?limit=20&cursor=eyJpZCI6MTIzLCJjcmVhdGVkX3RpbWUiOiIyMDI0LTAxLTE1VDEwOjMwOjAwWiJ9"
Cursor-Based Pagination Parameters:
- limit: Maximum number of items to return (default: 10, max: 50 for /posts/)
- cursor: Cursor token from the previous response's next_cursor field to get the next page
Programming Language Examples¶
Partner API Authentication
The examples below use API client credentials (api_client_key and api_secret_key), which is the correct method for partner integrations.
If you see examples using email and password, those are for internal dashboard login only and should not be used for partner API integrations.
JavaScript (Node.js)¶
async function quickstart() {
// Step 1: Get access token using API client credentials
const loginResponse = await fetch('https://partner-api.sherp.ai/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
api_client_key: 'your-client-key',
api_secret_key: 'your-secret-key'
})
});
if (!loginResponse.ok) {
const error = await loginResponse.json();
throw new Error(`Authentication failed: ${error.detail}`);
}
const { access_token } = await loginResponse.json();
// Step 2: Get user profile
const userResponse = await fetch('https://partner-api.sherp.ai/me', {
headers: { 'Authorization': `Bearer ${access_token}` }
});
const user = await userResponse.json();
console.log('User:', user);
// Step 3: Monitor rate limits
const remaining = userResponse.headers.get('X-RateLimit-Remaining');
const limit = userResponse.headers.get('X-RateLimit-Limit');
console.log(`Rate limit: ${remaining}/${limit} requests remaining`);
}
quickstart();
Python¶
import requests
# Step 1: Get access token using API client credentials
login_response = requests.post(
'https://partner-api.sherp.ai/auth/login',
json={
'api_client_key': 'your-client-key',
'api_secret_key': 'your-secret-key'
}
)
login_response.raise_for_status()
access_token = login_response.json()['access_token']
# Step 2: Get user profile
headers = {'Authorization': f'Bearer {access_token}'}
user_response = requests.get('https://partner-api.sherp.ai/me', headers=headers)
user = user_response.json()
print(f"User: {user}")
# Step 3: Monitor rate limits
remaining = user_response.headers.get('X-RateLimit-Remaining')
limit = user_response.headers.get('X-RateLimit-Limit')
print(f"Rate limit: {remaining}/{limit} requests remaining")
Troubleshooting¶
Common Issues¶
401 Unauthorized - Check that your credentials are correct. - Verify the access token is included in the Authorization header - Ensure the token hasn't expired (tokens last 1 hour)
422 Validation Error - Check that required parameters are included - Verify parameter types match the API specification - Review the error message for specific field issues
500 Internal Server Error - This indicates a server-side issue - Contact support if the issue persists
Getting Help¶
- Error Handling Guide - Detailed error handling
- FAQ - Common questions and solutions
- API Reference - Complete endpoint documentation
- Support - Contact our team
Next Steps¶
Now that you've made your first API call, explore these resources:
- API Reference - Complete documentation of all endpoints
- Rate Limiting - Understand usage limits