Hostinger provides official SDKs to simplify interaction with our API, making it easier and faster for developers to integrate Hostinger services into their applications. Currently, we offer SDKs in the following languages:
Getting Started
PHP SDK
To install the bindings via Composer, add the following to composer.json
:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/hostinger/api-php-sdk.git"
}
],
"require": {
"hostinger/api-php-sdk": "*"
}
}
Then run composer install
.
Example usage:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure Bearer authorization: apiToken
$config = Hostinger\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new Hostinger\Api\BillingCatalogApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
client: new GuzzleHttp\Client(),
config: $config
);
try {
$result = $apiInstance->getCatalogItemListV1();
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling BillingCatalogApi->getCatalogItemListV1: ', $e->getMessage(), PHP_EOL;
}
Python SDK
Install via pip:
pip install hostinger_api
Example usage:
import hostinger_api
from hostinger_api.rest import ApiException
from pprint import pprint
# Configure Bearer authorization: apiToken
configuration = hostinger_api.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with hostinger_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = hostinger_api.BillingCatalogApi(api_client)
try:
# Get catalog item list
api_response = api_instance.get_catalog_item_list_v1()
print("The response of BillingCatalogApi->get_catalog_item_list_v1:\n")
pprint(api_response)
except ApiException as e:
print("Exception when calling BillingCatalogApi->get_catalog_item_list_v1: %s\n" % e)
TypeScript SDK
Install via npm:
npm install hostinger-api-sdk@0.0.4 --save
Example usage:
import { Client } from 'hostinger-api-sdk';
const client = new Client('your-api-token');
client.get('/v1/user').then(response => {
console.log(response);
});
Authentication
All SDKs require an API token to authenticate your requests. You can obtain your API token from your Hostinger dashboard under the API in Account settings.
Explore our SDKs' functionalities and advanced features by checking out their respective GitHub repositories linked above.