Client Libraries

Getting Started

To make it easy to build your Duffel integration, we offer client libraries in C#, Java, JavaScript, PHP, Python, and Ruby.

Node.js

If you're using JavaScript, first install the library using your favourite package manager:

Shell (using yarn)

yarn add @duffel/api
Then import it into your codebase and initialise it with your access token:

JavaScript

import { Duffel } from '@duffel/api'
const duffel = new Duffel({
token: YOUR_ACCESS_TOKEN,
})
View the repository on GitHub and check out the npm package:

Python

If you're using Python, first install the library using pip:

Python

pip install duffel-api
Then import it into your codebase and initialise it with your access token:

Python

from duffel_api import Duffel
duffel = Duffel(access_token=$YOUR_ACCESS_TOKEN)
View the repository on GitHub and check out the python package page:

Ruby

If you're using Ruby, first install the library using Bundler:

Ruby

gem add duffel_api
Then import it into your codebase and initialise it with your access token:

Ruby

require "duffel_api"
duffel = DuffelAPI::Client.new(access_token: $YOUR_ACCESS_TOKEN)
View the repository on GitHub and check out the ruby gem page:

C#

If you're using C#, first install the library using NuGet:

C#

Install-Package Duffel.ApiClient
Then import it into your codebase and initialise it with your access token:

C#

using Duffel.ApiClient;
var duffel = new DuffelApiClient(accessToken: $"{YOUR_ACCESS_TOKEN}", production: true);
View the repository on GitHub and check out the NuGet page:

Java

If you're using Java, add the dependency to your project with Maven:
<dependency>
<groupId>com.duffel</groupId>
<artifactId>duffel-api</artifactId>
<version>1.0.1</version>
</dependency>
or Gradle:
implementation 'com.duffel:duffel-api:1.0.1'
Then import it into your codebase and initialise it with your access token:
import com.duffel.DuffelApiClient;
DuffelApiClient client = new DuffelApiClient("$API_KEY");
View the repository on GitHub and check out the Maven page: