Get Offer Counts For Offer Type

Get Offer Counts for Offer Types

The Get Offer Counts for Offer Types endpoint allows clients to retrieve the number of available offers for each specified offer type. This is useful for displaying offer type filters with counts or tracking distribution across different offer types, such as online, in_store, or cash_back.

Prerequisites

Before making an API call to get offer counts for offer types, 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

  1. Construct the API Request

    • Purpose: Retrieve a count of offers for each requested offer type.
    • Endpoint Reference: Get offer counts for offer types
    • Usage: Make a GET request to the following endpoint:
      • GET /api/v1/offers/counts/offer-types
    • Query Parameters:
      • offer_types (array of strings, required): A list of offer types to retrieve counts for. Example:
        • offer_types=online&offer_types=in_store&offer_types=cash_back
  2. Process the Response

    • Purpose: To display a breakdown of how many offers are available for each offer type.
    • Response Body: A successful (200 OK) response will return a JSON object mapping each provided offer type to its corresponding count.
    • Error Handling:
      • 400 Bad Request: Returned if the offer_types parameter is missing or malformed
      • 500 Internal Server Error: Indicates a server-side issue while processing the request
      • Error responses will include an error_code and a user-friendly error_message

Key Considerations

  1. Offer Types Are Required: This endpoint requires at least one valid offer type to be passed. Omitting this will result in a 400 error.
  2. Match Against Accepted Values: Ensure the values passed to offer_types match accepted backend values (e.g., in_store, online, cash_back) to avoid zero counts or errors.
  3. Zero Counts Are Valid: If a given offer type has no matching offers, the count will still be included with a value of 0.

Best Practices

  • Predefine Valid Types: Use a controlled set of offer types on the client side to ensure consistent requests and avoid validation issues.
  • UI Integration: Display offer type counts alongside type filters or in analytics dashboards to give users visibility into availability.
  • Batch Requesting: Request all needed types in one call to minimize network latency and improve performance.
  • Gracefully Handle Errors: Handle 400 and 500 errors with fallback UI and logging to capture issues during runtime.