Introduction
Learn how to integrate our APIs into your application.
API Basics
Before you begin!
You should create a Bunce account that you can test the API against. We will provide you with secret key that you can use to interact with our APIs.
The Bunce API lets you interact with data and resources through REST. The API accepts requests in JSON format, returns responses in JSON, and uses standard HTTP response codes, authentication, methods and verbs.
Requests and Response
When making requests, specify application/json
as your Content-Type. For example:
curl -X POST https://sandbox.api.bunce.so/v1/customers
-H "X-Authorization: sk_test_re4e69088ww423f8f1e2d"
-H "Content-Type: application/json"
-d "{ "first_name": "John", "last_name": "Doe", "email": "johndoe@example.com" }"
Both request body data and response data are formatted as JSON. Content type for responses will always be application/json
. Generally, all responses will be in the following format:
Keys
{
"success": "boolean",
"message": "string",
"data": "object"
}
- success
boolean
: This lets you know if your request was successful or not. We recommend that you use this in combination with HTTP status codes to determine the result of an API call. - message
string
: This is a summary of the response and its status. For instance when trying to retrieve a list of customers, message might read “Customers fetched successfully”. In the event of an error, the message key will contain a description of the error. This is the only key that is universal across requests. - data
object
: This contain the results of your request. It can either be an object, or an array depending on the request made. For instance, a request to retrieve get a customer will return a customer object in the data key, while the key would be an array of customers if a list is requested instead.
Meta Object
"meta": {
"has_next_page": "boolean",
"has_prev_page": "boolean",
"next_page_cursor": "string|null",
"prev_page_cursor": "string|null",
"per_page": "number"
},
The meta key is used to provide context for the contents of the data key. For example, list customers. These list API methods share a common structure and accept, at a minimum, the following five parameters: has_next_page
, has_prev_page
, next_page_cursor
,prev_page_cursor
, and per_page
. The meta key will then contain an object with the following attributes:
Keys
has_next_page: boolean
: This will be true if the request response has a next page.has_prev_page: boolean
: This will be true if the request response has a previous pagenext_page_cursor: string|null
: This will be a string value ifhas_next_page
is true and null ifhas_next_page
is false. This value is used in the request as value for cursor in order to fetch the next page. Example
https://api.bunce.so/v1/customers?cursor=eyJjb21wYW55X2N1c3RvbWVycy5pZCI6ImM5NmI4&per_page=10per_page: number
: This is the maximum number of records that will be returned per request. This can be modified by passing a new value as a `per_page` query parameter.Default: 20