# HTTP API

Remote Admin API is not REST-full at the moment, all requests should submitted via HTTP POST request to admin/api.php file of your HostBill Installation

# Authentication

All Remote Admin API methods requires authentication to use them. API uses combination of API ID & API KEY arguments in requests to authenticate.

In order to get API ID & API KEY you will need to generate it

  1. Login to your HostBill
  2. Go to Settings > System Settings > Security settings > API Access
  3. Enter your allowed IP address/subnet, name for API key and click Add API access

# Access control

API ID/Key combination can be limited to certain IPs, Subnets, or be enabled to all IPs.

When creating new API ID/Key you can enter following allowed IP:

  • all - keyword matching all IPs
  • xxx.xxx.xxx.xxx - Single IP
  • xxx.xxx.xxx.xxx/M - IP with Mask in CIDR format
  • xxx.xxx.xxx.xxx/mmm.mmm.mmm.mmm - IP with Mask in dotted quad format

# Enabled API functions

Each API ID/Key combination is additionally limited only to subset of API functions it have access to. Access can be set in related API ID details page in HostBill admin area.

# Errors

In case of error API return JSON with success key set to false and error hash/array containing list of errors returned

{
    "success": false,
    "call": "accountSuspend",
    "server_time": 1679594592,
    "error": [
        "Wrong parameter"
    ]
}

# Pagination

Many of listing requests (ie list clients) are paginated. In case of paginated response, API adds sorter element to JSON response containing:

Key Description
perpage Amount of records returned per single page of results
totalpages Total count of pages available to return
sorterrecords Total count of records available
sorterpage Number of next page to return

Example:

...
    "call": "getAccounts",
    "sorter": {
        "perpage": 25,
        "totalpages": 39,
        "sorterrecords": 968,
        "sorterpage": 1
    },
...

# Getting next page of results

To change page (get next page of results) add page request attribute to your call with number of page to return, starting from 0

Example:

{{url}}api.php?api_id={{api_id}}&api_key={{api_key}}&call=getAccounts&page=2

# Changing number of results returned per page

To change number of rows returned per call, add perpage request attribute to your call with number of rows to return

Example:

{{url}}api.php?api_id={{api_id}}&api_key={{api_key}}&call=getAccounts&perpage=100

# Translation

To translate the language variables returned by the API, set the language_id parameter in API call

# Example
GET /admin/api.php?api_id=API_ID&api_key=API_KEY&call=getNews&language_id=1

# Logging

All requests to HostBill API are logged to Extras > System Logs > API Log

# Default Currency

Any price returned by Admin API is in your main currency set in Settings > Currencies

Last Updated: 3/31/2023, 2:33:12 PM