### Get VIN Example Source: https://smartcar.com/docs/api-reference/get-vin This example demonstrates how to fetch the vehicle's VIN using the Smartcar API. Ensure you have the 'read_vin' permission. ```javascript const vin = await smartcar.get("/vehicles/{{vehicle_id}}/vin"); ``` -------------------------------- ### Get Charge Voltmeter Example Source: https://smartcar.com/docs/api-reference/gm/get-charge-voltmeter This example demonstrates how to fetch the charging voltage of a vehicle. Ensure the vehicle is plugged in for a successful response. Requires the 'read_charge' permission. ```json { "voltage": 240 } ``` -------------------------------- ### Successful Charge Start Response Source: https://smartcar.com/docs/api-reference/charging/start-charging Example of a successful synchronous charge start command execution. The response includes a command ID, status, and execution metadata. ```json { "data": { "id": "exec_9876543210", "type": "command-execution", "attributes": { "commandType": "charge-start", "status": { "value": "SUCCESS" }, "executionMode": "sync" }, "meta": { "executedAt": "2024-01-01T12:00:00Z", "completedAt": "2024-01-01T12:00:02Z", "durationInSeconds": 2 } } } ``` -------------------------------- ### Virtual Key Status Response Example Source: https://smartcar.com/docs/api-reference/tesla/get-virtual-key-status This is an example of a successful JSON response when querying the virtual key status. It indicates whether the vehicle has the required virtual key installed. ```json { "isPaired": true } ``` -------------------------------- ### Charge Records Example Source: https://smartcar.com/docs/api-reference/signals/charge Provides an example of historical charging session data. This includes details such as start and end times, energy added, cost, and location. ```json { "values": [ { "startTime": "2023-10-15T19:30:00.000Z", "endTime": "2023-10-16T06:45:00.000Z", "startStateOfCharge": 25, "endStateOfCharge": 90, "energyAdded": 65.2, "isPublicCharger": false, "chargingType": "DC", "cost": { "currency": "GBP", "energyAmount": 12.56, "otherAmount": 0 }, "location": { "latitude": 51.5014, "longitude": -0.1419, "name": "Home", "address": "123 Park Lane, London SW1A 1AA" }, "id": "CHG-20231015-A39B" } ] } ``` -------------------------------- ### Set Daily Charge Schedule Request Example Source: https://smartcar.com/docs/api-reference/charge-schedules/set-daily-charge-schedule This example shows the structure of a request body to set a daily charge schedule. It includes the location, start time, and stop time for charging. ```yaml data: attributes: location: latitude: 37.7749 longitude: -122.4194 startTime: '08:00' stopTime: '10:00' ``` -------------------------------- ### Failed Charge Start Response Source: https://smartcar.com/docs/api-reference/charging/start-charging Example of a failed charge start command execution. The response includes an error object detailing the reason for the failure. ```json { "data": { "id": "exec_9876543210", "type": "command-execution", "attributes": { "commandType": "charge-start", "status": { "value": "FAILURE", "error": { "status": "500", "type": "VEHICLE", "code": "CHARGE_START_FAILED", "title": "Charge Start Failed", "detail": "The vehicle was unable to start charging.", "links": { "about": "https://smartcar.com/docs/errors/api-errors/v3/charge-start-failed" } } }, "executionMode": "sync" }, "meta": { "executedAt": "2024-01-01T12:00:00Z" } } } ``` -------------------------------- ### Set Weekly Charge Schedule Request Example Source: https://smartcar.com/docs/api-reference/charge-schedules/set-weekly-charge-schedule Use this example to set a weekly charge schedule with specific start and stop times for Monday, Wednesday, and Friday. Ensure the vehicleId and sc-user-id are correctly provided in the request. ```yaml openapi: 3.0.3 info: title: Smartcar Vehicle API version: 3.0.0 description: API for vehicle data (signals) and operations (commands). servers: - url: https://vehicle.api.smartcar.com/v3 security: [] tags: - name: Charging description: Commands for controlling vehicle charging behavior. - name: Security description: Commands for controlling vehicle door locks. - name: Navigation description: Commands for setting destinations in the vehicle navigation system. - name: Command Executions description: Retrieve the recorded result of a previously issued vehicle command. - name: Charge Schedules description: Create, retrieve, and delete recurring charge schedules on a vehicle. - name: Schedule Executions description: >- Retrieve the recorded result of a previously issued schedule create or delete request. paths: /vehicles/{vehicleId}/charge-schedules/weekly: post: tags: - Charge Schedules summary: Set weekly charge schedule description: Set weekly charge schedule with per-day time windows operationId: postWeeklyChargeSchedule parameters: - in: path name: vehicleId description: The unique identifier for the vehicle. schema: type: string example: v_123abc456def required: true - in: header name: sc-user-id required: true description: > The identifier of the vehicle user on whose behalf the command is being executed. Vehicle commands require both the `vehicleId` (path) and `sc-user-id` (header) to identify the specific vehicle and the user who has granted permission to act on it. The bearer token is a machine-to-machine token and does not carry per-user context, so this header must be provided explicitly for every command request. schema: type: string example: user_789xyz requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SetWeeklyScheduleRequest' example: data: attributes: location: latitude: 37.7749 longitude: -122.4194 days: monday: startTime: '08:00' stopTime: '10:00' wednesday: startTime: '08:00' stopTime: '10:00' friday: startTime: '08:00' stopTime: '10:00' responses: '200': description: 200 OK - Schedule created synchronously content: application/json: schema: $ref: '#/components/schemas/ScheduleExecutionResponse' example: data: id: exec_9876543210 type: charge-schedule-execution attributes: action: create scheduleType: weekly status: value: SUCCESS executionMode: sync scheduleId: sched_abc456 parameters: location: latitude: 37.7749 longitude: -122.4194 days: monday: startTime: '08:00' stopTime: '10:00' wednesday: startTime: '08:00' stopTime: '10:00' friday: startTime: '08:00' stopTime: '10:00' links: schedule: /vehicles/vid_abc/charge-schedules/sched_abc456 meta: executedAt: '2024-01-01T12:00:00Z' completedAt: '2024-01-01T12:00:02Z' durationInSeconds: 2 '202': description: > 202 Accepted — A 202 was sent to keep the connection alive; the body contains the final result. content: application/json: schema: $ref: '#/components/schemas/ScheduleExecutionResponse' examples: success: summary: Create — streamed via 202, succeeded ``` -------------------------------- ### Successful Charge Start Response (202 Accepted) Source: https://smartcar.com/docs/api-reference/charging/start-charging Example of a successful charge start command execution that returns a 202 Accepted status. The response body contains the final command result. ```json { "data": { "id": "exec_9876543210", "type": "command-execution", "attributes": { "commandType": "charge-start", "status": { "value": "SUCCESS" }, "executionMode": "sync" }, "meta": { "executedAt": "2024-01-01T12:00:00Z", "completedAt": "2024-01-01T12:03:10Z", "durationInSeconds": 190 } } } ``` -------------------------------- ### Response Example Source: https://smartcar.com/docs/api-reference/get-nominal-capacity This example shows a typical response containing available capacities, the determined nominal capacity, and a URL for user selection if needed. ```json { "availableCapacities": [ { "capacity" : 70.9, "description" : null }, { "capacity" : 80.9, "description" : null }, { "capacity" : 90.9, "description" : "BEV:Extended Range" } ], "capacity": { "nominal" : 80.9, "source": "USER_SELECTED" }, "url" : "https://connect.smartcar.com/battery-capacity?vehicle_id=36ab27d0-fd9d-4455-823a-ce30af709ffc&client_id=8229df9f-91a0-4ff0-a1ae-a1f38ee24d07&token=90abecb6-e7ab-4b85-864a-e1c8bf67f2ad&response_type=vehicle_id&redirect_uri=" } ``` -------------------------------- ### Start Charging OpenAPI Specification Source: https://smartcar.com/docs/api-reference/charging/start-charging This OpenAPI specification defines the endpoint for starting a vehicle's charging process. It includes request parameters, response schemas, and example responses for both success and failure scenarios. ```yaml openapi: 3.0.3 info: title: Smartcar Vehicle API version: 3.0.0 description: API for vehicle data (signals) and operations (commands). servers: - url: https://vehicle.api.smartcar.com/v3 security: [] tags: - name: Charging description: Commands for controlling vehicle charging behavior. - name: Security description: Commands for controlling vehicle door locks. - name: Navigation description: Commands for setting destinations in the vehicle navigation system. - name: Command Executions description: Retrieve the recorded result of a previously issued vehicle command. - name: Charge Schedules description: Create, retrieve, and delete recurring charge schedules on a vehicle. - name: Schedule Executions description: >- Retrieve the recorded result of a previously issued schedule create or delete request. paths: /vehicles/{vehicleId}/commands/charge/start: post: tags: - Charging summary: Start charging description: Initiates charging for the vehicle battery operationId: startCharge parameters: - in: path name: vehicleId description: The unique identifier for the vehicle. schema: type: string example: v_123abc456def required: true - in: header name: sc-user-id required: true description: > The identifier of the vehicle user on whose behalf the command is being executed. Vehicle commands require both the `vehicleId` (path) and `sc-user-id` (header) to identify the specific vehicle and the user who has granted permission to act on it. The bearer token is a machine-to-machine token and does not carry per-user context, so this header must be provided explicitly for every command request. schema: type: string example: user_789xyz responses: '200': description: 200 OK - Command executed synchronously and successfully content: application/json: schema: $ref: '#/components/schemas/CommandResponse' example: data: id: exec_9876543210 type: command-execution attributes: commandType: charge-start status: value: SUCCESS executionMode: sync meta: executedAt: '2024-01-01T12:00:00Z' completedAt: '2024-01-01T12:00:02Z' durationInSeconds: 2 '202': description: > 202 Accepted — A 202 was sent to keep the connection alive; the body contains the final command result. content: application/json: schema: $ref: '#/components/schemas/CommandResponse' examples: success: summary: Charge start completed successfully value: data: id: exec_9876543210 type: command-execution attributes: commandType: charge-start status: value: SUCCESS executionMode: sync meta: executedAt: '2024-01-01T12:00:00Z' completedAt: '2024-01-01T12:03:10Z' durationInSeconds: 190 failure: summary: Charge start failed value: data: id: exec_9876543210 type: command-execution attributes: commandType: charge-start status: value: FAILURE error: status: '500' type: VEHICLE code: CHARGE_START_FAILED title: Charge Start Failed detail: The vehicle was unable to start charging. links: about: >- https://smartcar.com/docs/errors/api-errors/v3/charge-start-failed executionMode: sync meta: executedAt: '2024-01-01T12:00:00Z' ``` -------------------------------- ### Get Packages Source: https://smartcar.com/docs/api-reference/signals/vehicleidentification Retrieve the optional feature sets or bundles installed on the vehicle. The response includes an array of package names. ```json { "values": [ "Base", "MY2021" ] } ``` -------------------------------- ### DateMetaData Example Source: https://smartcar.com/docs/api-reference/list-signals Example of DateMetaData, showing retrieval, OEM update, and ingestion timestamps. ```json { "retrievedAt": "2023-10-01T20:00:00Z", "oemUpdatedAt": "2023-10-01T19:59:59Z", "ingestedAt": "2023-10-01T20:01:00Z" } ``` -------------------------------- ### VehicleMode Example Source: https://smartcar.com/docs/api-reference/list-signals Example of a VehicleMode, specifying 'live' mode. ```json live ``` -------------------------------- ### Set Charge Schedule (Python) Source: https://smartcar.com/docs/api-reference/tesla/set-charge-schedule Use the Smartcar Python SDK to set a vehicle's charging schedule. This example sets the charging to start at 23:30. ```python chargeSchedule = vehicle.request( "POST", "{make}/charge/schedule", {"type": "START_TIME", "enable": true, "time": "23:30"} ) ``` -------------------------------- ### Get Wheel Tires Example Source: https://smartcar.com/docs/api-reference/signals/wheel Retrieve detailed information about each wheel on the vehicle, including tire pressure, row, and column position. This is useful for monitoring tire health and understanding vehicle wheel configuration. ```json { "rowCount": 2, "columnCount": 2, "values": [ { "row": 0, "column": 0, "tirePressure": 32 }, { "row": 0, "column": 1, "tirePressure": 32 }, { "row": 1, "column": 0, "tirePressure": 35 }, { "row": 1, "column": 1, "tirePressure": 35 } ], "unit": "kPa" } ``` -------------------------------- ### Fetch Vehicle Connections (Node.js) Source: https://smartcar.com/docs/api-reference/management/get-vehicle-connections This Node.js example shows how to retrieve connected vehicles via the Smartcar API. It encodes the management token for Basic Authentication and makes a GET request using the fetch API. ```javascript const basicAuth = Buffer.from(`default:${process.env.SMARTCAR_APP_MANAGEMENT_TOKEN}`).toString('base64'); const response = await fetch( "https://management.smartcar.com/v2.0/management/connections", { method: 'GET', headers: { 'Authorization': `Basic ${basicAuth}`, 'Content-Type': 'application/json' } } ); ``` -------------------------------- ### Example User Access Response Source: https://smartcar.com/docs/api-reference/tesla/get-user-access This is an example of the JSON response you will receive when requesting user access. It includes the access type and a list of permissions. ```json { "accessType": "OWNER", "permissions" : ["vehicle_cmds", "vehicle_device_data"] } ``` -------------------------------- ### Set Charge Schedule (cURL) Source: https://smartcar.com/docs/api-reference/tesla/set-charge-schedule Use this cURL command to set a vehicle's charging schedule. Ensure you replace `{id}`, `{make}`, and `{token}` with your specific values. This example sets the charging to start at 23:30. ```bash curl "https://api.smartcar.com/v2.0/vehicles/{id}/{make}/charge/schedule" \ -H "Authorization: Bearer {token}" \ -X "POST" \ -H "Content-Type: application/json" \ -d '{"type": "START_TIME", "enable": true, "time": "23:30"}' ``` -------------------------------- ### Defroster Response Example Source: https://smartcar.com/docs/api-reference/tesla/get-defroster This is an example of the JSON response you can expect when querying the defroster status. ```json { "frontStatus": "ON", "rearStatus": "OFF" } ``` -------------------------------- ### Fetch Tesla Charge Status (Java) Source: https://smartcar.com/docs/api-reference/tesla/get-charge This Java example shows how to construct and execute a request for Tesla charge status using the Smartcar SDK. A `SmartcarVehicleRequest` object is built for the GET method. ```java SmartcarVehicleRequest request = new SmartcarVehicleRequest.Builder() .method("GET") .path("{make}/charge") .build(); VehicleResponse charge = vehicle.request(request); ``` -------------------------------- ### Charge Signal Example Source: https://smartcar.com/docs/api-reference/list-signals Example of a charge signal response, including unit and value. ```json { "code": "charge-voltage", "name": "Voltage", "group": "Charge", "status": { "value": "SUCCESS" }, "body": { "unit": "volts", "value": 85 } } ``` -------------------------------- ### Example Charge Status Response Source: https://smartcar.com/docs/api-reference/evs/get-charge-status This is an example of the JSON response you will receive when requesting the charge status. ```json { "isPluggedIn": true, "state": "FULLY_CHARGED" } ``` -------------------------------- ### Charge Wattage Signal Example Source: https://smartcar.com/docs/api-reference/signals/charge Example of the charge wattage signal response, showing the value and unit. ```json { "value": 10.7, "unit": "watts" } ``` -------------------------------- ### Example Battery Level Response Source: https://smartcar.com/docs/api-reference/evs/get-battery-level This is an example of the JSON response you will receive when requesting the battery level. ```json { "percentRemaining": 0.3, "range": 40.5 } ``` -------------------------------- ### Example Tire Pressure Response Source: https://smartcar.com/docs/api-reference/get-tire-pressure This is an example of the JSON response received when requesting tire pressure data. The values are in kilopascals. ```json { "backLeft": 219.3, "backRight": 219.3, "frontLeft": 219.3, "frontRight": 219.3 } ``` -------------------------------- ### Get Charge Schedule Response Example Source: https://smartcar.com/docs/api-reference/nissan/get-charge-schedule This JSON object represents a successful response from the charge schedule endpoint, detailing one scheduled charging session with its start and end times, and the days it applies to. ```json { "chargeSchedules": [ { "end": "2020-01-01T02:00:00.000Z", "start": "2020-01-01T01:00:00.000Z", "days": [ "MONDAY", "WEDNESDAY", "FRIDAY" ] } ] } ``` -------------------------------- ### Successful Daily Charge Schedule Creation (200 OK) Source: https://smartcar.com/docs/api-reference/charge-schedules/set-daily-charge-schedule This example demonstrates a successful response when setting a daily charge schedule synchronously. It includes the execution details and the created schedule's parameters. ```json data: id: exec_9876543210 type: charge-schedule-execution attributes: action: create scheduleType: daily status: value: SUCCESS executionMode: sync scheduleId: sched_abc123 parameters: location: latitude: 37.7749 longitude: -122.4194 startTime: '08:00' stopTime: '10:00' links: schedule: /vehicles/vid_abc/charge-schedules/sched_abc123 meta: executedAt: '2024-01-01T12:00:00Z' completedAt: '2024-01-01T12:00:02Z' durationInSeconds: 2 ``` -------------------------------- ### Example Request for Compatibility by VIN Source: https://smartcar.com/docs/api-reference/compatibility/by-vin This example demonstrates how to request vehicle compatibility using a VIN and desired scopes. Ensure you replace placeholder values with actual data. ```http GET /compatibility?vin=YOUR_VIN&scope=read_battery%20read_fuel%20read_odometer HTTP/1.1 Host: api.smartcar.com Authorization: Basic ``` -------------------------------- ### Example Error Response: Resource Not Found Source: https://smartcar.com/docs/api-reference/get-signal Illustrates a 404 Not Found error, including the resource type and a link for more information. ```json { "errors": [ { "status": "404", "type": "RESOURCE_NOT_FOUND", "code": "NOT_FOUND", "title": "Not Found", "detail": "The requested resource could not be found.", "links": { "about": "https://smartcar.com/docs/errors/api-errors/v3/resource-not-found-errors" } } ] } ``` -------------------------------- ### Example JSON Response Source: https://smartcar.com/docs/api-reference/audi/get-charge A sample response object containing charging status, power metrics, and session details. ```json { "chargingStatus": "CHARGING", "isPluggedIn": null, "chargeRate": 21, "chargeType": "ac", "chargePortColor": "green", "chargePortLatch": "locked", "completionTime": "2022-01-13T22:52:55.358Z", "chargeMode": "manual", "socLimit": 0.8, "externalPowerStatus": "active", "wattage" : 1.5 } ``` -------------------------------- ### Example Tesla Get Charge API Response Source: https://smartcar.com/docs/api-reference/tesla/get-charge This JSON object represents a typical response from the Tesla Get Charge API, detailing the current charging status and related parameters. ```json { "amperage": 0, "completionTime": null, "wattage": 0, "voltage": 1, "isPluggedIn": false, "state": "NOT_CHARGING", "socLimit": 0.8, "amperageMaxVehicle": 48, "socLimitMax": 1, "socLimitMin": 0.5, "socLimitDefault": 0.8, "amperageRequested": 48, "energyAdded": 11.52, "rangeAddedRated": 70.811, "rangeAddedIdeal": 70.811, "chargeRate": 0, "connector": "", "fastChargerPresent": false, "fastChargerType": "", "fastChargerBrand": "", "amperageMaxCharger": 48, "chargePortColor": "", "chargePortOpen": false, "chargePortLatch": "Engaged", "chargerPhases": null } ``` -------------------------------- ### Batch Request Example Source: https://smartcar.com/docs/api-reference/batch This example demonstrates how to construct a batch request to fetch both the odometer and location data for a vehicle. Ensure you have the necessary SDK methods imported. ```javascript const vehicleIds = ["YOUR_VEHICLE_ID_1", "YOUR_VEHICLE_ID_2"]; const requests = vehicleIds.map(id => ({ path: `/vehicles/${id}`, method: "GET", query: { limit: 1, offset: 0 } })); const batchResponse = await smartcar.batch(requests); console.log(batchResponse); ``` -------------------------------- ### Get Wheel Style Example Source: https://smartcar.com/docs/api-reference/signals/wheel Retrieve the wheel style of the vehicle. This is useful for identifying specific vehicle models or trims. ```json { "value": "Apollo" } ``` -------------------------------- ### Start Charging Source: https://smartcar.com/docs/api-reference/charging/start-charging Initiates the charging process for the vehicle. ```APIDOC ## POST /vehicles/{vehicle_id}/charge/start ### Description Initiates the charging process for the vehicle. ### Method POST ### Endpoint /vehicles/{vehicle_id}/charge/start ### Request Body - **command_type** (string) - Required - The type of command to execute. Must be "charge-start". ### Request Example { "command_type": "charge-start" } ### Response #### Success Response (200) - **status** (object) - The status of the command execution. - **value** (string) - The state of the command execution (e.g., SUCCESS, FAILURE, PENDING). - **error** (object) - Error details if the status value is FAILURE. - **status** (string) - HTTP status code of the error. - **type** (string) - The type of error. - **code** (string) - The error code. - **title** (string) - A short description of the error. - **detail** (string) - A more detailed explanation of the error. - **links** (object) - Links to additional information about the error. - **about** (string) - URI to learn more about the error. - **resolution** (object) - Guidance on resolving the error. - **type** (string) - The type of resolution recommended (e.g., "RETRY_LATER", "CONTACT_SUPPORT", etc.). - **suggestedUserMessage** (string) - Optional user-friendly message for end-users. - **meta** (object) - Debug information for internal use. - **applicationId** (string) - The unique identifier for the application. - **requestId** (string) - The unique identifier for the request. - **origin** (string) - The origin of the error. #### Response Example { "status": { "value": "SUCCESS" } } ### Error Handling #### Bad Request (400) - **errors** (array) - A list of errors. - **status** (string) - HTTP status code of the error. - **type** (string) - The type of error. - **code** (string) - The error code. - **title** (string) - A short description of the error. - **detail** (string) - A more detailed explanation of the error. ``` -------------------------------- ### GET /vehicles/{id}/charge/schedule Source: https://smartcar.com/docs/api-reference/tesla/get-charge-schedule Retrieves the charging schedule of a vehicle, including start time and departure time configurations. ```APIDOC ## GET /vehicles/{id}/charge/schedule ### Description Returns the charging schedule of a vehicle. The response contains the start time and departure time of the vehicle's charging schedule. ### Method GET ### Endpoint /vehicles/{id}/charge/schedule ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the vehicle. ### Response #### Success Response (200) - **departureTime** (object) - The departure time configuration for the charging schedule. - **enabled** (boolean) - Indicates whether this schedule type is enabled or disabled. - **time** (string | null) - When plugged in, the vehicle may delay starting a charging session as long as it can reach its charge limit by this time in HH:mm. - **startTime** (object) - The start time configuration for the charging schedule. - **enabled** (boolean) - Indicates whether this schedule type is enabled or disabled. - **time** (string | null) - When plugged in, the vehicle will delay starting a charging session until this time in HH:mm. #### Response Example { "departureTime": { "enabled": false, "time": null }, "startTime": { "enabled": true, "time": "18:30" } } ``` -------------------------------- ### Get Surveillance Brand Source: https://smartcar.com/docs/api-reference/signals/surveillance Retrieves the brand of surveillance system available on the vehicle. For example, for Tesla, this would indicate 'Sentry Mode'. ```APIDOC ## GET /vehicles/{vehicleId}/signals/surveillance-brand ### Description Indicates the brand of surveillance available on the vehicle e.g. for Tesla this would be Sentry Mode ### Method GET ### Endpoint /vehicles/{vehicleId}/signals/surveillance-brand ### Parameters #### Path Parameters - **vehicleId** (string) - Required - The ID of the vehicle. #### Request Body - **value** (string) - Optional - The brand of the surveillance system. ### Request Example ```json { "value": "SentryMode" } ``` ### Response #### Success Response (200) - **value** (string) - The brand of the surveillance system. ``` -------------------------------- ### Start Charging Vehicle Source: https://smartcar.com/docs/api-reference/evs/control-charge Use this method to initiate vehicle charging. Ensure you have the 'control_charge' permission. ```javascript smartcar.startCharge(vehicleIds[0]); ``` -------------------------------- ### Get Surveillance Brand Signal Source: https://smartcar.com/docs/api-reference/signals/surveillance Retrieves the brand of surveillance system available on the vehicle. Example: Tesla's Sentry Mode. ```json { "value": "SentryMode" } ``` -------------------------------- ### Charger Phases Example Source: https://smartcar.com/docs/api-reference/signals/charge Shows the number of phases available from the connected charger. This is a simple integer value. ```json { "value": 3 } ``` -------------------------------- ### Get Charge Completion Time Response Source: https://smartcar.com/docs/api-reference/gm/get-charge-completion-time This is an example of the JSON response when requesting the charge completion time. It includes the expected completion time in ISO8601 format. ```json { "time": "2022-01-13T22:52:55.358Z" } ``` -------------------------------- ### Request Access Token with Node.js Source: https://smartcar.com/docs/api-reference/authorization/request-access-token This Node.js example demonstrates how to fetch an access token using the `fetch` API. Ensure your client ID and client secret are set as environment variables. ```javascript const response = await fetch('https://iam.smartcar.com/oauth2/token', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ grant_type: 'client_credentials', client_id: process.env.SMARTCAR_CLIENT_ID, client_secret: process.env.SMARTCAR_CLIENT_SECRET, }), }); const { access_token, token_type, expires_in } = await response.json(); ``` -------------------------------- ### Set Charge Schedule (Node.js) Source: https://smartcar.com/docs/api-reference/tesla/set-charge-schedule Use the Smartcar Node.js SDK to set a vehicle's charging schedule. This example configures the schedule to start at 23:30. ```javascript const chargeSchedule = vehicle.request( "POST", "{make}/charge/schedule", {"type": "START_TIME", "enable": true, "time": "23:30"} ); ``` -------------------------------- ### Start Charging Source: https://smartcar.com/docs/api-reference/charging/start-charging Initiates charging for the vehicle battery. This command requires the vehicle ID and a user ID to be specified. ```APIDOC ## POST /vehicles/{vehicleId}/commands/charge/start ### Description Initiates charging for the vehicle battery. ### Method POST ### Endpoint /vehicles/{vehicleId}/commands/charge/start ### Parameters #### Path Parameters - **vehicleId** (string) - Required - The unique identifier for the vehicle. #### Header Parameters - **sc-user-id** (string) - Required - The identifier of the vehicle user on whose behalf the command is being executed. ### Responses #### Success Response (200) - **data** (object) - Contains the command execution details. - **id** (string) - The unique identifier for the command execution. - **type** (string) - The type of the resource, always 'command-execution'. - **attributes** (object) - **commandType** (string) - The type of command executed, 'charge-start'. - **status** (object) - **value** (string) - The status of the command execution, e.g., 'SUCCESS'. - **executionMode** (string) - The mode of execution, e.g., 'sync'. - **meta** (object) - **executedAt** (string) - The timestamp when the command was executed. - **completedAt** (string) - The timestamp when the command execution was completed. - **durationInSeconds** (number) - The duration of the command execution in seconds. #### Accepted Response (202) - **data** (object) - Contains the command execution details, similar to the 200 OK response, but indicates asynchronous processing. #### Error Response - **data** (object) - Contains details about the command execution failure. - **attributes** (object) - **status** (object) - **value** (string) - The status of the command execution, e.g., 'FAILURE'. - **error** (object) - **status** (string) - The HTTP status code of the error. - **type** (string) - The type of the error, e.g., 'VEHICLE'. - **code** (string) - A specific error code, e.g., 'CHARGE_START_FAILED'. - **title** (string) - A short title for the error. - **detail** (string) - A detailed explanation of the error. - **links** (object) - **about** (string) - A link to documentation about the error. ### Request Example ```json { "example": "{\"data\": {\"id\": \"exec_9876543210\", \"type\": \"command-execution\", \"attributes\": {\"commandType\": \"charge-start\", \"status\": {\"value\": \"SUCCESS\"}, \"executionMode\": \"sync\"}, \"meta\": {\"executedAt\": \"2024-01-01T12:00:00Z\", \"completedAt\": \"2024-01-01T12:00:02Z\", \"durationInSeconds\": 2}}}" } ``` ### Response Example (Success) ```json { "example": "{\"data\": {\"id\": \"exec_9876543210\", \"type\": \"command-execution\", \"attributes\": {\"commandType\": \"charge-start\", \"status\": {\"value\": \"SUCCESS\"}, \"executionMode\": \"sync\"}, \"meta\": {\"executedAt\": \"2024-01-01T12:00:00Z\", \"completedAt\": \"2024-01-01T12:00:02Z\", \"durationInSeconds\": 2}}}" } ``` ### Response Example (Failure) ```json { "example": "{\"data\": {\"id\": \"exec_9876543210\", \"type\": \"command-execution\", \"attributes\": {\"commandType\": \"charge-start\", \"status\": {\"value\": \"FAILURE\", \"error\": {\"status\": \"500\", \"type\": \"VEHICLE\", \"code\": \"CHARGE_START_FAILED\", \"title\": \"Charge Start Failed\", \"detail\": \"The vehicle was unable to start charging.\", \"links\": {\"about\": \"https://smartcar.com/docs/errors/api-errors/v3/charge-start-failed\"}}}}, \"executionMode\": \"sync\"}, \"meta\": {\"executedAt\": \"2024-01-01T12:00:00Z\"}}}" } ``` ``` -------------------------------- ### Get Vehicle Charge Schedule Source: https://smartcar.com/docs/api-reference/tesla/get-charge-schedule Retrieves the charging schedule for a vehicle. Requires the `read_charge` permission. The response indicates whether departure or start time charging is enabled and specifies the times. ```json { "departureTime": { "enabled": false, "time": null }, "startTime": { "enabled": true, "time": "18:30" } } ``` -------------------------------- ### Example API Request with sc-user-id Header Source: https://smartcar.com/docs/api-reference/authorization/overview This example demonstrates how to make an API request to fetch vehicle signals, including the necessary Authorization and sc-user-id headers. Ensure you replace placeholders with your actual access token and userId. ```bash GET https://vehicle.api.smartcar.com/v3/vehicles/{id}/signals Authorization: Bearer YOUR_ACCESS_TOKEN sc-user-id: {userId} ``` -------------------------------- ### Get Engine Oil Life - Example Response Source: https://smartcar.com/docs/api-reference/get-engine-oil-life This JSON object represents a typical response when querying the engine oil life. The 'lifeRemaining' field indicates the oil's quality as a percentage. ```json { "lifeRemaining": 0.35 } ``` -------------------------------- ### Set Workweek Charge Schedule Request Source: https://smartcar.com/docs/api-reference/charge-schedules/set-workweek-charge-schedule This example shows the JSON payload for setting a workweek charge schedule. It includes the charging location and separate start and stop times for weekdays and weekends. ```json { "data": { "attributes": { "location": { "latitude": 37.7749, "longitude": -122.4194 }, "weekdays": { "startTime": "08:00", "stopTime": "10:00" }, "weekends": { "startTime": "10:00", "stopTime": "12:00" } } } } ``` -------------------------------- ### Fetch Compatible Electric Vehicles by Region and Make Source: https://smartcar.com/docs/api-reference/compatible-vehicles Combine filters to find specific electric vehicles, such as BMW EVs in the US. ```bash curl "https://compatibility.api.smartcar.com/v3/compatible-vehicles?filter[region]=US&filter[make]=BMW&filter[powertrainType]=EV" ``` -------------------------------- ### GET /charge/schedule Source: https://smartcar.com/docs/api-reference/nissan/get-charge-schedule Returns the charging schedule of a vehicle. The response contains the start time and departure time of the vehicle's charging schedule. This endpoint is currently available for `nissan` EVs on the `MyNISSAN` platform. ```APIDOC ## GET /charge/schedule ### Description Returns the charging schedule of a vehicle. The response contains the start time and departure time of the vehicle's charging schedule. ### Permission `read_charge` ### Method GET ### Endpoint /charge/schedule ### Request Body None ### Response #### Success Response (200) - **chargeSchedules** (array) - An array of charge schedules. Maximum of 3 schedules, empty if no schedules are set. - **start** (string) - HH:mm in UTC for a schedule start time. - **end** (string) - HH:mm in UTC for a schedule end time. - **days** (array) - An array of days the schedule applies to. ### Response Example ```json { "chargeSchedules": [ { "end": "2020-01-01T02:00:00.000Z", "start": "2020-01-01T01:00:00.000Z", "days": [ "MONDAY", "WEDNESDAY", "FRIDAY" ] } ] } ``` ``` -------------------------------- ### Cabin Climate Response Example Source: https://smartcar.com/docs/api-reference/tesla/get-cabin A sample JSON response containing the climate status and target temperature. ```json { "status": "ON", "temperature": 20 } ``` -------------------------------- ### Start Charging Source: https://smartcar.com/docs/api-reference/charging/start-charging Initiates the charging process for the vehicle. This is a synchronous operation. ```APIDOC ## POST /charging/start ### Description Initiates the charging process for the vehicle. This is a synchronous operation. ### Method POST ### Endpoint /charging/start ### Request Body - **commandType** (string) - Required - The type of command to execute, which is 'charge-start' for this operation. ### Request Example ```json { "commandType": "charge-start" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the details of the command execution. - **id** (string) - The unique identifier for this command execution. - **type** (string) - Resource type, always "command-execution". - **attributes** (object) - Contains command-specific attributes. - **commandType** (string) - The type of command that was executed. - **status** (object) - The status of the command execution. - **value** (string) - The status value (e.g., "SUCCESS"). - **executionMode** (string) - Whether the command was executed synchronously or asynchronously. - **meta** (object) - Contains metadata about the command execution. - **executedAt** (string) - ISO 8601 UTC timestamp when execution started. - **completedAt** (string) - ISO 8601 UTC timestamp when execution completed. - **durationInSeconds** (integer) - Elapsed time from execution start to completion, in seconds. #### Response Example ```json { "data": { "id": "exec_9876543210", "type": "command-execution", "attributes": { "commandType": "charge-start", "status": { "value": "SUCCESS" }, "executionMode": "sync" }, "meta": { "executedAt": "2024-01-01T12:00:00Z", "completedAt": "2024-01-01T12:00:02Z", "durationInSeconds": 2 } } } ``` ``` -------------------------------- ### Set Charge Schedule (Java) Source: https://smartcar.com/docs/api-reference/tesla/set-charge-schedule Use the Smartcar Java SDK to set a vehicle's charging schedule. This example configures the schedule to start at 23:30. Ensure the `SmartcarVehicleRequest` is built correctly with the method, path, and body parameters. ```java SmartcarVehicleRequest request = new SmartcarVehicleRequest.Builder() .method("POST") .path("{make}/charge/schedule") .addBodyParameter("type", "START_TIME") .addBodyParameter("enable", "true") .addBodyParameter("time", "23:30") .build(); ChargeSchedule chargeSchedule = vehicle.request(request); ``` -------------------------------- ### Example Compatibility Response Source: https://smartcar.com/docs/api-reference/compatibility/by-vin This JSON response indicates whether a vehicle is compatible and lists the capabilities for the requested scopes. 'compatible' being true suggests potential compatibility, while 'capabilities' details specific feature support. ```json { "compatible": true, "reason": null, "capabilities": [ { "capable": false, "endpoint": "/engine/oil", "permission": "read_engine_oil", "reason": "SMARTCAR_NOT_CAPABLE" }, { "capable": true, "endpoint": "/battery", "permission": "read_battery", "reason": null }, { "capable": true, "endpoint": "/battery/capacity", "permission": "read_battery", "reason": null }, { "capable": true, "endpoint": "/vin", "permission": "read_vin", "reason": null } ] } ```