Skip to main content

Official Hetzner Cloud python library

Project description

Hetzner Cloud Python

Official Hetzner Cloud python library.

The library's documentation is available at hcloud-python.readthedocs.io, the public API documentation is available at docs.hetzner.cloud.

[!IMPORTANT] Make sure to follow our API changelog available at docs.hetzner.cloud/changelog (or the RSS feed available at docs.hetzner.cloud/changelog/feed.rss) to be notified about additions, deprecations and removals.

Usage

Install the hcloud library:

pip install hcloud

For more installation details, please see the installation docs.

Here is an example that creates a server and list them:

from hcloud import Client
from hcloud.images import Image
from hcloud.server_types import ServerType

client = Client(
    token="{YOUR_API_TOKEN}", # Please paste your API token here
    application_name="my-app",
    application_version="v1.0.0",
)

# Create a server named my-server
response = client.servers.create(
    name="my-server",
    server_type=ServerType(name="cx23"),
    image=Image(name="ubuntu-22.04"),
)
server = response.server
print(f"{server.id=} {server.name=} {server.status=}")
print(f"root password: {response.root_password}")

# List your servers
servers = client.servers.get_all()
for server in servers:
    print(f"{server.id=} {server.name=} {server.status=}")

Supported Python versions

We support python versions until end-of-life.

Experimental features

Experimental features are published as part of our regular releases (e.g. a product public beta). During an experimental phase, breaking changes on those features may occur within minor releases.

The stability of experimental features is not related to the stability of its upstream API.

Experimental features have different levels of maturity (e.g. experimental, alpha, beta) based on the maturity of the upstream API.

While experimental features will be announced in the release notes, you can also find whether a python class or function is experimental in its docstring:

Experimental:
    $PRODUCT is $MATURITY, breaking changes may occur within minor releases.
    See https://docs.hetzner.cloud/changelog#$SLUG for more details.

Development

First, create a virtual environment and activate it:

make venv
source venv/bin/activate

You may setup pre-commit to run before you commit changes, this removes the need to run it manually afterwards:

pre-commit install

You can then run different tasks defined in the Makefile, below are the most important ones:

Build the documentation and open it in your browser:

make docs

Lint the code:

make lint

Run tests using the current python3 version:

make test

You may also run the tests for multiple python3 versions using tox:

tox .

Deprecations implementation

When deprecating a module or a function, you must:

  • Update the docstring with a deprecated notice:
"""Get image by name

.. deprecated:: 1.19
    Use :func:`hcloud.images.client.ImagesClient.get_by_name_and_architecture` instead.
"""
  • Raise a warning when the deprecated module or function is being used:
warnings.warn(
    "The 'hcloud.images.client.ImagesClient.get_by_name' method is deprecated, please use the "
    "'hcloud.images.client.ImagesClient.get_by_name_and_architecture' method instead.",
    DeprecationWarning,
    stacklevel=2,
)

Releasing experimental features

To publish experimental features as part of regular releases:

  • an announcement, including a link to a changelog entry, must be added to the release notes.

  • an Experimental notice, including a link to a changelog entry, must be added to the python classes and functions that are experimental:

    """
    Experimental:
        $PRODUCT is $MATURITY, breaking changes may occur within minor releases.
        See https://docs.hetzner.cloud/changelog#$SLUG for more details.
    """
    

License

The MIT License (MIT). Please see License File for more information.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hcloud-2.19.0.tar.gz (154.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hcloud-2.19.0-py3-none-any.whl (112.0 kB view details)

Uploaded Python 3

File details

Details for the file hcloud-2.19.0.tar.gz.

File metadata

  • Download URL: hcloud-2.19.0.tar.gz
  • Upload date:
  • Size: 154.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for hcloud-2.19.0.tar.gz
Algorithm Hash digest
SHA256 b17a2e7503456e7a470dfbaf6b258bb7d3f5ef1a23227d02199da91cc87dc156
MD5 e94e229f197b075f73941c7c57e2f465
BLAKE2b-256 1e9936d18258f90b8d5cf499a6dbad82bb8cc0419d95c55181691bd8a1e16528

See more details on using hashes here.

Provenance

The following attestation bundles were made for hcloud-2.19.0.tar.gz:

Publisher: release.yml on hetznercloud/hcloud-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hcloud-2.19.0-py3-none-any.whl.

File metadata

  • Download URL: hcloud-2.19.0-py3-none-any.whl
  • Upload date:
  • Size: 112.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for hcloud-2.19.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b61312827b2c716ca3afc6b2d026b0a385ac074f2372f83e4a38aeeac80f9855
MD5 903b54a93260804748e7318c2aabbbb1
BLAKE2b-256 ee03c2a6a35c735445a6909d10c6e5c04732f2f493a2c52a06f3bf0b75c2b7a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for hcloud-2.19.0-py3-none-any.whl:

Publisher: release.yml on hetznercloud/hcloud-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page