This is an unofficial Porsche Connect API library written in Swift. The primary purpose for this library is to act as a building block for both mobile, desktop and serverside applications built around the Porsche Connect service.
You will require a My Porsche account to be able to make use of this library.
Absolutely not. These endpoints are a result of reverse engineering Porsche's web and mobile applications.
The library has a comprehensive suite of unit tests that run on GitHub Actions. Currently the test suite is run on a simulated Intel based macOS v12.1.
You can see the current build status of the main
branch here:
Porsche Connect requires Swift 5.5 or higher. It uses the new async/await concurrency language features introduced in Swift 5.5.
Currently the library supports the following platforms:
This library is availble on the Swift Package Index at https://swiftpackageindex.com/driven-app/porsche-connect.
Create an instance of the library:
let porscheConnect = PorscheConnect(username: "homer.simpson@icloud.example",
password: "Duh!")
Currently the following environments are supported:
A valid MyPorsche username (email) and password is required to use this library.
To get a list of vehicles associated with your My Porsche account . This call will return an array of Vehicle
structs, with nested VehicleAttribute
's and VehiclePicture
's as appropriate for the vehicles configuration.
try {
let result = porscheConnect.vehicles()
if let vehicles = result.vehicles, let response = result.response {
// Do something with vehicles or raw response
}
} catch {
// Handle the error
}
For example, to get the external Color (a SwiftUI struct) for the first car in your account:
try {
let result = porscheConnect.vehicles()
if let vehicles = result.vehicles {
let firstVehicle = vehicles.first!
let color: Color = firstVehicle.externalColor
}
} catch {
// Handle the error
}
To get a summary for a vehicle. This call will return a Summary
struct.
try {
let result = porscheConnect.summary(vehicle: vehicle)
if let summary = result.summary, let response = result.response {
// Do something with the summary or raw response
}
} catch {
// Handle the error
}
To get last reported position for a vehicle. This call will return a Position
struct.
try {
let result = porscheConnect.position(vehicle: vehicle)
if let position = result.position, let response = result.response {
// Do something with the position or raw response
}
} catch {
// Handle the error
}
To get capabilities for a vehicle. This call will return a Capabilities
struct. This struct has nested OnlineRemoteUpdateStatus
and HeatingCapabilities
structs as appropriate for the vehicle.
try {
let result = porscheConnect.capabilities(vehicle: vehicle)
if let capabilities = result.capabilities, let response = result.response {
// Do something with the capabilities or raw response
}
} catch {
// Handle the error
}
If the vehicle is a plug-in hybrid (PHEV) or a battery electric vehicle (BEV) this will return the status and configuration of the e-mobility aspects of the vehicle. This call requires both a vehicle and its matching capabilities. This call will return a Emobility
struct.
try {
let result = porscheConnect.emobility(vehicle: vehicle, capabilities: capabilities)
if let emobility = result.emobility, let response = result.response {
// Do something with the emobility or raw response
}
} catch {
// Handle the error
}
To run the test suite:
xcodebuild test -destination "platform=iOS Simulator,name=iPhone 12 mini" -scheme "PorscheConnect"
This is similar to the commands that are run in CI to test the library on each git commit. You can change the destinations to any of the libraries supported platforms.
The library is packaged with a command line utility to give a simple terminal access to the set of Porsche Connect services wrapped by this library.
From within the project directory, run:
swift build -c release
This will place the excutable in <project-dir>/.build/apple/Products/Release
folder, where it will be named porsche
. If you want to make it available more generally when using a terminal, copy it to /usr/local/bin
from the project dir:
cp -f .build/apple/Products/Release/porsche /usr/local/bin
If you would like to build a universal binary for both Intel (x86) and Apple (M1) Mac's then run the compiler with:
swift build -c release --arch arm64 --arch x86_64
To get help on the various commands available, call with --help
on either the overall command or any of the sub-commands:
$ porsche --help
OVERVIEW: A command-line tool to call and interact with Porsche Connect services
USAGE: porsche <subcommand>
OPTIONS:
--version Show the version.
-h, --help Show help information.
SUBCOMMANDS:
list-vehicles
show-summary
show-position
show-capabilities
show-emobility
See 'porsche help <subcommand>' for detailed help.
To get a list of all the vehicles associated with your My Porsche account:
$ porsche list-vehicles <username> <password>
#1 => Model: Taycan 4S; Year: 2021; Type: Y1ADB1; VIN: WP0ZZZXXXXXXXXXXX
To show the summary for a specific vehicle – the nickname is usually set to be the licenseplate of the car, but can be any value set by the owner:
$ porsche show-summary <username> <password> <vin>
Model Description: Taycan 4S; Nickname: 211-D-12345
To show the current position of a vehicle:
$ porsche show-position <username> <password> <vin>
Latitude: 53.395367; Longitude: -6.389296; Heading: 68
To show the capabilties of a vehicle:
$ porsche show-capabilities <username> <password> <vin>
Display parking brake: yes; Needs SPIN: yes; Has RDK: yes; Engine Type: BEV; Car Model: J1; Front Seat Heating: yes; Rear Seat Heating: no; Steering Wheel Position: RIGHT; Honk & Flash: yes
To show the emobility of a vehicle:
(Note: this only displays a small subset of the information that the emobility service returns)
$ porsche show-emobility <username> <password> <vin>
Battery Level: 53%; Remaining Range: 180 KM; Charging Status: NOT_CHARGING; Plug Status: DISCONNECTED
To do this, add the repo to Package.swift
, like this:
import PackageDescription
let package = Package(
name: "PorscheConnect",
dependencies: [
.package(url: "git@github.com:driven-app/porsche-connect.git",
from: "0.1"),
]
)
link |
Stars: 12 |
Last commit: 2 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics