Skip to main content

a python client library for easy leaseweb api access

Project description

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

Project details


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.3.tar.gz (11.1 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.3-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lswapi-0.5.3.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for lswapi-0.5.3.tar.gz
Algorithm Hash digest
SHA256 b7b754bc8dd3009044f91373bdc74fd1a6835bc3e35096b2fa6ae9207a07e8c4
MD5 5fc8d1c781adb2b9394d845552d5bf37
BLAKE2b-256 02fab88f04b5fd3d02171cca35b881383c886ceb45308506b274730eabbcf3cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lswapi-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for lswapi-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 19d638bfcf3fc6a1d6e497472234a606c5df6e810fdebd946e3b1c055492bbfb
MD5 5b406e291ece8a64cbf369c3b5c7a924
BLAKE2b-256 91ff9ce4d30c9d77a3e2303aef01e3db51eb5578ea66299001e1bfaa337d0d21

See more details on using hashes here.

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