bunny.net
Learn how to use the bunny.net API. Everything that can be done with the control panel can also be achieved using our API, documented on this page.
Authentication
Header name: AccessKey
To authenticate requests, include your account API key in the request headers using the following format:
Header name: AccessKey
The API key is required for performing account-specific actions, such as managing zones or other resources. You can have only one API key associated with your account, which can be viewed anytime in the dashboard.
You can learn how to locate your API key here.
Example configuration:
curl --request GET \
--url https://api.bunny.net/dnszone \
--header 'AccessKey: 4ef48caf-3b9a-492a-6ffe-9961ead7522d2ac3f9b5-1d1c-5511-80ca-29788315287b'
Ensure your API key is stored securely and never shared publicly to prevent unauthorized access to your account.
Data format
The API uses JSON as the default format for both requests and responses, ensuring consistency and simplicity in data handling:
- For GET requests, the API expects parameters to be passed via query strings.
- For other HTTP methods (e.g., POST, PUT), the request body should be formatted as JSON.
There is no need to explicitly specify content encoding in the headers, as the API assumes JSON by default for all applicable requests and responses.
Pagination
The API supports pagination to manage large datasets efficiently. Use the page and perPage query parameters to control the data returned in your requests.
Parameters:
- page (int32): The page number to retrieve.
- perPage (int32): The number of items to include per page.
Example request:
GET https://api.bunny.net/dnszone?page=1&perPage=10
Example response:
{
"Items": [],
"CurrentPage": 1,
"TotalItems": 2,
"HasMoreItems": false
}
Bear in mind the following:
- The
CurrentPage
field in the response indicates the current page being viewed. - The
TotalItems
field shows the total number of items available. - The
HasMoreItems
field indicates whether there are additional pages to fetch.
Use this structure to efficiently navigate through large datasets while ensuring optimal performance.
Errors
This section outlines the standard HTTP error codes returned by the API. These errors provide insight into why a request may have failed and how to address the issue. Each error code corresponds to a specific type of problem encountered during the processing of the request.
Error body example:
{
"ErrorKey": "pullZone.not_found",
"Field": "PullZone",
"Message": "The requested Pull Zone was not found"
}
Possible status codes:
- 400 - The request did not pass validation. This may include issues with the request model, body, or parameters.
- 401 - Authorization for the request has failed.
- 403 - The action is forbidden for the user. This may include restrictions on the URL or the HTTP method being used.
- 404 - The requested entity could not be found.
- 429 - Too many requests; the rate limit has been exceeded.
- 500 - An internal server error occurred.
Third Party API Clients
We currently do not maintain an official API library, but you can use one of the third-party options provided here:
bunny.net PHP library, thanks to ToshY
These third-party clients are not maintained or developed by bunny.net. We cannot offer support for them or confirm the security of these libraries.