Skip to main content

lswapi (beta)

Actions Status

Python module to talk to Leaseweb's API.

For more information refer to the documentation available at [http://developer.leaseweb.com]

This module contains two api clients:

  1. One is based on the requests module.
  2. The second one is based on the aiohttp module for asyncio support.

Installation

Install the module using pip. This will not install requests or aiohttp.

pip install lswapi

You can install optional depencies, such as aiohttp:

pip install 'lswapi[aio]'

Or if you prefer to use requests:

pip install 'lswapi[requests]'

Usage

Using requests

The lswapi.requests.get_leaseweb_api function creates an instance of the Leaseweb Api object with the X-Lsw-Auth key. You can provide the api key as an argument to get_leaseweb_api

$ python
>>> from lswapi.requests import get_leaseweb_api
>>> client = get_leaseweb_api(api_key="xxxx-xxx-xxxxxx")
>>> response = client.get("/bareMetals/v2/servers")
>>> servers = response.json()

or get LSW_API_KEY from an environment variable:

$ LSW_API_KEY=xxxx-xxxx-xxxxx python
>>> from lswapi.requests import get_leaseweb_api
>>> client = get_leaseweb_api()
>>> response = client.get("/bareMetals/v2/servers")
>>> servers = response.json()

Using aiohttp

The lswapi.aio.get_leaseweb_api function creates an instance of the Leaseweb Api object with the X-Lsw-Auth key. You can provide the api key as an argument to get_leaseweb_api or via the environment variable LSW_API_KEY:

$ python -m asyncio
>>> from lswapi.aio import get_leaseweb_api
>>> client = get_leaseweb_api(api_key="xxxx-xxx-xxxxxx")
>>> response = await client.get("/bareMetals/v2/servers")
>>> servers = await response.json()

Contribute

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Make sure that tests pass (make test)
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

Download files

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

Source Distribution

lswapi-0.5.5.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

lswapi-0.5.5-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file lswapi-0.5.5.tar.gz.

File metadata

  • Download URL: lswapi-0.5.5.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for lswapi-0.5.5.tar.gz
Algorithm Hash digest
SHA256 73da20e6ddc753c9baa37548e1be8ffb795df5b56fe4aae9e97f8e56e244838c
MD5 4aba2133e54ed8b099b6e1369368f994
BLAKE2b-256 a6d5f8bf707f697fa7242925fec9a16f77728e73ee409dc9e0e684e17f680874

See more details on using hashes here.

File details

Details for the file lswapi-0.5.5-py3-none-any.whl.

File metadata

  • Download URL: lswapi-0.5.5-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for lswapi-0.5.5-py3-none-any.whl
Algorithm Hash digest
SHA256 86e2c92b5f5f5695ca5cd426b274c4f614d95c36d66cd1f81c157b0d5996e453
MD5 fb81c6020898d4e95c8a2346376f78d5
BLAKE2b-256 ebace7c71ee008460ad9fd44c6f1500bde7405357d77c356c55a1851d4395cac

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.5 This release

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

1 file

0.4.0

1 file

0.3.5

1 file

0.3.4

1 file

0.3.3

1 file

0.3.2

1 file

0.3.1

1 file

0.3.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page