Skip to content

Instantly share code, notes, and snippets.

@AnttiKurittu
Created December 1, 2022 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnttiKurittu/f6c4b6e0c47d9cd67ff0da82296eef1a to your computer and use it in GitHub Desktop.
Save AnttiKurittu/f6c4b6e0c47d9cd67ff0da82296eef1a to your computer and use it in GitHub Desktop.
Python script to request data from Wallbox API
#/usr/bin/python3
import requests
import json
def fetch_token():
payload = {}
url = "https://api.wall-box.com/auth/token/user"
headers = {
'Accept': 'application/json, text/plain, */*\'',
'Content-Type': 'application/json;charset=utf-8'
}
response = requests.request("GET", url, headers=headers, data=payload, auth=('your email address', 'your password'))
response_json = json.loads(response.text)
return str(response_json['jwt'])
def main():
payload = {}
url = "https://api.wall-box.com/v3/chargers/groups"
bearer_token = fetch_token()
headers = {
'Accept': 'application/json, text/plain, */*\'',
'Content-Type': 'application/json;charset=utf-8',
'Authorization': f'Bearer {bearer_token}'
}
response = requests.request("GET", url, headers=headers, data=payload)
chargers = json.loads(response.text)
print(json.dumps(chargers, indent=2))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment