Giter Club home page Giter Club logo

shlink-py's Introduction

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

shlink-py's People

Contributors

davidsouthgate avatar

Stargazers

 avatar

Watchers

 avatar  avatar

shlink-py's Issues

Get short url visits from shlink

I'd like to integrate a new feature to this library.

In a project I'm working on I need to have this API connection with python: https://api-spec.shlink.io/#/Visits/getShortUrlVisits
It means to add this API connection:

/rest/v{version}/short-urls/{shortCode}/visits

It's been a while since the last update of this, I think it would be nice to include API version 3 instead of 1 also if possible.

If I can help with this please let me know, and I'll do!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.