Retrieve all audience segments for your application.
Endpoint
GET /audiences
Authentication
Required: Bearer token in Authorization header
Authorization: Bearer YOUR_API_KEY
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
app_id | string | Yes | Your application ID |
limit | integer | No | Maximum number of results (default: 50, max: 100) |
offset | integer | No | Pagination offset (default: 0) |
Response
{
"success": true,
"audiences": [
{
"audience_id": "aud_789",
"name": "Active Premium Users",
"description": "Users with premium plan who were active in the last 7 days",
"user_count": 1250,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-20T14:22:10Z"
},
{
"audience_id": "aud_790",
"name": "Churned Users",
"description": "Users who haven't been active in 30+ days",
"user_count": 450,
"created_at": "2024-01-10T09:15:00Z",
"updated_at": "2024-01-20T14:22:10Z"
}
],
"pagination": {
"total": 25,
"limit": 50,
"offset": 0,
"has_more": false
}
}
Examples
JavaScript
const params = new URLSearchParams({
app_id: 'app_123',
limit: 50,
offset: 0
});
const response = await fetch(`https://api.appizer.com/v1/audiences?${params}`, {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const data = await response.json();
console.log(data);
Python
import requests
params = {
'app_id': 'app_123',
'limit': 50,
'offset': 0
}
response = requests.get(
'https://api.appizer.com/v1/audiences',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
params=params
)
print(response.json())
cURL
curl -X GET "https://api.appizer.com/v1/audiences?app_id=app_123&limit=50&offset=0" \
-H "Authorization: Bearer YOUR_API_KEY"
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Invalid or missing API key |
| 404 | Not Found - App ID not found |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error - Something went wrong on our end |
Pagination
Use limit and offset parameters to paginate through results:
// Get first page
let offset = 0;
const limit = 50;
const response = await fetch(
`https://api.appizer.com/v1/audiences?app_id=app_123&limit=${limit}&offset=${offset}`,
{ headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
);
const data = await response.json();
// Check if there are more results
if (data.pagination.has_more) {
offset += limit;
// Fetch next page...
}
Best Practices
- Use pagination for apps with many audiences
- Cache audience lists when appropriate
- Monitor audience sizes regularly
- Archive or delete unused audiences
- Use descriptive names and descriptions for easy identification