Get Offer Counts
Get Offer Counts
The Get Offer Counts endpoint allows clients to retrieve the number of available offers based on specified filters. This is useful for analytics, dashboards, or dynamically displaying the number of offers by category, type, or redemption method. The response returns the count of matching offers per filter.
Prerequisites
Before making an API call to get offer counts, ensure that the necessary user-level session token has been obtained. This token is required to authenticate API requests and can be acquired by following the User Client Level Authentication.
Steps to Implement
-
Construct the API Request
- Purpose: Retrieve a count of offers based on filter parameters.
- Endpoint Reference: Get offer counts
- Usage: Make a
GET
request to the following endpoint:GET /api/v1/offers/counts
- Query Parameters (all optional):
categories
: Array of strings representing category namesoffer_types
: Array of strings representing the type of offer (e.g.,in_store
,online
)offer_redemption_types
: Array of strings representing the method of redemption (e.g.,printable
,digital
)
-
Process the Response
- Purpose: To retrieve and display offer count summaries in the application.
- Response Body: A successful (
200 OK
) response will contain a JSON object with the count of offers that match the provided filters. - Error Handling:
400 Bad Request
: Returned if the query parameters are malformed or invalid500 Internal Server Error
: Returned if the backend fails to process the request- Error responses include an
error_code
anderror_message
Key Considerations
- Flexible Filtering: You may provide any combination of
categories
,offer_types
, oroffer_redemption_types
. If none are provided, the endpoint may return a total count of all offers. - Array Format: Query parameters should be passed as repeated query strings (e.g.,
categories=Dining&categories=Shopping
) or as comma-separated strings, depending on client implementation. - Use with Get Offers: This endpoint is typically used in conjunction with Get Offers to provide count summaries alongside actual offer listings.
Best Practices
- Cache Counts Where Applicable: If the filters do not change often, cache the result to avoid unnecessary API calls.
- Validate Filter Values: Ensure your frontend or analytics tools send valid and expected filter names to prevent
400 Bad Request
errors. - Use for UI Elements: Offer counts can be used to dynamically update tab labels, display badges, or provide quick summaries of offer availability.
- Monitor Response Time: Since this is often called during UI initialization, monitor its performance to avoid slow page loads.
Updated about 2 months ago