A client that can be used to call the Volkswagen Car-Net API via the We Connect portal. Since Volkswagen does not yet provide an open API, this module can be used as a workaround.
NOTE: This library will break when Volkswagen changes their We Connect/Car-Net portal.
To login and get valid session cookies, puppeteer is used. The library can be used with either puppeteer or puppeteer-core.
Here is an example where this library is used in a REST API on a AWS Lambda.
# install puppeteer
npm i puppeteer -S
# (or puppeteer-core)
# npm i puppeteer-core -S
npm i node-vw-carnet -S
The main
function in all examples below are called like this:
main()
.then(() => process.exit(0))
.catch(err => {
console.log('ERROR!', err);
process.exit(1);
});
It takes a long time to log in (normally around 5-20 seconds). The reason is that the We-Connect portal takes some time to respond. Once the login is complete, you can save the CarnetAPIClient
instance (or information) and call the Car-Net API directly (this is done with node-fetch) and the responses from these calls are usually quick.
import puppeteer from 'puppeteer';
import CarnetLoginHandler from 'node-vw-carnet';
async function main() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Create the puppeteer login client by sending in
// the puppeteer.Page (and a optional logger, can be skipped).
const handler = new CarnetLoginHandler(page, console);
// Try to login with your username and password.
// The login will take ~10 seconds...
const client = await handler.createClient({
email: process.env.EMAIL, // your carnet email
password: process.env.PASS // your carnet password
});
// Close chrome browser since it's not needed anymore.
await browser.close();
// Successful login, now use the client.
// Get car details.
const details = await client.loadCarDetails();
console.log('car details:', details);
// Start the climate heater.
const response = await client.triggerClimatisation(true);
console.log('response:', response);
}
import puppeteer from 'puppeteer-core';
import CarnetLoginHandler from 'node-vw-carnet';
async function main() {
const browser = await puppeteer.launch({
executablePath: '<path to chrome>' // /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
});
// ...
}
The following methods are available on the CarnetAPIClient
. All methods
returns Promise<CarNetJSONResponse>
interface CarNetJSONRespose {
[x: string]: any;
// If errorCode is '0' the request was successfull
errorCode: string;
}
getLocation()
getFullyLoadedCars()
getCompleteVehicleJson()
loadCarDetails()
triggerClimatisation(on: boolean)
triggerWindowheating()
getPSPStatus()
getVehicleDetails()
getVehicleStatusReport()
getLatestReport()
getEmanager()
getLatestTripStatistics()
// Can be used if this library have missed a certain method.
triggerAction(url, body = null)
# clone this repo
git clone https://github.com/nekman/node-vw-carnet.git
# install dependencies
npm i
# lint
npm run eslint
# manual test
EMAIL=<your carnet email> PASS=<your carnet pass> npm run manual:test
A: Easier to login to the We Connect Portal. I can of course do like other libraries and perform all required login steps, but next time Volkswagen changes their We Connect portal a new time consuming login procedure needs to be implemented. Changes will be easier to handle with Puppeteer.