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
- TypeScript
- JavaScript
- Bash
- Python
import axios from 'axios';
const platform_hostname = 'community.thingpark.io';
import axios from 'axios';
const platform_hostname = 'community.thingpark.io';
PLATFORM_HOSTNAME="community.thingpark.io"
import requests
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.
- TypeScript
- JavaScript
- Bash
- Python
const client_id = 'sub-199983788/my-app';
const client_secret = 'JyqK3iQA6sVdMsmxe4kqPNYNaftrAgap';
const client_id = 'sub-199983788/my-app';
const client_secret = 'JyqK3iQA6sVdMsmxe4kqPNYNaftrAgap';
CLIENT_ID="sub-199983788/my-app"
CLIENT_SECRET="JyqK3iQA6sVdMsmxe4kqPNYNaftrAgap"
client_id = 'sub-199983788/my-app'
client_secret = 'JyqK3iQA6sVdMsmxe4kqPNYNaftrAgap'
Issue an access token
Call the token endpoint for a client credentials grant.
- TypeScript
- JavaScript
- Bash
- Python
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' } },
)
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' } },
)
ACCESS_TOKEN=$(curl \
-d "client_id=${CLIENT_ID}" \
-d "client_secret=${CLIENT_SECRET}" \
-d "grant_type=client_credentials" \
https://${PLATFORM_HOSTNAME}/users-auth/protocol/openid-connect/token | jq -r '.access_token')
token = requests.post(
f"https://{platform_hostname}/users-auth/protocol/openid-connect/token",
data = { 'client_id': client_id, 'client_secret': client_secret, 'grant_type': 'client_credentials' },
headers = { 'content-type': 'application/x-www-form-urlencoded' },
).json()
Retrieve devices
Devices are paginated. You may have to request the next pages to retrieve all the devices. See pagination.
- TypeScript
- JavaScript
- Bash
- Python
const devices = await axios.get(
`https://${platform_hostname}/thingpark/wireless/rest/subscriptions/mine/devices`,
{ headers: { 'Authorization': `Bearer ${token.data.access_token}` } },
)
const devices = await axios.get(
`https://${platform_hostname}/thingpark/wireless/rest/subscriptions/mine/devices`,
{ headers: { 'Authorization': `Bearer ${token.data.access_token}` } },
)
curl \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Accept: application/json" \
https://${PLATFORM_HOSTNAME}/thingpark/wireless/rest/subscriptions/mine/devices
devices = requests.get(
f"https://{platform_hostname}/thingpark/wireless/rest/subscriptions/mine/devices",
headers = { 'Authorization': f"Bearer {token['access_token']}", 'Accept': 'application/json' },
).json()
Retrieve base stations
Base stations are paginated. You may have to request the next pages to retrieve all the base stations. See pagination.
- TypeScript
- JavaScript
- Bash
- Python
const base_stations = await axios.get(
`https://${platform_hostname}/thingpark/wireless/rest/partners/mine/bss`,
{ headers: { 'Authorization': `Bearer ${token.data.access_token}` } },
)
const base_stations = await axios.get(
`https://${platform_hostname}/thingpark/wireless/rest/partners/mine/bss`,
{ headers: { 'Authorization': `Bearer ${token.data.access_token}` } },
)
curl \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Accept: application/json" \
https://${PLATFORM_HOSTNAME}/thingpark/wireless/rest/partners/mine/bss
base_stations = requests.get(
f"https://{platform_hostname}/thingpark/wireless/rest/partners/mine/bss",
headers = { 'Authorization': f"Bearer {token['access_token']}", 'Accept': 'application/json' },
).json()
Token renewal
For a long running application, you may have to renew the access token. See token renewal.