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.2.tar.gz (8.5 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.2-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lswapi-0.5.2.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.6 Linux/6.11.0-1018-azure

File hashes

Hashes for lswapi-0.5.2.tar.gz
Algorithm Hash digest
SHA256 37690eb368a5c8f330c1c395a695e68034936696c3daed573c0799ee7417299f
MD5 0fc7488f3c772e38a0508bea55ee8e23
BLAKE2b-256 0f6fb312d5bf686c2094e51c0907be68cff5f9e7caa0ad1f1e662438bc330847

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lswapi-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.6 Linux/6.11.0-1018-azure

File hashes

Hashes for lswapi-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ecefa1a641af256b864cb1942d31c51616c849338a5680ce9201c8d298d0028a
MD5 6f7a4fd3125483110759b44200a4fc2b
BLAKE2b-256 de0d42f212e9ee714c1a035123c9e63c86a5ea1b9dc13113b9d733af61e2e1b0

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