Comment on page
Overview
Introduction to Rewardful's REST API
The Rewardful API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
We highly recommend checking out Insomnia, a desktop app that makes testing API requests and responses a breeze 👍
All API requests require authentication with HTTP Basic Auth, similar to how Stripe authenticates. Provide your API Secret as the basic auth
username
value. You do not need to provide a password.curl https://api.getrewardful.com/v1/affiliates/7B016217-18AF-44DD-A30C-0DE0C1534D2A \
-u YOUR_API_SECRET:
Be sure to replace
YOUR_API_SECRET
with your actual API Secret. For example, if your API secret was ABC123
, the curl
command to fetch all affiliates would be:curl --request GET \
--url https://api.getrewardful.com/v1/affiliates \
-u ABC123:
Keep your API Secret safe!
Your API Secret grants full access to your Rewardful account. Do not:
- Share your API Secret with third parties
- Commit your API Secret to version control (i.e. Git)
- Share your API Secret over email or chat
- Send your API Secret to the web browser in HTML or JavaScript
Contact us as soon as possible if you believe your API Secret has been compromised so we can rotate it for you.
Rewardful will provide a JSON-based REST API through which merchants can create affiliate accounts and fetch data for reporting. Endpoints accept form-encoded request bodies and return JSON-encoded responses.
Rewardful uses UUID strings for primary keys (IDs) for all resources. If you plan to store Rewardful IDs in your database, make sure to use a column type (string, UUID, etc) appropriate for your database engine.
Missing or invalid authorization will return a
401 Unauthorized
JSON response:{ "error": "Invalid API Secret." }
Requesting a nonexistent object will return a
404 Not Found
JSON response:{ "error": "Affiliate not found: " }
Passing invalid data to a create/update endpoint will return a
422 Unprocessable
Entity JSON response:{
"error": "Could not create affiliate.",
"details": ["Email can't be blank"]
}
API endpoints that return a list of objects include pagination, unless noted otherwise. The data structure has two root objects:
Key | Description |
pagination | Pagination data, such as current/next/previous page numbers, counts, etc. |
data | An array of objects returned for the specified page number. |
Key | Description |
previous_page | Previous page number. Will be null if there's no previous page. |
current_page | Current page number. |
next_page | Next page number. Will be null if there's no next page. |
count | The number of objects on this page. |
limit | The requested number of objects per page. |
total_pages | The total number of pages. |
total_count | The total number of objects returned across all pages. |
This example demonstrates the
pagination
for a collection of 150 objects in total, split into 3 pages of 50 objects per page:{
"pagination": {
"previous_page": 1,
"current_page": 2,
"next_page": 3,
"count": 50,
"limit": 50,
"total_pages": 3,
"total_count": 150
},
"data": [
// Array of objects
]
}
Many objects allow you to request additional information as an expanded response by using the
expand
request parameter. You can use expand
to expand a single type of object, or expand[]
to expand multiple types of objects.The documentation for each endpoint will list which objects are expandable (if any) for that endpoint.
For example, to expand an
affiliate
you would prepend this query string parameter to the request URL:?expand=affiliate
To expand both
affiliate
and sale
objects, prepend this query string parameter to the request URL:?expand[]=affiliate&expand=sale
The Rewardful REST API uses rate limiting to help maximize its uptime and stability. Users who send many requests in quick succession may see error responses that show up as HTTP status code
429
. These 429
responses will include RateLimit header fields which you can use to gracefully handle failures and retry requests when your quota resets.In most cases the API rate limit is 45 requests per 30 second window. Please treat these limits as absolute maximums and do not generate unnecessary load.
If you plan to run a batch script (such as programmatically creating many affiliates via API), please throttle your API usage by adding sleep/delay mechanisms to your script. We may reduce limits at any time to prevent abuse.
Last modified 1yr ago