Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

duffelhq/duffel-api-python

Folders and files

NameName
Last commit message
Last commit date
May 17, 2023
Sep 29, 2023
Feb 13, 2023
Sep 29, 2023
Feb 21, 2021
Jan 31, 2022
Feb 21, 2021
Oct 2, 2023
Jan 7, 2022
Feb 19, 2021
Sep 5, 2024
Jan 4, 2022
Dec 14, 2023
Oct 2, 2023
May 17, 2023

Repository files navigation

Warning

This client library is not currently being supported by Duffel due to a lack of adoption.

You're welcome to fork the repositories and continue maintaining them for your own use.

If, in the future, there's sufficient demand for a particular client library, we'll reconsider our decision to officially support it.


PyPI Supported Python versions Build Status Code style:black Downloads

duffel-api

Python client library for the Duffel API.

Requirements

  • Python 3.8+

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/*