Retrieving and sending data to your VOLVO using an API connection.

As you may know, I'm very passionate about cars and IT. This article combines these two passions by retrieving actual data from my car through an API connection.

Retrieving and sending data to your VOLVO using an API connection.

1. Get an API key and access token

As you may know, I'm very passionate about cars and IT. This article combines these two passions by retrieving actual data from my car through an API connection.

To follow this tutorial, you'll need a Volvo with an activated Volvo On Call subscription.

Now head over to the Volvo Developer website: https://developer.volvocars.com and create an account. It's easy to log in with a Google account.

After logging in, we'll need to create an application. Follow this link to do so: https://developer.volvocars.com/account/#your-api-applications

Give your application a name and press "Create":

Now, your application has been created. Its name should pop up on your screen. Click on it and copy the primary API key. This is an important key you should never share with anyone else.

Now head over to this page: https://developer.volvocars.com/apis/docs/test-access-tokens/ Go to the section "My Volvo car" and select the Connected Vehicle API from the list. Then authorize your car by following the log-in prompt.

Log in with the Volvo Key and copy the access token. This will be valid for 60 minutes and can only be viewed once. Store it somewhere where you'll easily be able to access it during this next hour.

2. Create an API request to retrieve your VIN number

After copying all these codes, open an API tool. I highly recommend Postman. In Postman, create a new HTTPS request for your Volvo API requests:

The first request we'll need to build is one to get our VIN number. This is required for all further requests. So please store this as well. We'll need to do a few steps to build the initial requests. Start off by copying and pasting this URL in the upper bar in Postman: https://api.volvocars.com/connected-vehicle/v1/vehicles

Then go to the "Authorization" tab, select "Bearer token" and paste your access token:

Now go to the "Headers" tab. Create a new header line and name the key "VCC-API-KEY". Paste your application API key behind it in the value section. Then press send. This was your first successful API request to retrieve data from Volvo, Congratulations! Copy the VIN code that pops up. I've blurred part of mine for privacy reasons.

3. API Requests to retrieve climate data and more

We'll now try to get some data from our actual vehicle, like the current temperature outside of it. Head over to this page if you want to see all possible API endpoints/requests you can make for climate.

Let's start by saving our current request to retrieve the VIN number. Do so by clicking save in the upper right corner:

Create a new collection with any name you'd like and save it there:

Then duplicate your request:

Paste the following URL in your request bar:

https://api.volvocars.com/connected-vehicle/v1/vehicles/{vin}/environment

Replace VIN with your actual VIN Number. Send the request and voila, there's the current outside temperature of your vehicle. It's currently summer in the Netherlands and quite hot, so my request returned 32 degrees celsius.

Let's make another request. My driver-side window is currently open to ventilate a bit. Let's see if the API returns this correctly. I do so by sending a request to: https://api.volvocars.com/connected-vehicle/v1/vehicles/{VIN}/windows

4. Let the light flash

As you can see, this worked properly. Let's take one step further and send an actual order to our car like flashing the lights a few times. Use this URL: https://api.volvocars.com/connected-vehicle/v1/vehicles/{VIN}/commands/flash and go to the "Headers" tab in Postman. Add a new line with the key "Content-Type" and value "application/vnd.volvocars.api.connected-vehicle.flash.v1+json". Now send a POST request and take a look at your car. It flashed within 20 seconds when I tested this:

If you'd like to see more API endpoints (requests you can send), look at the official documentation here: https://developer.volvocars.com/apis/connected-vehicle/v1/endpoints/lights-sound/