Skip to main content

Quickstart

Learn how to retrieve your devices and base stations with a few requests.

Get your platform hostname

This is the hostname you are using to access ThingPark user interface.

If you are using ThingPark Enterprise SaaS, this is either:

  • Community: community.thingpark.io
  • Europe: thingparkenterprise.eu.actility.com
  • Australia: thingparkenterprise.au.actility.com
  • United-States: thingparkenterprise.us.actility.com
import axios from 'axios';

const platform_hostname = 'community.thingpark.io';

Add a service account

See Managing service accounts in the user guide.

Take note of the service account's client ID and client secret.

const client_id = 'sub-199983788/my-app';
const client_secret = 'JyqK3iQA6sVdMsmxe4kqPNYNaftrAgap';

Issue an access token

Call the token endpoint for a client credentials grant.

const token = await axios.post(
`https://${platform_hostname}/users-auth/protocol/openid-connect/token`,
{ client_id, client_secret, grant_type: 'client_credentials' },
{ headers: { 'content-type': 'application/x-www-form-urlencoded' } },
)

Retrieve devices

Devices are paginated. You may have to request the next pages to retrieve all the devices. See pagination.

const devices = await axios.get(
`https://${platform_hostname}/thingpark/wireless/rest/subscriptions/mine/devices`,
{ headers: { 'Authorization': `Bearer ${token.data.access_token}` } },
)

Retrieve base stations

Base stations are paginated. You may have to request the next pages to retrieve all the base stations. See pagination.

const base_stations = await axios.get(
`https://${platform_hostname}/thingpark/wireless/rest/partners/mine/bss`,
{ headers: { 'Authorization': `Bearer ${token.data.access_token}` } },
)

Token renewal

For a long running application, you may have to renew the access token. See token renewal.