Skip to content

Latest commit

 

History

History
565 lines (396 loc) · 21.7 KB

File metadata and controls

565 lines (396 loc) · 21.7 KB

hostinger_api.HostingWebsitesApi

All URIs are relative to https://developers.hostinger.com

Method HTTP request Description
create_website_v1 POST /api/hosting/v1/websites Create website
delete_website_v1 DELETE /api/hosting/v1/websites/{domain} Delete website
deploy_static_site_archive_v1 POST /api/hosting/v1/accounts/{username}/websites/{domain}/deploy Deploy static site archive
list_website_setups_v1 GET /api/hosting/v1/onboardings List website setups
list_websites_v1 GET /api/hosting/v1/websites List websites
start_website_setup_v1 POST /api/hosting/v1/orders/{order_id}/onboardings Start website setup

create_website_v1

CommonSuccessEmptyResource create_website_v1(hosting_v1_websites_create_website_request)

Create website

Create a new website for the authenticated client.

You must choose which hosting order to create this website on. Pass that order as order_id together with the domain name. List orders to see available IDs; the website is provisioned on that order's hosting plan.

Only Web and Cloud hosting orders are accepted. To create a website on an Agency Plan order, use POST /api/agency-hosting/v1/orders/{order_id}/websites/setups.

The datacenter_code parameter is required when creating the first website on a new hosting plan - this will set up and configure new hosting account in the selected datacenter.

Subsequent websites will be hosted on the same datacenter automatically.

Website creation is asynchronous and takes up to a few minutes. Poll the list website setups endpoint with the domain filter every 10 to 15 seconds and wait for status: completed before uploading files, deploying or creating databases. While the setup is running, endpoints that operate on the website may respond with 404 or 409. is_enabled on the websites list reflects suspension, not readiness.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.common_success_empty_resource import CommonSuccessEmptyResource
from hostinger_api.models.hosting_v1_websites_create_website_request import HostingV1WebsitesCreateWebsiteRequest
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.HostingWebsitesApi(api_client)
    hosting_v1_websites_create_website_request = hostinger_api.HostingV1WebsitesCreateWebsiteRequest() # HostingV1WebsitesCreateWebsiteRequest | 

    try:
        # Create website
        api_response = api_instance.create_website_v1(hosting_v1_websites_create_website_request)
        print("The response of HostingWebsitesApi->create_website_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingWebsitesApi->create_website_v1: %s\n" % e)

Parameters

Name Type Description Notes
hosting_v1_websites_create_website_request HostingV1WebsitesCreateWebsiteRequest

Return type

CommonSuccessEmptyResource

Authorization

apiToken

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success empty response -
422 Validation error response -
401 Unauthenticated response -
500 Error response -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

delete_website_v1

CommonSuccessEmptyResource delete_website_v1(domain)

Delete website

This endpoint permanently removes a website and all of its data. This action cannot be undone. Before calling it, make sure the user understands the consequences and explicitly confirms that they want to proceed.

All website files, databases and related configuration will be removed. The hosting plan itself is kept, so a new website can be created on it afterwards.

Supported websites: main and addon domain websites on web hosting plans, and Website Builder websites. Parked domains and subdomains cannot be deleted with this endpoint. The domain must be the exact website domain, not a preview domain or an alias.

Returns 404 when the domain does not exist or does not belong to the authenticated client.

Website removal is processed asynchronously and can take a few minutes to complete. The response returns before the removal finishes.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.common_success_empty_resource import CommonSuccessEmptyResource
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.HostingWebsitesApi(api_client)
    domain = 'mydomain.tld' # str | Domain name

    try:
        # Delete website
        api_response = api_instance.delete_website_v1(domain)
        print("The response of HostingWebsitesApi->delete_website_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingWebsitesApi->delete_website_v1: %s\n" % e)

Parameters

Name Type Description Notes
domain str Domain name

Return type

CommonSuccessEmptyResource

Authorization

apiToken

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success empty response -
422 Validation error response -
401 Unauthenticated response -
500 Error response -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

deploy_static_site_archive_v1

CommonSuccessEmptyResource deploy_static_site_archive_v1(username, domain, hosting_v1_websites_deploy_archive_request)

Deploy static site archive

Deploy a static application from an archive file.

WARNING: this overwrites the website's existing contents and cannot be undone — verify this is intended before calling this endpoint.

This endpoint allows you to deploy a static application from an archive file that has been uploaded to the website's directory.

This only works for static sites (pre-built HTML/CSS/JS with no build step). For Node.js applications, use Create NodeJS build from archive instead, or Start Node.js build if the archive is already uploaded. For WordPress sites, use Import WordPress website.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.common_success_empty_resource import CommonSuccessEmptyResource
from hostinger_api.models.hosting_v1_websites_deploy_archive_request import HostingV1WebsitesDeployArchiveRequest
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.HostingWebsitesApi(api_client)
    username = 'u123456789' # str | 
    domain = 'mydomain.tld' # str | Domain name
    hosting_v1_websites_deploy_archive_request = hostinger_api.HostingV1WebsitesDeployArchiveRequest() # HostingV1WebsitesDeployArchiveRequest | 

    try:
        # Deploy static site archive
        api_response = api_instance.deploy_static_site_archive_v1(username, domain, hosting_v1_websites_deploy_archive_request)
        print("The response of HostingWebsitesApi->deploy_static_site_archive_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingWebsitesApi->deploy_static_site_archive_v1: %s\n" % e)

Parameters

Name Type Description Notes
username str
domain str Domain name
hosting_v1_websites_deploy_archive_request HostingV1WebsitesDeployArchiveRequest

Return type

CommonSuccessEmptyResource

Authorization

apiToken

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success response -
422 Validation error response -
401 Unauthenticated response -
500 Error response -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

list_website_setups_v1

List[HostingV1OnboardingsOnboardingResource] list_website_setups_v1(order_id=order_id, subscription_id=subscription_id, domain=domain)

List website setups

Returns the website setups started in the last 24 hours for the hosting accounts accessible to the authenticated client, newest first. Narrow the list with the order_id, subscription_id or domain filters.

Meant for polling right after creating a website or starting a website setup: the website shows up in the websites list before its server-side setup has finished, and while the setup is running endpoints that operate on that website may respond with 404 or 409. Poll this endpoint with the domain filter every 10 to 15 seconds and wait for status: completed before uploading files, deploying or creating databases. failed means the setup stopped before finishing or has not reported progress for over an hour. Setups older than 24 hours are not listed.

type is the website type the setup was started with (wordpress, headless_wordpress, headless_ecommerce, headless_pocketbase), or null for an empty website.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.hosting_v1_onboardings_onboarding_resource import HostingV1OnboardingsOnboardingResource
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.HostingWebsitesApi(api_client)
    order_id = 123 # int | Order ID (optional)
    subscription_id = 'sub_abc123' # str | Filter by hosting order subscription ID (optional)
    domain = 'example.com' # str | Filter by domain name (exact match) (optional)

    try:
        # List website setups
        api_response = api_instance.list_website_setups_v1(order_id=order_id, subscription_id=subscription_id, domain=domain)
        print("The response of HostingWebsitesApi->list_website_setups_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingWebsitesApi->list_website_setups_v1: %s\n" % e)

Parameters

Name Type Description Notes
order_id int Order ID [optional]
subscription_id str Filter by hosting order subscription ID [optional]
domain str Filter by domain name (exact match) [optional]

Return type

List[HostingV1OnboardingsOnboardingResource]

Authorization

apiToken

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success response -
422 Validation error response -
401 Unauthenticated response -
500 Error response -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

list_websites_v1

HostingListWebsitesV1200Response list_websites_v1(page=page, per_page=per_page, username=username, order_id=order_id, is_enabled=is_enabled, domain=domain, website_types=website_types)

List websites

Retrieve a paginated list of websites (CloudLinux, Builder, and Horizons) accessible to the authenticated client.

This endpoint returns websites from your hosting accounts as well as websites from other client hosting accounts that have shared access with you.

Each website includes a website_type field describing the type of website detected on the underlying platform (wordpress, builder, horizons, nodejs, or other). Some fields, such as vhost_type, username, and root_directory, only apply to CloudLinux websites and are null for other platforms.

Use website_types to list only websites of a given detected type, e.g. only WordPress websites (website_types=wordpress) or only Node.js websites (website_types=nodejs). Combine with the other available query parameters to filter by username, order ID, enabled status, or domain name for more targeted results.

A website appears in this list before its server-side setup has finished, and is_enabled reflects suspension, not readiness. To know when a newly created website is ready for file, deploy or database operations, poll the list website setups endpoint instead.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.hosting_list_websites_v1200_response import HostingListWebsitesV1200Response
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.HostingWebsitesApi(api_client)
    page = 1 # int | Page number (optional)
    per_page = 25 # int | Number of items per page (optional) (default to 25)
    username = 'cl_user123' # str | Filter by specific username (optional)
    order_id = 123 # int | Order ID (optional)
    is_enabled = true # bool | Filter by enabled status (optional)
    domain = 'example.com' # str | Filter by domain name (case-insensitive substring match) (optional)
    website_types = ['[\"wordpress\",\"nodejs\"]'] # List[str] | Filter by detected website type, e.g. wordpress,nodejs. Accepts a comma-separated list. (optional)

    try:
        # List websites
        api_response = api_instance.list_websites_v1(page=page, per_page=per_page, username=username, order_id=order_id, is_enabled=is_enabled, domain=domain, website_types=website_types)
        print("The response of HostingWebsitesApi->list_websites_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingWebsitesApi->list_websites_v1: %s\n" % e)

Parameters

Name Type Description Notes
page int Page number [optional]
per_page int Number of items per page [optional] [default to 25]
username str Filter by specific username [optional]
order_id int Order ID [optional]
is_enabled bool Filter by enabled status [optional]
domain str Filter by domain name (case-insensitive substring match) [optional]
website_types List[str] Filter by detected website type, e.g. wordpress,nodejs. Accepts a comma-separated list. [optional]

Return type

HostingListWebsitesV1200Response

Authorization

apiToken

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Success response -
401 Unauthenticated response -
500 Error response -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

start_website_setup_v1

HostingV1OnboardingsOnboardingResource start_website_setup_v1(order_id, hosting_v1_onboardings_start_onboarding_request)

Start website setup

Starts a website setup on a Web or Cloud hosting order and returns the created setup right away; the website itself is provisioned asynchronously. Poll the list website setups endpoint with the domain filter every 10 to 15 seconds and wait for status: completed before uploading files, deploying or creating databases.

Omit type for an empty website. type: wordpress installs WordPress in the website root with the admin user, email and password from wordpress, the domain as the site title, and en_US when wordpress.language is omitted. The headless types (headless_wordpress, headless_ecommerce, headless_pocketbase) create a headless website; headless_wordpress additionally installs WordPress into the cms directory of the website root with generated credentials.

Omit domain to set the website up on a generated temporary free subdomain.

The order must already have a hosting account: to create the first website on a new hosting plan use the create website endpoint, which takes the datacenter_code. Returns 404 when the order does not exist or is not accessible to the authenticated client, and 409 with a Retry-After header while a setup for the same domain is still running.

Example

  • Bearer Authentication (apiToken):
import hostinger_api
from hostinger_api.models.hosting_v1_onboardings_onboarding_resource import HostingV1OnboardingsOnboardingResource
from hostinger_api.models.hosting_v1_onboardings_start_onboarding_request import HostingV1OnboardingsStartOnboardingRequest
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.HostingWebsitesApi(api_client)
    order_id = 12345 # int | Hosting order ID. List orders to find available IDs.
    hosting_v1_onboardings_start_onboarding_request = hostinger_api.HostingV1OnboardingsStartOnboardingRequest() # HostingV1OnboardingsStartOnboardingRequest | 

    try:
        # Start website setup
        api_response = api_instance.start_website_setup_v1(order_id, hosting_v1_onboardings_start_onboarding_request)
        print("The response of HostingWebsitesApi->start_website_setup_v1:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling HostingWebsitesApi->start_website_setup_v1: %s\n" % e)

Parameters

Name Type Description Notes
order_id int Hosting order ID. List orders to find available IDs.
hosting_v1_onboardings_start_onboarding_request HostingV1OnboardingsStartOnboardingRequest

Return type

HostingV1OnboardingsOnboardingResource

Authorization

apiToken

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
201 Created response -
422 Validation error response -
401 Unauthenticated response -
404 Error response -
409 Conflict response. `Retry-After`, when present, is the number of seconds to wait before retrying. * Retry-After - Seconds to wait before retrying the request
500 Error response -

[Back to top] [Back to API list] [Back to Model list] [Back to README]