Skip to main content

Client library for the Duffel API

Project description

PyPI Supported Python versions Build Status Code style:black Downloads

duffel-api

Python client library for the Duffel API.

Requirements

  • Python 3.7+

Getting started

pip install duffel-api

Usage

You first need to set the API token you can find in the Duffel dashboard under the section Developers > Access Tokens.

Once you have the token, you can call Duffel() with the value:

from duffel_api import Duffel

access_token = 'test_...'
client = Duffel(access_token = access_token)

After you have a client you can interact with, you can make calls to the Duffel API:

from duffel_api import Duffel

client = Duffel(access_token = 'test...')

offer_requests = client.offer_requests.list()
for offer_request in offer_requests:
    print(offer_request.id)

You can find a complete example of booking a flight in ./examples/book-flight.py.

Development

Testing

Run all the tests:

tox

As part of running tox, a code coverage report is built for you. You can navigate it by opening htmlcov/index.html in a browser, or if in a OS that supports it by using open (alternative xdg-open):

open ./htmlcov/index.html

Packaging

Setup pypi config (~/.pypirc):

[pypi]
  username = __token__
  password = pypi-generated-token

[testpypi]
  username = __token__
  password = pypi-generated-token

Install dependencies:

pip install wheel twine

Build the package before uploading:

python setup.py sdist bdist_wheel

Upload packages (test):

twine upload -r testpypi --verbose dist/*

The above will upload the packages to test.pypi.org which will allow you to verify all is well with your upload before uploading it to the main pypi repository.

twine upload -r pypi --verbose dist/*

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

duffel-api-0.4.0.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

duffel_api-0.4.0-py3-none-any.whl (61.5 kB view details)

Uploaded Python 3

File details

Details for the file duffel-api-0.4.0.tar.gz.

File metadata

  • Download URL: duffel-api-0.4.0.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for duffel-api-0.4.0.tar.gz
Algorithm Hash digest
SHA256 f45ff4a6e25c69677577ecec240d4513d5bb919c2362b688440be6ecdb7104fb
MD5 a911e58e39237c8e7aea27e3b318c544
BLAKE2b-256 253093ac88047c2995eb99513a8526e8be3e8d16560392cdd8bd1ecaa9c44bbe

See more details on using hashes here.

File details

Details for the file duffel_api-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: duffel_api-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 61.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for duffel_api-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 879ab85f7138b5b59eb264293580575675d152c6558891b890a05874465c096d
MD5 be3d0eab961e3494d3fa6b7250e578cc
BLAKE2b-256 05122f6a9d4c02008f364576f5fd5034828fe7f300f31d7960954f783265aae4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page