Create duffel app
To make building with Duffel even easier, we offer a command-line interface for generating a full-stack application with Duffel's SDK integrated along with a simple flight booking example (See supported frameworks/languages for the available options).
To use this tool, make sure you have either
npm installed, then run the following command:
yarn create duffel-app
You will be guided through selecting the front end and back end language/framework, and finally inputting your Duffel access token which can be found on your tokens page on the Duffel dashboard. Only test tokens are allowed to ensure that real orders won't be booked accidentally (you can change this later on if you wish).
After that, the tool will create your app folder with two folders inside:
server. Simply start the server by going inside the
server directory and following the instructions. Then finally, you can run
yarn start from within the
client folder. Your browser will open
http://localhost:3000 once that's done.
This is what you will see after starting the client
The page contains a working flight booking example that you can play around with. As this example uses the Duffel API, the orders created through this will be visible on your orders page.
Within the code, you will be able to see how the Duffel API endpoints are used in combination to create an order. You can also evolve the example further to explore more of Duffel's capabilities. The sky is the limit!
React (powered by create-react-app)
Replacing the access token
The Duffel access token you use during the initial setup will be written to the files under the
env folder under
DUFFEL_ACCESS_TOKEN variable. You can manually change this if you wish to use another token.