shlink-py
Python module for API communication with Shlink
Installation
To install simply use pip:
pip install shlink
Usage
The package is used by creating a new instance of an Shlink object. API calls can then be made using methods on this object.
An example of all of the calls available is shown in the below example:
import json
import sys
from datetime import datetime
from shlink import Shlink
from shlink.data import Error
shlink = Shlink(
url="https://example.com/",
api_key="000000000-0000-0000-0000-000000000000"
)
# LIST_SHORT_URLS
result = shlink.list_short_urls()
print(json.dumps(result.to_dict()))
if isinstance(result, Error):
sys.exit(1)
# ADD_SHORT_URL
result = shlink.add_short_url(
long_url="http://example.com/",
tags=[
"example"
],
valid_since=datetime(2019, 3, 14),
valid_until=datetime(2019, 3, 20),
custom_slug="example",
max_visits=100,
find_if_exists=False
)
print(json.dumps(result.to_dict()))
if isinstance(result, Error):
sys.exit(2)
# GET_SHORT_URL
result = shlink.get_short_url("example")
print(json.dumps(result.to_dict()))
if isinstance(result, Error):
sys.exit(3)
Development
To run this project in a development environment pipenv is recommended.
E.g.
pipenv run python example.py
Release files for shlink 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shlink-0.1.0.tar.gz | 4.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shlink-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.0 kB
Release files / shlink-0.1.0.tar.gz
| Download URL | shlink-0.1.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
445b3a53a00bc99f45ed7e96220f4d0b22cefdfe21be8b6c0e4bdf64204aaf6c
|
|
BLAKE2b-256 checksum How to use checksums |
bdaaf2948700bf52aabfc8eeff94e8fab6cd30eb2839226d77df47f33346a5bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.3
|
Release files / shlink-0.1.0-py3-none-any.whl
| Download URL | shlink-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a70f0b375aad713f2b9275cd2fdf2faf93a29021edd15f391546de8cff31031
|
|
BLAKE2b-256 checksum How to use checksums |
57133fd37480b6eb95d0160f22954a5f08154ae8d858d2feed05c0149a2ce8fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.3
|