Skip to main content

REST APIs

All our REST services are documented using the OpenAPI spec + Swagger.

Services#

  • Data - endpoints for managing Sample data.
  • User - endpoints for managing users and permissions.
  • Billing - endpoints for calculating costs.

Generating client libraries#

Using an OpenAPI client generator, it is possible to generate client libraries for many common programming languages.

Example#

In the following example we will be using the Python generator to generate a Data client, but you can choose any generator from this list and any of our REST APIs above.

Download the OpenAPI document#

First, open the relevant REST API browser by clicking a service above. In this scenario we will open the Data service. Then, click on the swagger.json link to download the OpenAPI document.

img

Alternatively you can use the CLI to download an OpenAPI document:

$ wget https://api.splashback.io/data/swagger/v1/swagger.json

Generate the client library#

First, install the generator's dependencies. You will need to install the latest stable release of Node.js and Java 8 (you can use OpenJDK 8 on Linux).

To install the OpenAPI generator CLI and generate a Python client, run the following commands:

$ npm install @openapitools/openapi-generator-cli -g$ npx @openapitools/openapi-generator-cli generate -i swagger.json -g python --package-name splashback_data -o splashback_data
tip

Replace swagger.json with the path to the OpenAPI document you downloaded.

The -g python option selects the generator. For example, to generate a PHP client library, use -g php instead.

The -o splashback_data option sets the output path.

The --package-name splashback_data option should be set to whatever you would like to call the library. This will show up in your codebase.