Sponsored

Rivian API

agame32

Well-Known Member
First Name
Aaron
Joined
Oct 19, 2021
Threads
6
Messages
243
Reaction score
237
Location
CA
Vehicles
R1T, Model Y
What’s the latest on Rivian API capabilities?

With new features to set charging schedule and amperage in the vehicle/app, I’d love to get to a point where I use my home’s SolarEdge API to read production and then drive Rivian charging characteristics so that I’m only charging below a certain threshold of total production.

Eg: whenever solar production is >= 4kWh, then start Rivian charging at 12amps (~3kWh).
 

AdamUCF

Well-Known Member
First Name
Adam
Joined
Apr 3, 2022
Threads
13
Messages
299
Reaction score
434
Location
Orlando, FL
Vehicles
June 2022 R1T
What’s the latest on Rivian API capabilities?

With new features to set charging schedule and amperage in the vehicle/app, I’d love to get to a point where I use my home’s SolarEdge API to read production and then drive Rivian charging characteristics so that I’m only charging below a certain threshold of total production.

Eg: whenever solar production is >= 4kWh, then start Rivian charging at 12amps (~3kWh).
Here's the command to set the charge schedule... All this of course is with the appropriate auth headers.
Code:
POST https://rivian.com/api/gql/gateway/graphql HTTP/1.1

{
    "operationName": "SetChargingSchedule",
    "variables": {
        "vehicleId": "01-123456789",
        "chargingSchedules": [{
            "weekDays": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
            "startTime": 1320,
            "duration": 360,
            "location": {
                "latitude": 40.50505677290137,
                "longitude": -89.05740992302492
            },
            "amperage": 44,
            "enabled": true
        }]
    },
    "query": "mutation SetChargingSchedule($vehicleId: String!, $chargingSchedules: [InputChargingSchedule!]!) { setChargingSchedules(vehicleId: $vehicleId, chargingSchedules: $chargingSchedules) { success } }"
}
Response to that is just...
{"data":{"setChargingSchedules":{"success":true}}}

Then getting a charge schedule...
Code:
POST https://rivian.com/api/gql/gateway/graphql HTTP/1.1

{
    "operationName": "GetChargingSchedule",
    "variables": {
        "vehicleId": "01-123456789"
    },
    "query": "query GetChargingSchedule($vehicleId: String!) { getVehicle(id: $vehicleId) { chargingSchedules { startTime duration location { latitude longitude } amperage enabled weekDays } } }"
}
Response to that looks like...
Code:
{
    "data": {
        "getVehicle": {
            "chargingSchedules": [{
                "startTime": 1320,
                "duration": 360,
                "location": {
                    "latitude": 40.50505677290137,
                    "longitude": -89.05740992302492
                },
                "amperage": 44,
                "enabled": true,
                "weekDays": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
            }]
        }
    }
}
 

Tony R1S

Well-Known Member
First Name
Tony
Joined
Mar 1, 2022
Threads
15
Messages
179
Reaction score
98
Location
San Jose
Vehicles
Pacifica Hybrid, R1S QM 21
Here's the command to set the charge schedule... All this of course is with the appropriate auth headers.
Code:
POST https://rivian.com/api/gql/gateway/graphql HTTP/1.1

{
    "operationName": "SetChargingSchedule",
    "variables": {
        "vehicleId": "01-123456789",
        "chargingSchedules": [{
            "weekDays": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
            "startTime": 1320,
            "duration": 360,
            "location": {
                "latitude": 40.50505677290137,
                "longitude": -89.05740992302492
            },
            "amperage": 44,
            "enabled": true
        }]
    },
    "query": "mutation SetChargingSchedule($vehicleId: String!, $chargingSchedules: [InputChargingSchedule!]!) { setChargingSchedules(vehicleId: $vehicleId, chargingSchedules: $chargingSchedules) { success } }"
}
Response to that is just...
{"data":{"setChargingSchedules":{"success":true}}}

Then getting a charge schedule...
Code:
POST https://rivian.com/api/gql/gateway/graphql HTTP/1.1

{
    "operationName": "GetChargingSchedule",
    "variables": {
        "vehicleId": "01-123456789"
    },
    "query": "query GetChargingSchedule($vehicleId: String!) { getVehicle(id: $vehicleId) { chargingSchedules { startTime duration location { latitude longitude } amperage enabled weekDays } } }"
}
Response to that looks like...
Code:
{
    "data": {
        "getVehicle": {
            "chargingSchedules": [{
                "startTime": 1320,
                "duration": 360,
                "location": {
                    "latitude": 40.50505677290137,
                    "longitude": -89.05740992302492
                },
                "amperage": 44,
                "enabled": true,
                "weekDays": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
            }]
        }
    }
}
Does this scheduling require the use of the Rivian wall charger or can work with 3rd party chargers?
 

Sponsored

the_mace

Well-Known Member
First Name
Rob
Joined
Apr 8, 2022
Threads
10
Messages
366
Reaction score
302
Location
Boston, MA
Vehicles
Tesla Model S75D, Ford F350 Diesel, Mercedes GLC30
Occupation
CTO
There are some endpoints like these:

GetChargingSessionStatus
getLiveSessionHistory
getLiveSessionData

That return valid data but the data is not "live"

In the app, I get live data of the nature these endpoints return but when calling via API I get stale data.

i.e I just started charging but I get this for getLiveSessionData:

JSON:
{'data': {'getLiveSessionData': {'isRivianCharger': False, 'isFreeSession': False, 'vehicleChargerState': {'value': 'charging_active', 'updatedAt': '2023-06-08T01:49:28.899Z'}, 'chargerId': 'USCPIL13538041', 'startTime': '2023-06-08T01:49:28.88888Z', 'timeElapsed': '68051', 'timeRemaining': None, 'kilometersChargedPerHour': None, 'power': None, 'rangeAddedThisSession': None, 'totalChargedEnergy': None, 'currentPrice': 0}}}
That's the session from last night, not the one now.

Does anyone know why or how the App is getting current/live session data? I dont see any other endpoints used in the App that could do that.
 

the_mace

Well-Known Member
First Name
Rob
Joined
Apr 8, 2022
Threads
10
Messages
366
Reaction score
302
Location
Boston, MA
Vehicles
Tesla Model S75D, Ford F350 Diesel, Mercedes GLC30
Occupation
CTO
Also this one is odd:

GetChargingSessionStatus

It wants a JobId and a UserId but not sure where a JobId comes from. Its not returned in any calls I know of.
 

the_mace

Well-Known Member
First Name
Rob
Joined
Apr 8, 2022
Threads
10
Messages
366
Reaction score
302
Location
Boston, MA
Vehicles
Tesla Model S75D, Ford F350 Diesel, Mercedes GLC30
Occupation
CTO
Anyway I have a PR in for the docs and the python API/CLI has been updated in Github
 

the_mace

Well-Known Member
First Name
Rob
Joined
Apr 8, 2022
Threads
10
Messages
366
Reaction score
302
Location
Boston, MA
Vehicles
Tesla Model S75D, Ford F350 Diesel, Mercedes GLC30
Occupation
CTO
Nevermind on the getLiveSessionData, I had to adjust the call then it worked:

Code:
bin/rivian_cli --live_charging_session         
Battery Level: 78.9%
Range: 230.0 mi
Battery Limit: 85.0%
Charging state: charging_active
Charger status: chrgr_sts_connected_charging
Charging Active: True
Charging Updated: 06/08/2023, 19:10PM EDT
Charge Start: 06/08/2023, 16:03PM EDT
Elapsed Time: 3 hours, 6 minutes, 44 seconds
Remaining Time: 0 hours, 54 minutes, 34 seconds
Charge power: 9 kW
Charge rate: 18.0 mph
Range added: 61.5 mi
Total charged energy: 27 kW
 
Last edited:

poldim

Member
Joined
Jun 22, 2021
Threads
3
Messages
23
Reaction score
6
Location
San Francisco
Vehicles
R1S
What’s the latest on Rivian API capabilities?

With new features to set charging schedule and amperage in the vehicle/app, I’d love to get to a point where I use my home’s SolarEdge API to read production and then drive Rivian charging characteristics so that I’m only charging below a certain threshold of total production.

Eg: whenever solar production is >= 4kWh, then start Rivian charging at 12amps (~3kWh).
I'd love this functionality. I've got a tiny solar system now, but with the new R1S, I need to expand it to cover the significantly increased usage. At that point, it would be great to automate pushing power into the R1S battery rather than the grid.

I just added an FR to the integration.
 

Sponsored

sillygoose

Active Member
First Name
Rick
Joined
May 22, 2021
Threads
3
Messages
44
Reaction score
35
Location
Finger Lakes, NY
Vehicles
2023 R1S, 2022 Mustang Mach-E GT
Now an owner of an R1S and would like to add support for trip logging to an iOS app I wrote for my Mustang Mach-E (after missing the TeslaFi views that I had when I owned a TM3).

The viewing app for trips looks like this:

Rivian R1T R1S Rivian API 1686716232663


The Trip Overview (left side) shows the trips logged in the selected period along with some useful statistics. The Trip Detail (right side) just drills into the details of a specific trip.

On the Mach-E I pull the data from the OBDII connector via a Bluetooth scan tool so I can observe the gear selector and do everything automatically. On the R1S it looks like I need to use the Rivian API to grab vehicle state at the beginning and end of a trip but most of the important data is there (VIN, odometer, SoC, and the phone provides the GPS data.

I know nothing about REST or GraphQL but I see plenty of Python examples pulling the vehicle state from the API so it shouldn't be too hard to do in Swift with the Apollo iOS client and integrate the R1S into my vehicle logging.

If anyone knows of any iOS/Swift resources or a Rivian API schema file it might jump start things (I normally do this sort of stuff in the winter months). I have all the other code necessary to make it happen, just need to sort out the API for access to the vehicle data.
 

jrgutier

Member
First Name
Jose
Joined
Apr 4, 2022
Threads
0
Messages
21
Reaction score
16
Location
Oklahoma City, OK
Vehicles
Rivian R1T
Clubs
 
Now an owner of an R1S and would like to add support for trip logging to an iOS app I wrote for my Mustang Mach-E (after missing the TeslaFi views that I had when I owned a TM3).

The viewing app for trips looks like this:

1686716232663.png


The Trip Overview (left side) shows the trips logged in the selected period along with some useful statistics. The Trip Detail (right side) just drills into the details of a specific trip.

On the Mach-E I pull the data from the OBDII connector via a Bluetooth scan tool so I can observe the gear selector and do everything automatically. On the R1S it looks like I need to use the Rivian API to grab vehicle state at the beginning and end of a trip but most of the important data is there (VIN, odometer, SoC, and the phone provides the GPS data.

I know nothing about REST or GraphQL but I see plenty of Python examples pulling the vehicle state from the API so it shouldn't be too hard to do in Swift with the Apollo iOS client and integrate the R1S into my vehicle logging.

If anyone knows of any iOS/Swift resources or a Rivian API schema file it might jump start things (I normally do this sort of stuff in the winter months). I have all the other code necessary to make it happen, just need to sort out the API for access to the vehicle data.
https://rivian-api.kaedenb.org/
https://github.com/the-mace/rivian-python-api
https://github.com/bretterer/rivian-python-client
 

sillygoose

Active Member
First Name
Rick
Joined
May 22, 2021
Threads
3
Messages
44
Reaction score
35
Location
Finger Lakes, NY
Vehicles
2023 R1S, 2022 Mustang Mach-E GT
Thanks but already aware of these repos but none help me out with iOS and Swift.

But after spending some time with the Apollo GraphQL iOS client tutorial I'm thinking maybe I should just port the @the_mace Python code using the Swift version of the Python requests library. I only need limited vehicle state and authentication so will be a shorter learning curve.
 

sillygoose

Active Member
First Name
Rick
Joined
May 22, 2021
Threads
3
Messages
44
Reaction score
35
Location
Finger Lakes, NY
Vehicles
2023 R1S, 2022 Mustang Mach-E GT
I'm in, nice of Swift Playgrounds to let you prototype asynchronous code (and studying the Python code in the @the_mace repo):

Rivian R1T R1S Rivian API 1687102006595


The plan is to make a Rivian-specific recording app from the existing Mach-E version. I can hit up the Rivian API at the start and end of a trip so I know the distance and the beginning and ending SoC but there is a lot not in the API vehicle state so it will be educated guesses for the energy used and the trip efficiency.
 
Last edited:

poldim

Member
Joined
Jun 22, 2021
Threads
3
Messages
23
Reaction score
6
Location
San Francisco
Vehicles
R1S
Somewhat unrelated, but is the API to see the Rivian public charge in use/available state publicly available?
Sponsored

 
 




Top