A Swift implementation of the TESLASCOPE API for usage on Apple platforms.
This library is built using async
await
syntax.
// init the vehicle api
let swiftScope = SwiftScope()
swiftScope.setApiKey("yourapikey")
// init (if needed) the teslapedia api (software versions)
let teslapedia = Teslapedia()
Get details about a vehicle and it's driving/charging sessions.
let vehicle: BasicVehicle = try await swiftScope.getBasicVehicle(vehicleId: "corsair")
let state = try await swiftScope.getBasicVehicleState(vehicleId: "corsair")
This data is paginated, after requesting without parameters you can retrieve the nextPage
and prevPage
properties.
let drives: PaginatedJsonResponse<DrivingSession> = try await swiftScope.getDrivingSessions(vehicleId: "corsair")
let charges: PaginatedJsonResponse<ChargingSession> = try await swiftScope.getChargingSessions(vehicleId: "corsair")
print(drives.currentPage) // will print the current page index
print(drives.nextPage) // will print the next page index
print(drives.prevPage) // will print the previous page index
// request the next page
let moreDrives: PaginatedJsonResponse<DrivingSession> = try await swiftScope.getDrivingSessions(vehicleId: "corsair", page: drives.nextPage)
Get a list of known software updates and their feature lists.
let softwareVersions: [String] = try await teslapedia.getSoftwareVersions()