Seiki API - v1 (1.2.0)

Download OpenAPI specification:Download

How to use this API

Authentication

To call this API you need an API key provided by Seiki. The API key is provided in every HTTP call in the key header.

Here is an example in Python :

requests.get(
    'https://api.winter-mushroom.seiki.co/v1/account/credits',
    headers = {'key': MY_API_KEY}
    )

In case of failed authentication, the API returns the following status codes :

  • 401 : No API key was provided
  • 403 : The provided API key is not authorized to access this API

Credits

To use this API, you need credits in order to create new POIs : 1 POI = 1 credit.

To retrieve your amount of credits, you can call the endpoint /account/credits

In case of insufficient credits, the API returns a status code 402.

For the endpoints that create POIs, the optional boolean parameter dry_run can be provided, which allows you to check authentication and parameters validity at no cost. It also allows you to retrieve what would be the cost of the computation.

Here's the workflow when you create POIs :

  • Check authentication
  • Check parameters validity
  • Compute projected cost : 1 for each POI, except for the free lat/lng (48.8751, 2.3074)
  • Check that you have enough credits
  • If it's a dry run, stop here
  • Consume projected cost
  • Perform computation
  • Compute real cost : if the computation could not be performed on a POI, this POI is free
  • If real cost is less than the projected cost, refund the difference

Asynchronous calls

You can compute multiple POIs at once, using the asynchronous endpoint /poi/batch. When submitting your inputs, the API immediately returns a batch id. You can then query the API with this batch id, to check the batch processing state, and retrieve the output when done.

Here's an example submitting a new batch :

body = {
    'items': [
        { 'lat': 48.8751, 'lng': 2.3074, 'end_date': '2023-12-03' },
    ]}

MY_BATCH_ID = requests.post(
    'https://api.winter-mushroom.seiki.co/v1/poi/batch',
    headers = { 'key': MY_API_KEY },
    json = body
    ).json()['batch_id']

To retrieve the state and/or output of a batch, you can use the following code :

requests.get(
    'https://api.winter-mushroom.seiki.co/v1/batch/' + MY_BATCH_ID,
    headers = { 'key': MY_API_KEY }
    )

To wait until a job is done, you can use the following code :

status_code = 202

while status_code == 202:

    time.sleep(5) # Wait 5 seconds
    output = requests.get(
        'https://api.winter-mushroom.seiki.co/v1/batch/' + MY_BATCH_ID,
        headers = { 'key': MY_API_KEY }
        )
    status_code = output.status_code

print(output.json())

Account

Get credits information

This route allows you to check your remaining credits

Authorizations:
API_KEY

Responses

Request samples

requests.get(
  'https://api.winter-mushroom.seiki.co/v1/account/credits',
  headers = { 'key': MY_API_KEY }
)

Response samples

Content type
application/json
{
  • "credits": 42
}

POI Analysis

Compute POIs

This route allows you to compute a batch of new POIs, described by their coordinates or addresses. The route is asynchronous : it returns a batch id that can be queried subsequently. Beware that using addresses can result in imprecisions on the exact locations of the POIs.

Costs 1 credit per POI

Authorizations:
API_KEY
query Parameters
dry_run
boolean
Default: false

Perform a dry run : only checks authorization and parameters, at no credit cost

Request Body schema: application/json
required
Array of objects

Responses

Request samples

Content type
application/json
{
  • "items": [
    ]
}

Response samples

Content type
application/json
{
  • "consumed_credits": 1,
  • "batch_id": "077d5c56-d25f-4d7f-a08e-24a935f55895"
}

Retrieve batch

This route allows you to retrieve the state and output of a batch (if completed)

The status code can be used to check the job progression : 200 if done, 202 if still running

Authorizations:
API_KEY

Responses

Request samples

requests.get(
  'https://api.winter-mushroom.seiki.co/v1/batch/MY_BATCH_ID',
  headers = {'key': MY_API_KEY}
)

Response samples

Content type
application/json
{
  • "state": "SUCCESS | FAILURE",
  • "cost": 2,
  • "refund": 1,
  • "error": "string",
  • "items": [
    ]
}

List all batches

This route allows you to retrieve the list of all batches in the last 48 hours

Authorizations:
API_KEY

Responses

Request samples

requests.get(
  'https://api.winter-mushroom.seiki.co/v1/batch',
  headers = {'key': MY_API_KEY}
)

Response samples

Content type
application/json
{
  • "items": [
    ]
}

Reference Data

Get all genders

Authorizations:
API_KEY

Responses

Response samples

Content type
application/json
{
  • "items": [
    ]
}

Get all ages

Authorizations:
API_KEY

Responses

Response samples

Content type
application/json
{
  • "items": [
    ]
}

Get all social groups

Authorizations:
API_KEY

Responses

Response samples

Content type
application/json
{
  • "items": [
    ]
}

Get all modes

Authorizations:
API_KEY

Responses

Response samples

Content type
application/json
{
  • "items": [
    ]
}

Get all trip purposes

Authorizations:
API_KEY

Responses

Response samples

Content type
application/json
{
  • "items": [
    ]
}