node-vw-carnet
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.
Example
Here is an example where this library is used in a REST API on a AWS Lambda.
Installation
# install puppeteer npm i puppeteer -S # (or puppeteer-core) # npm i puppeteer-core -S npm i node-vw-carnet -S
Usage
The main
function in all examples below are called like this:
;
Login
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.
With puppeteer
;; { const browser = await puppeteer; const page = await browser; // Create the puppeteer login client by sending in // the puppeteer.Page (and a optional logger, can be skipped). const handler = page console; // Try to login with your username and password. // The login will take ~10 seconds... const client = await handler; // Close chrome browser since it's not needed anymore. await browser; // Successful login, now use the client. // Get car details. const details = await client; console; // Start the climate heater. const response = await client; console;}
With puppeteer-core
;; { const browser = await puppeteer; // ...}
Available client methods
The following methods are available on the CarnetAPIClient
. All methods
returns Promise<CarNetJSONResponse>
getLocationgetFullyLoadedCarsgetCompleteVehicleJsonloadCarDetailstriggerClimatisationon: booleantriggerWindowheatinggetPSPStatusgetVehicleDetailsgetVehicleStatusReportgetLatestReportgetEmanagergetLatestTripStatistics// Can be used if this library have missed a certain method.triggerActionurl, body = null
Building
# 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
Q: Why puppeteer?
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.