API Definitions & Swagger

What is swagger & how can I use it to generate an API client?

Linnworks' API 1 uses Swagger 2.0 specifications, which allows us to describe the endpoints, including request and response information. This works jointly with Swaggeropens in a new tab, which is a set of open-source tools consume our APIs.

Accessing Swagger Definitions

All our API definitions are kept in our GitHubopens in a new tab

Generating a Client

One of the main benefits of using Swagger is the ability to generate a client in many different languages. There are multiple different client generators, but this guide will make use of Swagger Codegenopens in a new tab. You can use it via the command line, or via the online swagger editoropens in a new tab.

Swagger Editor

Generating a client via the online editor is very simple.

  • Paste in the open API definition
    • You will see the swagger visually in the area to the right, where you can see all the available endpoints and models.
  • Click 'Generate Client' in the menu bar, and select a language
    • This will now download the client

Command Line

Swagger have good documentation themselves for generating clients via the command line, which you can find on swagger's documentation pageopens in a new tab.

Using the Client

In the downloaded folder, you will the code needed to call the API. This code will differ between languages, but you can use the generated code to call the API. All the request and response models will be generated for you, along with the implementation of the API and any client classes the code needs to help call the API.

Macros

If you are developing a Macro, you do not need to generate a client yourself, as it will be part of our
Macro SDKopens in a new tab.