Wrapped
Get organization's year in review
Retrieves wrapped statistics for a given year. For large datasets (>10,000 donations),
* the calculation will be performed asynchronously when refresh=true.
*
* Polling Strategy:
* 1. Make initial request with refresh=true
* 2. If response is 202, begin polling the status endpoint
* 3. Poll /wrapped/{year}/status every 5-10 seconds
* 4. When status is 'completed', make another request to this endpoint
* 5. Stop polling if status is 'failed' or after 5 minutes
*
* Example polling implementation:
* ```javascript
* async function getWrappedStats(year, refresh = false) {
* const response = await fetch(`/api/v1/admin/wrapped/${year}?refresh=${refresh}`);
*
* if (response.status === 202) {
* return pollCalculation(year);
* }
*
* return response.json();
* }
*
* async function pollCalculation(year) {
* let attempts = 0;
* const maxAttempts = 60; // 5 minutes at 5-second intervals
*
* while (attempts < maxAttempts) {
* const status = await fetch(`/api/v1/admin/wrapped/${year}/status`);
* const data = await status.json();
*
* if (data.status === 'completed') {
* return getWrappedStats(year);
* }
* if (data.status === 'failed') {
* throw new Error(data.error || 'Calculation failed');
* }
* await new Promise(resolve => setTimeout(resolve, 5000));
* attempts++;
* }
* throw new Error('Calculation timed out');
* }
* ```
GET
Get organization's year in review
Authorizations
Gratona API key sent with the compatibility header X-HYS-API-Key.
Path Parameters
Year to get wrapped data for. Must not be a future year. If not specified, defaults to current year. Any past year or current year
Example:
2024
Query Parameters
Force refresh of wrapped statistics. For large datasets (>10,000 donations), triggers async calculation.
Example:
false