Make your first API call
In this tutorial you create an API key, use it to get an access token, and ask the API for one SIM’s details. At the end you have the SIM’s status, data package and usage as a JSON response in your terminal.
Before you start
You need:
- the API app on your company’s account. See Turn on an app in the App Store.
- the ICCID of one of your SIMs
- a computer with
curl
Create an API key
- In Terminal, go to Apps > API.
- Select + Create API key.
- Under Label, enter
first-test. - Under Permissions, choose Read.
- Leave IP whitelist (optional) empty.
- Select Create API key.
Terminal shows Your API key has been created, with a username and password. Copy both and keep them somewhere safe. Terminal shows the password only once.
Get an access token
Run this command. Put your username and password in place of the placeholders.
curl -X POST "https://api.1ot.mobi/v1/oauth/token?username=YOUR_USERNAME&password=YOUR_PASSWORD&grant_type=password"You now see a response like this:
{"access_token":"cdfgf91f-...","expires_in":3153600000,"refresh_token":"55th0b4d-...","scope":"read write trust","token_type":"bearer"}Copy the access_token. It doesn’t expire, so you only need to do this once.
Ask for one SIM’s details
Run this command. Put your access token and ICCID in place of the placeholders.
curl "https://api.1ot.mobi/v1/get_sim?iccid=YOUR_ICCID" -H "Authorization: YOUR_ACCESS_TOKEN"You now see the SIM’s details as JSON, including its state, which matches the SIM status you see in Terminal.
What you’ve done
You created an API key, got an access token and read a SIM’s details through the 1oT Terminal API.
Next steps
- Create and manage API keys
- Give a sub-client API access
- SIM statuses
- How the 1oT Terminal API works
- See every request in View documentation on the API page in Terminal. See Find the API documentation.