{"id":15037296,"url":"https://github.com/hamblinsoft/teslakit","last_synced_at":"2025-04-09T23:24:17.415Z","repository":{"id":56923901,"uuid":"113019402","full_name":"HamblinSoft/TeslaKit","owner":"HamblinSoft","description":"Elegant Tesla API in Swift","archived":false,"fork":false,"pushed_at":"2020-06-24T10:04:10.000Z","size":39140,"stargazers_count":49,"open_issues_count":2,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-07T09:46:36.330Z","etag":null,"topics":["ios","ios-lib","model","models","modelx","swift","swift3","swift4","tesla","tesla-api","teslaapi","teslakit","teslamotors"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HamblinSoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-04T09:00:57.000Z","updated_at":"2025-02-07T12:10:02.000Z","dependencies_parsed_at":"2022-08-21T05:20:27.304Z","dependency_job_id":null,"html_url":"https://github.com/HamblinSoft/TeslaKit","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HamblinSoft%2FTeslaKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HamblinSoft%2FTeslaKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HamblinSoft%2FTeslaKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HamblinSoft%2FTeslaKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HamblinSoft","download_url":"https://codeload.github.com/HamblinSoft/TeslaKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248127150,"owners_count":21052195,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","ios-lib","model","models","modelx","swift","swift3","swift4","tesla","tesla-api","teslaapi","teslakit","teslamotors"],"created_at":"2024-09-24T20:34:12.426Z","updated_at":"2025-04-09T23:24:17.386Z","avatar_url":"https://github.com/HamblinSoft.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TeslaKit\n\n[![Platform](https://img.shields.io/badge/platform-iOS%20%7C%20macOS%20%7C%20watchOS%20%7C%20tvOS-lightgrey.svg?style=flat)](https://github.com/Jarious-Apps/TeslaKit)\n[![Cocoapods compatible](https://img.shields.io/badge/Cocoapods-compatible-4BC51D.svg?style=flat)](https://github.com/CocoaPods/CocoaPods)\n[![Version](https://img.shields.io/cocoapods/v/TeslaKit.svg?style=flat)](http://cocoapods.org/pods/TeslaKit)\n[![License](https://img.shields.io/cocoapods/l/TeslaKit.svg?style=flat)](http://cocoapods.org/pods/TeslaKit)\n[![Language](https://img.shields.io/badge/language-Swift%204-E05C43.svg?style=flat)](https://swift.org)\n[![Twitter](https://img.shields.io/badge/twitter-@JJJJaren-00ACED.svg?style=flat)](http://twitter.com/jjjjaren)\n\n\nTeslaKit is a framework written in Swift that makes it easy for you to interface with Tesla's mobile API and communicate with your Tesla automobiles.\n\n# Features\n- [x] Authenticate with Tesla's API to obtain an access token\n- [x] Retrieve a list of vehicles associated with your Tesla account\n- [x] Obtain all data on your vehicle\n- [x] Send commands to your vehicle\n- [x] Utilizes `ObjectMapper` for `JSON` mapping\n- [x] Uses `Structures` to maintain thread safe operations\n- [x] VIN Decoder\n- [ ] Summon and Homelink - Coming soon\n\n# Inspiration\nI have been a long time fan of Tesla ever since the original Roadster. When the Model 3 was announced, I actually camped out overnight so I could place my reservation. I am also a big Apple fan and really enjoy my Apple Watch, although wish there were more interesting complications I could add to my watch faces. So I decided to make my own app while I wait for my Model 3.\n\nFast foward to mid-2018, I have officially released my app, called [AutoMate for Tesla](https://apple.co/2ylLmOf), on the App Store and have also received my Model 3! During development of AutoMate, I decided to separate the core Tesla API interactions into a separate project and open source it so others could also build really cool apps too.\n\nI am looking forward to seeing what people do with TeslaKit and if you're anything like me and thoroughly enjoy your car and own an Apple Watch, I think you will also enjoy AutoMate so please give it a try!\n\n# Installation\n\nTeslaKit is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'TeslaKit'\n```\n\n# Usage\n\nAdd an ATS exception domain for `owner-api.teslamotors.com` in your info.plist\n\n```xml\n\u003ckey\u003eNSAppTransportSecurity\u003c/key\u003e\n\u003cdict\u003e\n    \u003ckey\u003eNSExceptionDomains\u003c/key\u003e\n    \u003cdict\u003e\n        \u003ckey\u003eowner-api.teslamotors.com\u003c/key\u003e\n        \u003cdict\u003e\n            \u003ckey\u003eNSIncludesSubdomains\u003c/key\u003e\n            \u003ctrue/\u003e\n            \u003ckey\u003eNSExceptionMinimumTLSVersion\u003c/key\u003e\n            \u003cstring\u003eTLSv1.0\u003c/string\u003e\n            \u003ckey\u003eNSExceptionAllowsInsecureHTTPLoads\u003c/key\u003e\n            \u003ctrue/\u003e\n        \u003c/dict\u003e\n    \u003c/dict\u003e\n\u003c/dict\u003e\n```\n\nAdd an import statement for `TeslaKit` into your file\n```swift\nimport TeslaKit\n```\n\n## TeslaAPI\nCreate a new `TeslaAPI` instance\n\n```swift\nlet teslaAPI = TeslaAPI()\n```\n\nAlso see other initialization [configuration](#configuration) options\n\n## Access Token\nObtain an Access Token by logging in with your Tesla account credentials\n\n```swift\nlet email = \"e.musk@teslakit.com\"\nlet password = \"M@R$R0X!\"\n\nteslaAPI.getAccessToken(email: email, password: password) { (httpResponse, dataOrNil, errorOrNil) in\n\n    guard let accessToken = dataOrNil?.accessToken else { return }\n\n    // Set the accessToken for use with future requests\n    teslaAPI.setAccessToken(accessToken)\n}\n```\n\n## Vehicle List\nObtain a list of vehicles associated with your account\n\n```swift\nteslaAPI.getVehicles { (httpResponse, dataOrNil, errorOrNil) in\n\n    guard let vehicle = dataOrNil?.vehicles.first else { return }\n\n    print(\"Hello, \\(vehicle.displayName)\")\n}\n```\n\n## Vehicle Data\nObtain all data for a vehicle\n\n```swift\nteslaAPI.getData(vehicle.id) { (httpResponse, dataOrNil, errorOrNil) in\n\n    guard let vehicle = dataOrNil else { return }\n\n    print(\"Battery is at \\(vehicle.chargeState.batteryLevel)%\")\n}\n```\n\n## Send Command\nSend a command to a vehicle\n\n```swift\nlet command = Command.unlockDoors\n\nteslaAPI.send(command, to: vehicle) { response in\n    if response.result {\n        print(\"Command sent successfully!\")\n    }\n}\n```\n\nSend a command to a vehicle with request parameters\n\n```swift\nlet parameters = SetTemperature(driverTemp: 21.0, passengerTemp: 21.0)\n\nteslaAPI.send(.setTemperature, to: vehicle, parameters: parameters) { response in\n    if response.result {\n        print(\"Command sent successfully!\")\n    }\n}\n```\n\n# \u003ca name=\"configuration\"\u003e\u003c/a\u003eConfiguration\n\n## Default\n```swift\nlet teslaAPI = TeslaAPI(configuration: .default) // same as TeslaAPI()\n```\n\nThe ```default``` configuration points to Tesla's production owner API\n\n## Mock\n```swift\nlet teslaAPI = TeslaAPI(configuration: .mock)\n```\n\nThe ```mock``` configuration directs all requests to a custom server that returns a predefined responses for each of the owner API endpoints allowing you to work with some real-looking data to work with without having to own a Tesla vehicle or without having a Tesla account at all.\n\nNote: Because this is a free service, requests are occasionally throttled.\n\n## Custom\n```swift\nlet customConfig = TeslaAPI.Configuration(baseURL: URL(string: \"SOME_URL\")!,\n                                          clientId: \"SOME_CLIENT_ID\",\n                                          clientSecret: \"SOME_CLIENT_SECRET\",\n                                          requestTimeout: 30)\n\nlet teslaAPI = TeslaAPI(configuration: customConfig)\n```\n\nThe ```custom``` configuration allows you to specify your own ```baseURL```. This is convenient if you would like to point to your own environment. You can also specify an alternate ```clientId``` and ```clientSecret``` value. You can also specify a different request timeout interval (default: ```30```)\n\n## Debug Mode\n\n```swift\nlet teslaAPI = TeslaAPI(debugMode: true)\n```\n\nEnabling debug mode will print all the raw request and response information to the console (default: ```false```)\n\n# VIN Decoder\n\n```swift\nlet vin = VIN(vinString: \"5YJSA1E2XHF999999\")!\nprint(vin.make)         // Model S\nprint(vin.driveUnit)    // Dual Motor\nprint(vin.modelYear)    // 2017\nprint(vin.serialNo)     // 999999\nprint(vin.vinString)    // 5YJSA1E2XHF999999\n```\n\n# Apps Built With TeslaKit\n- [AutoMate for Tesla](https://apple.co/2ylLmOf)\n\nIs your app using TeslaKit? Let me know and I'll feature it here too!\n\n# Tesla Referral Program\nBuying a new Tesla? Use my [referral code](https://ts.la/jaren29211) and receive 1,000 free Supercharger miles!\n\n# Author\n\njjjjaren, jjjjaren@gmail.com\n\n# License\n\nThis project is licensed under the terms of the MIT license. See the [LICENSE](LICENSE) file.\n\n\u003e This project is in no way affiliated with Tesla Inc. This project is open source under the MIT license, which means you have full access to the source code and can modify it to fit your own needs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamblinsoft%2Fteslakit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhamblinsoft%2Fteslakit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamblinsoft%2Fteslakit/lists"}