DATE:
AUTHOR:
The Duffel team
API

New Duffel JavaScript library

DATE:
AUTHOR: The Duffel team

To make it easier to integrate the Duffel API, we now offer a client library in JavaScript, fully typed and ready to be used!

If you are using Node.js v12 (LTS) or later, just install using your favourite package manager:

$ yarn add @duffel/api
or
$ npm i -S @duffel/api

You can then import it into your codebase and initialise it with your access token:

import { Duffel } from '@duffel/api'

const duffel = new Duffel({
 token: YOUR_ACCESS_TOKEN
})

The Duffel JavaScript library is written in TypeScript and comes with types for Duffel API objects, which you can easily import:

import { Aircraft } from '@duffel/api'

const response = await duffel.aircraft.get('arc_00009VMF8AhXSSRnQDI6Hi')
const aircraft: Aircraft = response.data

If you need any help with the library, please let us know.

Powered by LaunchNotes