This document describes how to configure, connect to, and interact with the API. For information on expanding the API with your own custom code see Extending the API. All examples are presented using PHP.
Configuration
Overview
Structure
The structure of an API request involves passing to the API the model, method, and format to be requested, along with any additional parameters the method may require. For example:
No Format |
---|
https://yourdomain.com/installpath/index.php/api/users/get.xml?user_id=1 |
In the above example, yourdomain.com is your domain and installpath is the path to the Blesta installation. If you have enabled pretty URLs in Blesta the path may omit the index.php portion.
Formats
The API supports XML, JSON, and PHP serialization formats. By default XML formatting is used. So if there is an error detecting the format of the request (due to a bad URL, for example) the error response will be returned in XML format.
Errors
Timestamps
The API returns all timestamps in UTC time using the following ISO 8601 format:
No Format |
---|
YYYY-MM-DD hh:mm:ss / 2021-12-31 12:00:00 |
The API expects timestamps in one of the following formats:
No Format |
---|
YYYY-MM-DD hh:mm:ss ±hh:mm / 2021-12-31 12:00:00 +00:00
YYYY-MM-DD hh:mm:ss UTC / 2021-12-31 12:00:00 UTC
YYYY-MM-DDThh:mm:ssZ / 2021-12-31T12:00:00Z |
Note | ||
---|---|---|
| ||
If the timezone can not be determined from the timestamp, the system will assume the timezone is in local time. For this reason you should always specify a timezone in your timestamps. For details on checking or setting the local timezone for the system check your localization settings. |
Authentication
The API supports Basic Authentication.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
// from any other class... Loader::loadModels($this, array("ModelName")); // Now invoke it $this->ModelName->someMethod($param1, $param2); |
Requests
The API supports hundreds of requests.