Credits API (Billing, Payments and Credits)

Credits API is a system for administration of credits and payments for them.

Warning

https://spaceknow-credits.appspot.com/ is deprecated and should not be used anymore.

Concept

Some actions available through SpaceKnow APIs may be performed only within allocated areas and scenes. Users are grouped into groups where each group has credits. These credits can be exchanged for an area allocation.

For example:

Olivia and William are part of group called Smiths. Olivia wants to perform an analysis on multiple satellite images from San Francisco acquired between 4th May 2016 and 20th June 2017. Before she can do any analysis, she has to allocate scenes and location via Credits API. She does that with an API call.

There are 7 scenes found for provider GBDX and dataset IDAHO-PANSHARPENED between May 2016 and June 2017 and San Francisco has 121 \(km^2\). Mentioned dataset uses 0.1 credits per \(km^2\). This means that \(7 \cdot 121 \cdot 0.1 = 84.7\) credits is subtracted from group Smiths in exchange for that area. From now on all users from group Smiths (Olivia and William) can perform unlimited analysis of satellite images of San Francisco from dates between May 2016 and June 2017.

Selected imagery only

The Credits API currently applies to selected imagery only. To access other types of imagery, a special permission is required instead.

Free Area

The API offers one free area suitable for testing purposes. This gives customers a chance to evaluate the product without any commitment. Free area is enclosed by web map tiles (17, 121253, 75886) to (17, 121326, 75960), which correspond to the following GeoJSON. You can inspect the area here.

{
    "type": "Polygon",
        "coordinates": [[
            [153.03131103515622, -27.510707451811598],
            [153.23455810546878, -27.510707451811598],
            [153.23455810546878, -27.327855149448382],
            [153.03131103515622, -27.327855149448382],
            [153.03131103515622, -27.510707451811598]
        ]]
}

Cost of imagery

Provider Dataset cost per \(km^2\)
GBDX idaho-pansharpened idaho-swir idaho-panchromatic 0.1
Planet SkySatCollect 0.015
Planet PSOrthoTile PSScene3Band PSScene4Band 0.001
EarthEngine COPERNICUS/S1_GRD COPERNICUS/S2 LANDSAT/LE07/C01/T1 LANDSAT/LC08/C01/T1 0.0001

Allocate Area

Use this API endpoints to allocate an area and time range for group of which requesting client is part of.

Needed Permissions: credits.allocate-area

POST /credits/area/allocate-geojson
Request JSON Object:
 
  • geojson (object) – required; GeoJSON in WGS84 coordinates enclosing area to be allocated. The GeoJSON must be within -85 to 85 degrees of latitude.
  • sceneIds (list) – required; list of sceneIds, obtained from e.g. Ragnar search

Example request:

{
    "sceneIds": ['DXc_fDD2aRjkHXMur6NSw1Fz4vmD80bGJLtK1gfSGjMR77E2b-DOrvsQzfYeJA'],
    "geojson": {
        "type": "MultiPolygon",
        "coordinates": [
            [
                [
                    [-122.51747131348, 37.694823535365],
                    [-122.35130310059, 37.694823535365],
                    [-122.35130310059, 37.809919574016],
                    [-122.51747131348, 37.809919574016],
                    [-122.51747131348, 37.694823535365]
                ]
            ]
        ]
    }
}
Response JSON Object:
 
  • km2 (float) – number of \(km^2\) newly allocated.
  • cost (float) – number of credits subtracted from account

Example response:

{
    "km2": 2.5,
    "cost": 1.25
}

Check Area

This API endpoints can be used to check whether a client (the group (s)he is part of) has allocation for an area in given scenes.

Needed Permissions: credits.check-area

POST /credits/area/check-geojson
Request JSON Object:
 
  • geojson (object) – required; GeoJSON in WGS84 coordinates enclosing area to be checked. The GeoJSON must be within -85 to 85 degrees of latitude.
  • sceneIds (list) – required; list of sceneIds, obtained from e.g. Ragnar search
  • userId (string) – optional; check area for this user. If not provided ID of the user making the request is used. Specifying foreign user ID requires special permissions.

Example request:

{
    "sceneIds": ['DXc_fDD2aRjkHXMur6NSw1Fz4vmD80bGJLtK1gfSGjMR77E2b-DOrvsQzfYeJA'],
    "geojson": {
        "type": "MultiPolygon",
        "coordinates": [
            [
                [
                    [-122.51747131348, 37.694823535365],
                    [-122.35130310059, 37.694823535365],
                    [-122.35130310059, 37.809919574016],
                    [-122.51747131348, 37.809919574016],
                    [-122.51747131348, 37.694823535365]
                ]
            ]
        ]
    }
}
Response JSON Object:
 
  • km2 (float) – number of \(km^2\) requiring allocation.
  • cost (float) – number of credits required for allocation

Example response:

{
    "km2": 2.5,
    "cost": 1.25
}

Add User to a Group

Needed Permissions: admin.credits.bind-user

POST /credits/user/bind
Request JSON Object:
 
  • userId (string) – required; ID of the user to be added to a group
  • groupId (string) – required; ID of the group to which the user shall be added

Example request:

{
    "userId": "auth0|8e9c9d314376cb2319e14606",
    "groupId": "vCBzdovXPFezKDASAsuOgHUrb"
}

Example response:

{}

Remove User from its Group

Needed Permissions: admin.credits.unbind-user

POST /credits/user/unbind
Request JSON Object:
 
  • userId (string) – required; ID of the user to be affected

Example request:

{
    "userId": "auth0|8e9c9d314376cb2319e14606"
}

Example response:

{}

Search Group

Needed Permissions: admin.credits.search-group

POST /credits/group/search
Request JSON Object:
 
  • groupName (string) – required; name to search. Search is case-insensitive.

Example request:

{
    "groupName": "Example Company"
}
Response JSON Object:
 
  • groups (list) – list of first 10 found groups
  • groups[i].groupId (string) – a unique ID of the group
  • groups[i].name (string) – name of the group
  • groups[i].credit (float) – amount of credit assigned to the group
  • groups[i].usedCredit (float) – amount of credit already used. Remaining credit can be calculated as credit - usedCredit.

Example response:

{
    "groups": [
        {
            "groupId": "ccffeeddss",
            "name": "Example Company",
            "credit": 125,
            "usedCredit": 22.32
        }
    ]
}

Create Group

Needed Permissions: admin.credits.create-group

POST /credits/group/create
Request JSON Object:
 
  • name (string) – required; name of the group to be created. Group name does uniquely identify the group, always use group ID for that purpose.
  • credit (float) – required; number of credit to be assigned to the group

Example request:

{
    "name": "Example Company v2",
    "credit": 15
}
Response JSON Object:
 
  • groupId (string) – a unique ID of the created group

Example response:

{
    "groupId": "xxeeffdd"
}

Change Group Credit

Needed Permissions: admin.credits.change-group-credit

POST /credits/group/change-credit
Request JSON Object:
 
  • groupId (string) – required; ID of the group to be changed
  • creditDelta (float) – amount of credit to add. This value may be negative.

Example request:

{
    "groupId": "ccffeeddss",
    "creditDelta": 150
}
Response JSON Object:
 
  • credit (float) – amount of credit the company have after the addition

Example response:

{
    "credit": 155.2
}

Get Group

Needed Permissions: admin.credits.get-group

POST /credits/group/get
Request JSON Object:
 
  • groupId (string) – required; ID of the group to get

Example request:

{
    "groupId": "ccffeeddss"
}
Response JSON Object:
 
  • groupId (string) – a unique ID of the group
  • name (string) – name of the group
  • credit (float) – amount of credit assigned to the group
  • usedCredit (float) – amount of credit already used.
  • boundUserIds (list) – list of users bind to the group
  • boundUserIds[i] (string) – ID of a user

Example response:

{
    "groupId": "ccffeeddss",
    "name": "Example Company",
    "credit": 125,
    "usedCredit": 22.32,
    "boundUserIds": [
        "auth0|8e9c9d314376cb2319e14606"
    ]
}

Get Remaining Credit

Get remaining and used credit for the group the calling user is bind in.

Needed Permissions: credits.get-remaining-credit

POST /credits/get-remaining-credit

Example request:

{}
Response JSON Object:
 
  • remainingCredit (float) – amount of remaining credit of the users group

Example response:

{
    "remainingCredit": 101.1,
}

Create payment token

Generates Braintree client token which is needed to initiate new transaction.

Needed Permissions: credits.payment

POST /credits/payment/new

Example request:

{}
Response JSON Object:
 
  • clientToken (string) – Braintree client token

Example response:

{
    "clientToken": "eyJ2ZXJzaW9u..."
}

Buy credit

Buy credit using Braintree payment method nonce. Nonce is generated by Braintree Drop-in UI on frontend using client token and it is one-time-use reference to payment information.

Number of credits to be added is calculated as one tenth (1 / 10) of spent USD.

Needed Permissions: credits.payment

POST /credits/payment/buy-credit
Request JSON Object:
 
  • paymentMethodNonce (string) – Braintree payment method nonce
  • amountToSpend (int) – amount in USD to spend for credits, minimum is 10 USD

Example request:

{
    "paymentMethodNonce": "BlGmvLOYUHQ...",
    "amountToSpend": 15
}
Response JSON Object:
 
  • purchasedCredit (float) – amount of credit added to user’s group
  • remainingCredit (float) – amount of remaining credit of the users group

Example response:

{
    "purchasedCredit": 1.5,
    "remainingCredit": 101.1
}