Skip to content

🐍 The official Python SDK that you can use to easily interact with our API

License

Notifications You must be signed in to change notification settings

journy-io/python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

journy.io

journy.io Python SDK

pypi pypi downloads Code style: black

This is the official Python SDK for journy.io.

πŸ’Ύ Installation

You can use the python package manager (pip) to install the SDK:

pip install journyio-sdk

πŸ”Œ Getting started

Import

To start, first import the client.

from journyio.client import Client, Config

Configuration

To be able to use the journy.io SDK you need to generate an API key. If you don't have one you can create one in journy.io.

If you don't have an account yet, you can create one in journy.io or request a demo first.

Go to your settings, under the Connections-tab, to create and edit API keys. Make sure to give the correct permissions to the API Key.

from journyio.httpclient import HttpClientRequests

config = Config("api-key-secret")
http_client = HttpClientRequests()  # If wanted, an own implementation of the HttpClient interface can be created
client = Client(http_client, config)

Methods

Get API key details

from journyio.results import Success

result = client.get_api_key_details()
if isinstance(result, Success):
    print(result.request_id)  # str
    print(result.calls_remaining)  # int
    print(result.data)  # ApiKeyDetails
    print(result.permissions)  # list of strings denoting the permissions

Handling errors

Every call will return a Success or Failure object. Success objects refer to the call having succeeded (and optionally containing data). A Failure object refers to the API returning an error. This can be any APIError (too many requests, not found...). Our SDK only throws JournyExceptions, no other exceptions should be called. JournyExceptions are provided with useful messages, which state where the error was made.

from journyio.utils import JournyException

try:
    result = client.get_tracking_snippet("www.journy.io")
    if isinstance(result, Success):
        print(result.request_id)  # str
        print(result.calls_remaining)  # int
        print(result.data)  # TrackingSnippetResonse
    else:
        print(result.request_id)  # str
        print(result.calls_remaining)  # int
        print(result.error)  # APIError
except JournyException as e:
    print(e.msg)  # str with error message

The request ID can be useful when viewing API logs in journy.io.

πŸ“¬ API Docs

API reference

πŸ’― Tests

To run the tests:

cd tests
pip install -r requirements.txt
pip install -U pytest
python scripts/createversion.py 0.0.0
pytest

❓ Help

We welcome your feedback, ideas and suggestions. We really want to make your life easier, so if we’re falling short or should be doing something different, we want to hear about it.

Please create an issue or contact us via the chat on our website.

πŸ”’ Security

If you discover any security related issues, please email security at journy io instead of using the issue tracker.