How do I retrieve a list of packages via the API?

Andrew Porter
Published: 18 February 2020
Share:

What is the 20i Reseller Hosting API?

The 20i Reseller API gives you access to all the features and functionality of StackCP, allowing you to create a hosting control panel from scratch or integrate external services such as WHMCS.

This is for advanced hosting resellers and the support we provide for the Reseller API is service-based only.

How to retrieve a list of packages via the API?

GET  /package

An array of objects will be returned, the objects pertaining to current hosting packages held within the 20i account.

PHP examples use our API wrapper, which can be downloaded here: https://my.20i.com/reseller/api

PHP

Request:

require_once "vendor/autoload.php"; //We specify the API wrapper location.
$bearer_token = "INSERT YOUR GENERAL API KEY"; //Your 20i API key.

$response = json_encode($services_api->getWithFields("/package"), JSON_PRETTY_PRINT);
print_r($response);

Result:


[
    {
        "id": 797701,
        "created": "2020-01-15T16:30:30+00:00",
        "enabled": true,
        "name": "20i-wp.com",
        "names": [
            "20i-wp.com"
        ],
        "packageTypeName": "Linux Unlimited",
        "productSpec": null,
        "stackUsers": [
            "stack-user:989901"
        ],
        "typeRef": 811,
        "packageLabels": []
    },
    {
        "id": 527649,
        "created": "2019-03-14T18:43:17+00:00",
        "enabled": true,
        "name": "20iclone.com",
        "names": [
            "20iclone.com"
        ],
        "packageTypeName": "Unlimited Hosting",
        "productSpec": null,
        "stackUsers": [
            "stack-user:612771"
        ],
        "typeRef": 814,
        "packageLabels": []
    },
    {
        "id": 32025,
        "created": "2017-04-10T09:41:44+00:00",
        "enabled": true,
        "name": "20isupport.com",
        "names": [
            "20isupport.com",
            "tools.20isupport.com"
        ],
        "packageTypeName": "Linux Unlimited",
        "productSpec": null,
        "stackUsers": [
            "stack-user:33487"
        ],
        "typeRef": 811,
        "packageLabels": []
    }

The response, shows a list of hosting packages and various other details about each package instance. For example, in the response, we can see the name and id of packages, the name of the package type the package is assigned-to, as well as any StackUsers assigned to those packages.