fetchEntities API Reference
ThefetchEntities
function is the primary method for loading and filtering entity lists. It accepts filters, configuration, and options to control how entities are fetched and displayed.
Syntax
Parameters
Filters (Required)
User-controlled parameters that determine which entities to fetch:sortBy (Required)
"hot"
- Replyke’s hotness algorithm (default)"new"
- Newest first"top"
- Highest voted"controversial"
- Mixed voting scores
timeFrame (Optional)
"hour"
- Last hour"day"
- Last 24 hours"week"
- Last 7 days"month"
- Last 30 days"year"
- Last 12 monthsnull
- No time restriction (default)
Configuration (Optional)
System-level parameters that control fetch behavior:- sourceId: Logical separation of entities by context (default:
null
) - limit: Entities per page (default:
10
)
Options (Optional)
Controls how the fetch operation behaves:- immediate: Skip debouncing, execute immediately (default:
false
) - clearImmediately: Clear current entities before fetching (default:
false
) - resetUnspecified: Reset unspecified filters to defaults (default:
false
)
Examples
Basic Usage
Common Patterns
User Profile Feed
Search Results
Trending Content
Location-Based Feed
Advanced Filtering
Multiple Content Filters
Metadata Filtering
Debouncing Behavior
By default,fetchEntities
debounces rapid calls with an 800ms delay to prevent excessive API requests:
State Management
After callingfetchEntities
, the entity list state updates automatically:
Error Handling
The function handles errors internally and updates the entity list state:Performance Tips
- Use debouncing - Let the default 800ms debouncing handle rapid filter changes
- Specify immediate - Use
immediate: true
only when necessary (search, user actions) - Clear wisely - Use
clearImmediately: true
for search results, avoid for filter updates - Reasonable limits - Balance between UX and API costs with appropriate
limit
values - Reset sparingly - Use
resetUnspecified: true
only when you want to clear all other filters