Find the answers you need

Support Database

How do I 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:

<span class="hljs-meta"><!--?php</span--> require_once “vendor/autoload.php”; //We specify the API wrapper location.<br /> $bearer_token = “INSERT YOUR GENERAL API KEY”; //Your 20i API key.</span>
<span class="hljs-meta">$response = json_encode($services_api->getWithFields(”/package”), JSON_PRETTY_PRINT);<br /> print_r($response); </span>

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.