a python client library for easy leaseweb api access
Project description
lswapi (beta)
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:
- One is based on the
requests
module. - 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
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Make sure that tests pass (
make test
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
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
Built Distribution
File details
Details for the file lswapi-0.5.0.tar.gz
.
File metadata
- Download URL: lswapi-0.5.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
8ff646fef0d5b21d9043ead61346e75c77ca1c5bdea80299a2cd4fc04c14f288
|
|
MD5 |
eff0d32ed240343653f798a823b9e5c4
|
|
BLAKE2b-256 |
f1fe08b83326cd61eff6e44ddf1d41bfa214a895c075e1f4c62b8a23cd926e05
|
File details
Details for the file lswapi-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: lswapi-0.5.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
ad13878445fc12375b4482be82ce5f7355bcda7791b21ae17dc281f6e37e9889
|
|
MD5 |
7184f451c735c4102db7129a98f98c2f
|
|
BLAKE2b-256 |
734e03b3fb0e43a79bae5f1bad9418b57e41a92e502d0dc0b4f0dad6801c054a
|