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.4.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.4-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for lswapi-0.5.4.tar.gz
Algorithm Hash digest
SHA256 892eeee1ae4d8f4ae0927b16b4e644a50aea8a8526a956d1d70afd1fccd1abc2
MD5 8761fe2de76466ec8009a63ef999e7c7
BLAKE2b-256 13a1f6a14bbdb25500c4f40361c88c481e0861ba9d3f6f84d5adddbd56316e8f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lswapi-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c4861676861cd78f447ad05854c2147a4c25f26d0b260d7ac16915695151e1f0
MD5 d85871ceb6f6c842d6d5e1ec6e8e5beb
BLAKE2b-256 14b2e51990a7a5cd0b3f9220f5768ccb4eb8831a54af55fa0c6942ead8eb9b23

See more details on using hashes here.

Release history Release notifications | RSS feed

0.5.5

2 files

This release

0.5.4 This release

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