The Categories API now supports pagination to handle large datasets efficiently.
page(optional): Page number (default: 1, minimum: 1)per_page(optional): Items per page (default: 50, range: 1-100)
All responses now include pagination metadata:
{
"data": [
"Technology",
"News",
"Entertainment"
],
"pagination": {
"current_page": 1,
"per_page": 50,
"total": 25,
"last_page": 1,
"from": 1,
"to": 25,
"has_more_pages": false,
"has_previous_pages": false
}
}The Categories API now supports including image links for categories that can be used in mobile apps.
include_images(optional): Include image URLs for categories (default: false)X-Include-Imagesheader: Alternative way to include image links
When include_images=true is specified, categories will include image URLs:
{
"data": [
{
"name": "Technology",
"image_url": "https://example.com/tech-image.jpg"
},
{
"name": "News",
"image_url": "https://example.com/news-image.jpg"
},
{
"name": "Entertainment"
}
]
}Categories without configured image links will not include the image_url field.
Image links can be combined with other parameters:
{
"data": [
{
"name": "Technology",
"podcast_count": 15,
"image_url": "https://example.com/tech-image.jpg"
},
{
"name": "News",
"podcast_count": 8,
"image_url": "https://example.com/news-image.jpg"
}
]
}live_only(optional): Filter for categories with live podcasts onlyinclude_counts(optional): Include podcast counts for each categoryinclude_images(optional): Include image URLs for each categorypage(optional): Page number for paginationper_page(optional): Items per page for pagination
X-Live-Only: Alternative tolive_onlyparameterX-Include-Counts: Alternative toinclude_countsparameterX-Include-Images: Alternative toinclude_imagesparameterAccept: Response format (application/json, application/xml, text/csv)
# Get first page with 10 items per page
curl "http://localhost:8000/api/categories?page=1&per_page=10"
# Get second page
curl "http://localhost:8000/api/categories?page=2&per_page=10"
# Combine with other filters
curl "http://localhost:8000/api/categories?live_only=true&include_counts=true&page=1&per_page=5"# Get categories with image links
curl "http://localhost:8000/api/categories?include_images=true"
# Get live categories with image links
curl "http://localhost:8000/api/categories?live_only=true&include_images=true"
# Get categories with counts and image links
curl "http://localhost:8000/api/categories?include_counts=true&include_images=true"
# Using headers
curl -H "X-Include-Images: true" "http://localhost:8000/api/categories"- Previous: 1 hour (60 minutes)
- Current: 15 minutes
This shorter cache duration ensures more responsive updates when new podcasts are added or categories change.
The API uses different cache keys based on the request parameters:
all_categories- Basic categories listall_categories_with_counts- Categories with podcast countsall_categories_with_images- Categories with image linksall_categories_with_counts_with_images- Categories with counts and image linkslive_categories- Live-only categorieslive_categories_with_counts- Live categories with countslive_categories_with_images- Live categories with image linkslive_categories_with_counts_with_images- Live categories with counts and image links
Cache is automatically invalidated after 15 minutes. For immediate updates, you can:
- Wait for cache expiration
- Clear cache manually via admin interface
- Restart the application
# Get live categories with counts and image links, paginated, in XML format
curl -H "X-Live-Only: true" \
-H "X-Include-Counts: true" \
-H "X-Include-Images: true" \
-H "Accept: application/xml" \
"http://localhost:8000/api/categories?page=1&per_page=5"Response:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<data>
<item0>
<name>Technology</name>
<podcast_count>15</podcast_count>
<image_url>https://example.com/tech-image.jpg</image_url>
</item0>
<item1>
<name>News</name>
<podcast_count>8</podcast_count>
<image_url>https://example.com/news-image.jpg</image_url>
</item1>
</data>
<pagination>
<current_page>1</current_page>
<per_page>5</per_page>
<total>25</total>
<last_page>5</last_page>
<from>1</from>
<to>5</to>
<has_more_pages>true</has_more_pages>
<has_previous_pages>false</has_previous_pages>
</pagination>
</response>// Get paginated categories
async function getCategories(page = 1, perPage = 10) {
const response = await fetch(`/api/categories?page=${page}&per_page=${perPage}`);
const data = await response.json();
console.log('Categories:', data.data);
console.log('Pagination:', data.pagination);
return data;
}
// Get live categories with counts and image links, paginated
async function getLiveCategoriesWithCountsAndImages(page = 1, perPage = 10) {
const response = await fetch(`/api/categories?live_only=true&include_counts=true&include_images=true&page=${page}&per_page=${perPage}`);
const data = await response.json();
return data;
}
// Check if there are more pages
function hasMorePages(pagination) {
return pagination.has_more_pages;
}
// Get next page
function getNextPage(currentPage) {
return currentPage + 1;
}
// Extract image URLs from categories
function getCategoryImages(categories) {
return categories
.filter(category => category.image_url)
.map(category => ({
name: category.name,
imageUrl: category.image_url
}));
}- Use appropriate page sizes: 10-50 items per page is usually optimal
- Cache responses: Implement client-side caching for better performance
- Handle pagination gracefully: Always check
has_more_pagesbefore requesting next page - Optimize image loading: Only request image links when needed for UI display
- Fallback gracefully: Handle categories without image links in your UI
Category image links can be managed through the Adminix interface at /adminix/category-links. This allows administrators to:
- Add image URLs for categories
- Edit existing image URLs
- Remove image URLs
- View the JSON data stored in Redis
- Refresh the categories list from the database