Sponsored

Rivian API

sub

Well-Known Member
Joined
Jul 23, 2021
Threads
33
Messages
1,872
Reaction score
3,304
Location
USA
Vehicles
Rivian R1S, Tesla Model 3
So are you still getting real data? I can't think of what I might be doing wrong to get a bunch of Null. Wondered if that part of the API might have changed with the Release of app V2.0.



Here is what I am POSTing.

{
host: 'rivian.com',
port: '443',
path: '/api/gql/chrg/user/graphql',
method: 'POST',
headers: {
'User-Agent': 'RivianApp/1304 CFNetwork/1404.0.5 Darwin/22.3.0',
Accept: 'application/json',
'Content-Type': 'application/json',
'Apollographql-Client-Name': 'com.rivian.ios.consumer-apollo-ios',
'a-sess': <redacted>,
'csrf-token': <redacted>,
'u-sess': <redacted>
}
}

{"operationName":"getLiveSessionData","variables":{"vehicleID":<redacted>},"query":"query getLiveSessionData($vehicleId: ID) { getLiveSessionData(vehicleId: $vehicleId) { isRivianCharger isFreeSession vehicleChargerState { __typename value updatedAt } chargerId startTime timeElapsed timeRemaining { value updatedAt } kilometersChargedPerHour { value updatedAt } power { value updatedAt } rangeAddedThisSession { value updatedAt } totalChargedEnergy { value updatedAt } timeRemaining { value updatedAt } vehicleChargerState { value updatedAt } kilometersChargedPerHour { value updatedAt } currentPrice } }"}

The redacted tokens and vehicle ID works when I ask for info from /api/gql/gateway/graphql. But I can't get anything but null from /api/gql/chrg/user/graphql
Sponsored

 

the_mace

Well-Known Member
First Name
Rob
Joined
Apr 8, 2022
Threads
11
Messages
414
Reaction score
343
Location
Boston, MA
Vehicles
Tesla Model S75D, Ford F350 Diesel, Mercedes GLC30
Occupation
CTO
So are you still getting real data? I can't think of what I might be doing wrong to get a bunch of Null. Wondered if that part of the API might have changed with the Release of app V2.0.



Here is what I am POSTing.

{
host: 'rivian.com',
port: '443',
path: '/api/gql/chrg/user/graphql',
method: 'POST',
headers: {
'User-Agent': 'RivianApp/1304 CFNetwork/1404.0.5 Darwin/22.3.0',
Accept: 'application/json',
'Content-Type': 'application/json',
'Apollographql-Client-Name': 'com.rivian.ios.consumer-apollo-ios',
'a-sess': <redacted>,
'csrf-token': <redacted>,
'u-sess': <redacted>
}
}

{"operationName":"getLiveSessionData","variables":{"vehicleID":<redacted>},"query":"query getLiveSessionData($vehicleId: ID) { getLiveSessionData(vehicleId: $vehicleId) { isRivianCharger isFreeSession vehicleChargerState { __typename value updatedAt } chargerId startTime timeElapsed timeRemaining { value updatedAt } kilometersChargedPerHour { value updatedAt } power { value updatedAt } rangeAddedThisSession { value updatedAt } totalChargedEnergy { value updatedAt } timeRemaining { value updatedAt } vehicleChargerState { value updatedAt } kilometersChargedPerHour { value updatedAt } currentPrice } }"}

The redacted tokens and vehicle ID works when I ask for info from /api/gql/gateway/graphql. But I can't get anything but null from /api/gql/chrg/user/graphql
Im not currently plugged in but this is what I get right now
JSON:
{'data': {'getLiveSessionData': {'isRivianCharger': None, 'isFreeSession': None, 'vehicleChargerState': {'value': 'charging_ready', 'updatedAt': '2023-08-04T19:35:05.925Z'}, 'chargerId': None, 'startTime': None, 'timeElapsed': None, 'timeRemaining': None, 'kilometersChargedPerHour': {'value': 0, 'updatedAt': '2023-08-04T13:09:14.92Z'}, 'power': {'value': 0, 'updatedAt': '2023-08-04T19:35:05.925Z'}, 'rangeAddedThisSession': {'value': 102, 'updatedAt': '2023-08-04T13:09:14.92Z'}, 'totalChargedEnergy': {'value': 29, 'updatedAt': '2023-08-04T19:35:05.925Z'}, 'currentPrice': None}}}
 
  • Like
Reactions: sub

sub

Well-Known Member
Joined
Jul 23, 2021
Threads
33
Messages
1,872
Reaction score
3,304
Location
USA
Vehicles
Rivian R1S, Tesla Model 3
Im not currently plugged in but this is what I get right now
JSON:
{'data': {'getLiveSessionData': {'isRivianCharger': None, 'isFreeSession': None, 'vehicleChargerState': {'value': 'charging_ready', 'updatedAt': '2023-08-04T19:35:05.925Z'}, 'chargerId': None, 'startTime': None, 'timeElapsed': None, 'timeRemaining': None, 'kilometersChargedPerHour': {'value': 0, 'updatedAt': '2023-08-04T13:09:14.92Z'}, 'power': {'value': 0, 'updatedAt': '2023-08-04T19:35:05.925Z'}, 'rangeAddedThisSession': {'value': 102, 'updatedAt': '2023-08-04T13:09:14.92Z'}, 'totalChargedEnergy': {'value': 29, 'updatedAt': '2023-08-04T19:35:05.925Z'}, 'currentPrice': None}}}
Thanks for confirming it should work. It is what I needed to keep pushing. I figured out my problem.

In case anyone else has problems with one query working but not another:

/api/gql/gateway/graphql needs you to send it a vehicleID
/api/gql/chrg/user/graphql needs you to send it a vehicleId


Rivian - can you please pick one capitalization scheme and stick with it?
 

the_mace

Well-Known Member
First Name
Rob
Joined
Apr 8, 2022
Threads
11
Messages
414
Reaction score
343
Location
Boston, MA
Vehicles
Tesla Model S75D, Ford F350 Diesel, Mercedes GLC30
Occupation
CTO
Thanks for confirming it should work. It is what I needed to keep pushing. I figured out my problem.

In case anyone else has problems with one query working but not another:

/api/gql/gateway/graphql needs you to send it a vehicleID
/api/gql/chrg/user/graphql needs you to send it a vehicleId


Rivian - can you please pick one capitalization scheme and stick with it?
In case its helpful here's the query:
https://github.com/the-mace/rivian-...add6/src/rivian_python_api/rivian_api.py#L579
 
  • Like
Reactions: sub

sub

Well-Known Member
Joined
Jul 23, 2021
Threads
33
Messages
1,872
Reaction score
3,304
Location
USA
Vehicles
Rivian R1S, Tesla Model 3
Found another one in vehicleState. Units seem to be m/s. I had cruise control set to 55mph. 24m/s = 53.6 mph.

Code:
        "gnssSpeed": {
          "__typename": "TimeStampedFloat",
          "timeStamp": "2023-08-05T01:28:29.036Z",
          "value": 23.968
        },

Also, I haven't found anything new in getLiveSessionData, but if there is anything hiding in there, it is going to be so much easier to find. vehicleState just says "Error in GraphQL validation" when you try something that doesn't exist. getLiveSessionData outputs things like this:

"message": "Cannot query field \"chargedEnergy\" on type \"LiveSessionData\". Did you mean \"totalChargedEnergy\" or \"chargerId\"?",
 
Last edited:

Sponsored

sub

Well-Known Member
Joined
Jul 23, 2021
Threads
33
Messages
1,872
Reaction score
3,304
Location
USA
Vehicles
Rivian R1S, Tesla Model 3
I found a few new fields in getLiveSessionData

Code:
        "currentCurrency": null,

        "soc": {
          "__typename": "FloatValueRecord",
          "value": 79.400002,
          "updatedAt": "2023-08-05T14:10:00.107Z"
        },

        "currentMiles": {
          "__typename": "FloatValueRecord",
          "value": 378,
          "updatedAt": "2023-08-05T13:49:51.087Z"
        },

        "current": {
          "__typename": "FloatValueRecord",
          "value": 0,
          "updatedAt": "2023-08-05T14:07:34.597Z"
        },
 

the_mace

Well-Known Member
First Name
Rob
Joined
Apr 8, 2022
Threads
11
Messages
414
Reaction score
343
Location
Boston, MA
Vehicles
Tesla Model S75D, Ford F350 Diesel, Mercedes GLC30
Occupation
CTO
I found a few new fields in getLiveSessionData

Code:
        "currentCurrency": null,

        "soc": {
          "__typename": "FloatValueRecord",
          "value": 79.400002,
          "updatedAt": "2023-08-05T14:10:00.107Z"
        },

        "currentMiles": {
          "__typename": "FloatValueRecord",
          "value": 378,
          "updatedAt": "2023-08-05T13:49:51.087Z"
        },

        "current": {
          "__typename": "FloatValueRecord",
          "value": 0,
          "updatedAt": "2023-08-05T14:07:34.597Z"
        },
Just a caution on some of these parameter names:

Code:
{'data': {'getLiveSessionData': {'isRivianCharger': None, 'isFreeSession': None, 'vehicleChargerState': {'value': 'charging_ready', 'updatedAt': '2023-08-06T11:44:19.999Z'}, 'chargerId': None, 'startTime': None, 'timeElapsed': None, 'timeRemaining': None, 'kilometersChargedPerHour': {'value': 0, 'updatedAt': '2023-08-05T10:45:27.911Z'}, 'power': {'value': 0, 'updatedAt': '2023-08-06T11:44:19.999Z'}, 'rangeAddedThisSession': {'value': 88, 'updatedAt': '2023-08-05T10:45:27.911Z'}, 'totalChargedEnergy': {'value': 25, 'updatedAt': '2023-08-06T11:44:19.999Z'}, 'currentPrice': None, 'soc': {'value': 62.700001}, 'currentMiles': {'value': 294}, 'current': {'value': 0}}}}
My currentMiles from the above is 294 and my SOC is 62.7%. These numbers dont make sense if currentMiles is miles. currentMiles is actually current kM. The math there works for both the SOC and what the app actually says.

Also soc is also available in vehicleState under batteryLevel. There are a few things like that available in other areas.
 

mike22co

Well-Known Member
First Name
Mike
Joined
Aug 2, 2021
Threads
0
Messages
102
Reaction score
163
Location
Centennial, CO
Vehicles
Tesla Model 3, BMW X3 (x2), s00n R1S
Occupation
Person
I am so excited to be able to revisit this thread now that I have a vehicle to pick up tomorrow. I could even poll for the orders today and find the last charge session before pickup. Thanks for doing some of the legwork for all of us!
 

Dark-Fx

Well-Known Member
First Name
Brian
Joined
Jul 15, 2020
Threads
147
Messages
13,518
Reaction score
27,285
Location
Michigan
Vehicles
R1T, R1S, Livewire One, Sierra EV, R1S
Occupation
Engineering
Clubs
 
Without spending the time digging into this, are you guys finding that the "send to vehicle" stuff for navigation is being exposed anywhere? Just thought about doing an IFTTT routine to send google calendar events to the truck but don't have the time to dig right now.
 

jrgutier

Member
First Name
Jose
Joined
Apr 4, 2022
Threads
0
Messages
22
Reaction score
16
Location
Oklahoma City, OK
Vehicles
Rivian R1T
Clubs
 
Without spending the time digging into this, are you guys finding that the "send to vehicle" stuff for navigation is being exposed anywhere? Just thought about doing an IFTTT routine to send google calendar events to the truck but don't have the time to dig right now.
The Home Assistant team knows the API to send an address to the Rivian. I'm sure you'd be able to do Google Calendar to Rivian via HA if we ever implement it.
 

Sponsored

poldim

Active Member
Joined
Jun 22, 2021
Threads
4
Messages
42
Reaction score
17
Location
San Francisco
Vehicles
R1S
Can someone else confirm if getLiveSessionData or any of the other /chrg/user/ queries are still working for you? All I can get from any of the chrg/user queries is "null".
Just tried mine and it also came back as null:
Rivian R1T R1S Rivian API 1693864604886
 

MrMusAddict

Well-Known Member
Joined
Oct 29, 2022
Threads
42
Messages
323
Reaction score
890
Location
Oregon
Vehicles
2023 Rivian R1T
Occupation
Data Analyst
Sorry guys, total noob here when it comes to Python and calling APIs. I stumbled on this code from boardthatpowder.

Looking back a few pages, it sounds like there may have been something about the API that broke other code, so does anyone know if this code still works as written?

  • I've got Python 3.11.5 installed, and PIP 23.2.1 installed as well.
  • Got the dependencies installed; pip3 install requests python-dotenv twilio
  • Made sure my credentials were entered in the .env file (and tried single & double quotes).
  • Also tried renaming the .env file, and filling out the full file name in conf = dotenv_values([filename])

No matter what, I get this error when I run main.py

Rivian R1T R1S Rivian API 1695056543313
 

the_mace

Well-Known Member
First Name
Rob
Joined
Apr 8, 2022
Threads
11
Messages
414
Reaction score
343
Location
Boston, MA
Vehicles
Tesla Model S75D, Ford F350 Diesel, Mercedes GLC30
Occupation
CTO
Sorry guys, total noob here when it comes to Python and calling APIs. I stumbled on this code from boardthatpowder.

Looking back a few pages, it sounds like there may have been something about the API that broke other code, so does anyone know if this code still works as written?

  • I've got Python 3.11.5 installed, and PIP 23.2.1 installed as well.
  • Got the dependencies installed; pip3 install requests python-dotenv twilio
  • Made sure my credentials were entered in the .env file (and tried single & double quotes).
  • Also tried renaming the .env file, and filling out the full file name in conf = dotenv_values([filename])

No matter what, I get this error when I run main.py

1695056543313.png
If you’re using python there’s an open source rivian api I created here:
https://github.com/the-mace/rivian-python-api
 

Rivee

Member
First Name
K
Joined
Sep 29, 2023
Threads
0
Messages
12
Reaction score
2
Location
NJ
Vehicles
Rivian R1S LE Silver
For those not as tech savvy but still like data, can try ElectraFi from makers of TeslaFi. They have 2 month free trial at moment, plus get another 2 weeks free using referral link below....

https://www.electrafi.com/signupRivian.php?referred=Rivian (capital "R" if entering code "Rivian" manually)
 
Last edited:

Jiji

Well-Known Member
First Name
Rick
Joined
Jun 21, 2023
Threads
17
Messages
296
Reaction score
430
Location
Finger Lakes, NY
Website
github.com
Vehicles
Rivian Blue R1S
Anyone else notice that Rivian improved the accuracy of the reported power during charging?

I used to see just integer values returned but I am getting tenths of kilowatts, not a big deal when using a DCFC charger, it is nice when on a level 2 charger.
Sponsored

 
  • Like
Reactions: sub
 








Top