If you are writing a personal Python script, Home Assistant integration, or Raspberry Pi automation, you can fetch your data directly without setting up a complex OAuth application.
Prerequisites
You do not need to generate API keys for this. You will use your standard iON email and password that you use to log into the consumer app.
The Script
Copy the Python script below. It uses our public DIY Client ID to automatically authenticate your account and fetch a 1-hour id_token to use for API requests.
Security Note: Because this script uses your real username and password,
it should only be used in secure, local environments (like your own Raspberry
Pi). Never put this script on a public web server.
import requests
# 1. Your iON Credentials
USERNAME = "your_email@example.com"
PASSWORD = "Your_Password_123!"
# iON's Public Client ID for DIY Scripts
CLIENT_ID = "69gs8v1eli5or9167l7t7t84ef"
# 2. Authenticate with AWS Cognito to get a token
print("Authenticating...")
auth_response = requests.post(
"https://cognito-idp.eu-central-1.amazonaws.com/",
headers={
"X-Amz-Target": "AWSCognitoIdentityProviderService.InitiateAuth",
"Content-Type": "application/x-amz-json-1.1"
},
json={
"AuthFlow": "USER_PASSWORD_AUTH",
"ClientId": CLIENT_ID,
"AuthParameters": {
"USERNAME": USERNAME,
"PASSWORD": PASSWORD
}
}
)
if auth_response.status_code != 200:
print("Login Failed:", auth_response.json())
exit()
# Extract the Token
id_token = auth_response.json()["AuthenticationResult"]["IdToken"]
print("Successfully obtained Bearer Token!")
# 3. Call the iON API
print("Fetching Telemetry Data...")
api_response = requests.get(
"https://api.ionelectricity.com/v1/telemetry",
headers={"Authorization": f"Bearer {id_token}"}
)
print(api_response.json())