Use this guide before connecting any template to real ThingsLog devices.
- A ThingsLog username and password.
- Access to the ThingsLog company/devices you want to use.
- A backend template or server-side app where the token will be stored.
Never put a ThingsLog token in browser code, mobile app bundles, screenshots, public issues, or committed .env files.
This is useful for quick testing.
curl -i -X POST "https://iot.thingslog.com:4443/login" \
-H "Content-Type: application/json" \
-d '{"username":"YOUR_USERNAME","password":"YOUR_PASSWORD"}'If the credentials are valid, the response is 200 OK and includes a bearer token in the Authorization response header.
Copy the token value after Bearer.
This is the recommended flow for installer portals, integrator backends and production integrations.
- Generate a Keycloak access token.
curl -s -X POST "https://iot.thingslog.com/keycloak/realms/thingslog/protocol/openid-connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=password" \
-d "client_id=thingslog-admin" \
-d "username=YOUR_USERNAME" \
-d "password=YOUR_PASSWORD"Copy the access_token value from the JSON response.
- Generate a long-term API token.
curl -i -X POST "https://iot.thingslog.com:4443/api/api-token?expirationTimeHours=720&name=installer-demo-token" \
-H "Authorization: Bearer YOUR_KEYCLOAK_ACCESS_TOKEN"Use a shorter expiration for production if your security policy requires it. Rotate tokens before expiry, ideally at 80-90% of the token lifetime.
Copy .env.example to the local environment file for your chosen template:
cp .env.example .envFor Next.js use:
cp .env.example .env.localThen set:
THINGSLOG_MOCK=false
THINGSLOG_BASE_URL=https://iot.thingslog.com:4443
THINGSLOG_TOKEN=YOUR_API_TOKEN
THINGSLOG_DEVICE_NUMBER=YOUR_DEVICE_NUMBER
THINGSLOG_SENSOR_INDEX=0
THINGSLOG_FROM_DATE=2026-02-01T00:00:00+02:00
THINGSLOG_TO_DATE=2026-02-02T00:00:00+02:00Start the app. If the device number, sensor index, date range, and token are valid, you should see real ThingsLog counter and alarm data.
Help me connect this ThingsLog template to real ThingsLog data.
Read the README, AGENTS.md, and the token guide.
Check that ThingsLog credentials stay server-side.
Use THINGSLOG_TOKEN, THINGSLOG_DEVICE_NUMBER, THINGSLOG_SENSOR_INDEX, THINGSLOG_FROM_DATE, and THINGSLOG_TO_DATE from the environment.
Keep mock mode available.
After changes, run the build/check command and explain how to start the app.
I have a ThingsLog API token and want to start this template with real data.
Inspect the existing ThingsLog client and environment setup.
Keep the token server-side and preserve mock mode.
Tell me exactly which environment variables to set and which command to run.