Smartcar Node SDK documentation.
- Promise
- AuthClient
- SmartcarError
Class to handle all errors from Smartcar API Please see our error guides to see a list of all the possible error types and codes of both v2.0 and v1.0 requests.
- SmartcarService
- Vehicle
- METHODS_MAP :
object.<String, Object> Every key here is the function name on vehicle This map is used to generate the methods dynamically. Every value is an object of the following fields :
- requestType: http request type, defaults to 'get' if not mentioned.
- path: url path to hit, defaults to the method name
- body: body for post requests.
- Access :
Object - Permissions :
Object - DiagnosticSystemStatus :
Object - DiagnosticSystemStatusResponse :
Object - DiagnosticTroubleCode :
Object - DiagnosticTroubleCodesResponse :
Object - ServiceHistory :
Object - ChargeLimit
- WebhookSubscription :
Object - Batch :
Object - Response :
Object - SignalsRes :
Object - SignalsResBody :
Object - SignalRes :
Object - SignalResBody :
Object - Meta :
Object - Vin :
Object - Charge :
Object - Battery :
Object - BatteryCapacity :
Object - NominalCapacity :
Object - Fuel :
Object - TirePressure :
Object - EngineOil :
Object - Odometer :
Object - SecurityResponse :
Object - Location :
Object - Attributes :
Object - ActionResponse :
Object
- smartcar
- static
- .SmartcarError
- .Vehicle
- .AuthClient
- .setApiVersion(version)
- .getApiVersion() ⇒
String - .getUser(accessToken) ⇒
User - .getVehicles(accessToken, [paging]) ⇒
VehicleIds - .getVehicle(accessToken, vehicleId) ⇒
VehicleRes - .getCompatibility(vin, scope, [country], [options]) ⇒
Compatibility - .getCompatibilityMatrix(region, [options]) ⇒
CompatibilityMatrix - .hashChallenge(amt, challenge) ⇒
String - .verifyPayload(amt, signature, body) ⇒
Boolean
- inner
- ~User :
Object - ~VehicleIds :
Object - ~VehicleRes :
Object - ~Vehicle :
Object - ~Compatibility :
Object - ~CompatibilityMatrixEntry :
Object - ~CompatibilityMatrix :
Object - ~GetConnections ⇒
Promise.<GetConnections> - ~DeleteConnections ⇒
Promise.<DeleteConnections>
- ~User :
- static
Kind: static property of smartcar
See: module:errors
Kind: static property of smartcar
See: Vehicle
Kind: static property of smartcar
See: AuthClient
Sets the version of Smartcar API you are using
Kind: static method of smartcar
| Param | Type |
|---|---|
| version | String |
Gets the version of Smartcar API that is set
Kind: static method of smartcar
Returns: String - version
smartcar.getUser(accessToken) ⇒ User
Return the user's id.
Kind: static method of smartcar
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| accessToken | String |
access token |
smartcar.getVehicles(accessToken, [paging]) ⇒ VehicleIds
Return list of the user's vehicles ids.
Kind: static method of smartcar
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| accessToken | String |
access token |
| [paging] | Object |
|
| [paging.limit] | Number |
number of vehicles to return |
| [paging.offset] | Number |
index to start vehicle list |
smartcar.getVehicle(accessToken, vehicleId) ⇒ VehicleRes
Return basic info about a vehicle.
Kind: static method of smartcar
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| accessToken | String |
access token |
| vehicleId | String |
vehicle id |
smartcar.getCompatibility(vin, scope, [country], [options]) ⇒ Compatibility
Determine whether a vehicle is compatible with Smartcar.
A compatible vehicle is a vehicle that:
- has the hardware required for internet connectivity,
- belongs to the makes and models Smartcar supports, and
- supports the permissions.
To use this function, please contact us!
Kind: static method of smartcar
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Default | Description |
|---|---|---|---|
| vin | String |
the VIN of the vehicle | |
| scope | Array.<String> |
list of permissions to check compatibility for | |
| [country] | String |
'US' |
an optional country code according to ISO 3166-1 alpha-2. |
| [options] | Object |
||
| [options.testMode] | Boolean |
Deprecated, please use mode instead. Launch Smartcar Connect in test mode. |
|
| [options.mode] | String |
Determine what mode Smartcar Connect should be launched in. Should be one of test, live or simulated. | |
| [options.testModeCompatibilityLevel] | String |
This string determines which permissions the simulated vehicle is capable of. Possible Values can be found at this link: (https://smartcar.com/docs/integration-guide/test-your-integration/test-requests/#test-successful-api-requests-with-specific-vins) |
Example
// Called with country parameter
const compatibility = await smartcar.getCompatibility(
'5YJ3E1EA7KF317XXX',
['read_odometer', 'read_location'],
'US',
{ mode: 'live' },
);Example
// Called without country parameter
const compatibility = await smartcar.getCompatibility(
'5YJ3E1EA7KF317XXX',
['read_odometer', 'read_location'],
{ mode: 'live' },
);smartcar.getCompatibilityMatrix(region, [options]) ⇒ CompatibilityMatrix
Retrieve the Smartcar compatibility matrix for a given region. Provides the ability to filter by scope, make, and type.
A compatible vehicle is a vehicle that:
- has the hardware required for internet connectivity,
- belongs to the makes and models Smartcar supports, and
- supports the permissions.
To use this function, please contact us!
Kind: static method of smartcar
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| region | String |
the region to retrieve the compatibility matrix for |
| [options] | Object |
|
| [options.scope] | Array.<String> |
list of permissions to filter the matrix by |
| [options.make] | Array.<String> |
list of makes to filter the matrix by |
| [options.type] | String |
Engine type to filter the matrix by (e.g., "ICE", "HEV", "PHEV", "BEV"). |
| [options.mode] | String |
Determine what mode Smartcar Connect should be launched in. Should be one of test, live or simulated. |
| [options.version] | String |
API version to use for the request |
Generate hash challenege for webhooks. It does HMAC_SHA256(amt, challenge)
Kind: static method of smartcar
Returns: String - String representing the hex digest
| Param | Type | Description |
|---|---|---|
| amt | String |
Application Management Token |
| challenge | String |
Challenge string |
Verify webhook payload with AMT and signature.
Kind: static method of smartcar
Returns: Boolean - true if signature matches the hex digest of amt and body
| Param | Type | Description |
|---|---|---|
| amt | String |
Application Management Token |
| signature | String |
sc-signature header value |
| body | object |
webhook response body |
Kind: inner typedef of smartcar
Properties
| Name | Type | Description |
|---|---|---|
| id | String |
User Id |
| meta | module:smartcar.Vehicle.Meta |
Example
{
id: "e0514ef4-5226-11e8-8c13-8f6e8f02e27e",
meta: {
requestId: 'b9593682-8515-4f36-8190-bb56cde4c38a',
}
}Kind: inner typedef of smartcar
Properties
| Name | Type | Description |
|---|---|---|
| vehicles | Array.<String> |
A list of the user's authorized vehicle ids. |
| paging | Object |
|
| paging.count- | Number |
The total number of vehicles. |
| paging.offset | Number |
The current start index of returned vehicle ids. |
| meta | module:smartcar.Vehicle.Meta |
Example
{
vehicles: [
'36ab27d0-fd9d-4455-823a-ce30af709ffc',
'770bdda4-2429-4b20-87fd-6af475c4365e',
],
paging: {
count: 2,
offset: 0,
},
meta: {
requestId: 'b9593682-8515-4f36-8190-bb56cde4c38a',
}
}Kind: inner typedef of smartcar
Properties
| Name | Type | Description |
|---|---|---|
| body | Vehicle |
The vehicle response data. |
| [headers] | Object |
Response headers |
Kind: inner typedef of smartcar
Properties
| Name | Type | Description |
|---|---|---|
| id | String |
Vehicle Id |
| type | String |
Resource type |
| attributes | Object |
|
| attributes.make | String |
Vehicle make |
| attributes.model | String |
Vehicle model |
| attributes.year | Number |
Vehicle year |
| links | Object |
|
| links.self | String |
Link to vehicle resource |
Example
{
"id": "36ab27d0-fd9d-4455-823a-ce30af709ffc",
"type": "vehicle",
"attributes": {
"make": "TESLA",
"model": "Model 3",
"year": 2019
},
"links": {
"self": "/vehicles/36ab27d0-fd9d-4455-823a-ce30af709ffc"
}
}Kind: inner typedef of smartcar
Properties
| Name | Type |
|---|---|
| compatible | Boolean |
| reason | VEHICLE_NOT_COMPATIBLE | MAKE_NOT_COMPATIBLE | null |
| capabilities | Array.<String> |
| capabilities[].permission | String |
| capabilities[].endpoint | String |
| capabilities[].capable | Boolean |
| capabilities[].reason | VEHICLE_NOT_COMPATIBLE | MAKE_NOT_COMPATIBLE | null |
| meta | module:smartcar.Vehicle.Meta |
Example
{
compatible: true,
reason: null,
capabilities: [
{
capable: false,
endpoint: '/engine/oil',
permission: 'read_engine_oil',
reason: 'SMARTCAR_NOT_CAPABLE',
},
{
capable: true,
endpoint: '/vin',
permission: 'read_vin',
reason: null,
},
],
meta: {
'requestId':'6d4226e7-a7dd-44e0-b29c-9eed26be249d'
}
}Kind: inner typedef of smartcar
Properties
| Name | Type |
|---|---|
| model | String |
| startYear | Number |
| endYear | Number |
| type | String |
| endpoints | Array.<String> |
| permissions | Array.<String> |
Example
{
model: "LEAF",
startYear: 2018,
endYear: 2022,
type: "BEV",
endpoints: [
"EV battery",
"EV charging status",
"Location",
"Lock & unlock",
"Odometer"
],
permissions: [
"read_battery",
"read_charge",
"read_location",
"control_security",
"read_odometer"
]
}Kind: inner typedef of smartcar
Properties
| Name | Type | Description |
|---|---|---|
| makes | Object.<String, Array.<CompatibilityMatrixEntry>> |
A mapping of make names to arrays of CompatibilityMatrixEntry objects. |
Example
{
"NISSAN": [
{
"model": "LEAF",
"startYear": 2018,
"endYear": 2022,
"type": "BEV",
"endpoints": [
"EV battery",
"EV charging status",
"Location",
"Lock & unlock",
"Odometer"
],
"permissions": [
"read_battery",
"read_charge",
"read_location",
"control_security",
"read_odometer"
]
}
],
"TESLA": [
{
"model": "3",
"startYear": 2017,
"endYear": 2023,
"type": "BEV",
"endpoints": [
"EV battery",
"EV charging status",
"EV start & stop charge",
"Location",
"Lock & unlock",
"Odometer",
"Tire pressure"
],
"permissions": [
"read_battery",
"read_charge",
"control_charge",
"read_location",
"control_security",
"read_odometer",
"read_tires"
]
}
]
}Returns a paged list of all the vehicles that are connected to the application associated with the management API token used sorted in descending order by connection date.
Kind: inner typedef of smartcar
| Param | Type | Description |
|---|---|---|
| amt | String |
Application Management Token |
| filter | object |
|
| filter.userId | String |
|
| filter.vehicleId | String |
|
| paging | object |
|
| paging.limit | number |
|
| paging.cursor | String |
Properties
| Name | Type |
|---|---|
| vehicleId | String |
| userId | String |
| connectedAt | String |
| connections | Array.<Connection> |
| [paging] | Object |
| [paging.cursor] | string |
Deletes all the connections by vehicle or user ID and returns a list of all connections that were deleted.
Kind: inner typedef of smartcar
| Param | Type | Description |
|---|---|---|
| amt | String |
Application Management Token |
| filter | object |
|
| filter.userId | String |
|
| filter.vehicleId | String |
Properties
| Name | Type |
|---|---|
| vehicleId | String |
| userId | String |
| connections | Array.<Connection> |
Kind: global class See: http://bluebirdjs.com/docs/api-reference.html
Kind: global class
Create a Smartcar OAuth client for your application.
| Param | Type | Default | Description |
|---|---|---|---|
| options | Object |
||
| options.clientId | String |
Application client id obtained from Smartcar Developer Portal. If you do not have access to the dashboard, please request access. | |
| options.clientSecret | String |
The application's client secret. | |
| [options.redirectUri] | String |
Redirect URI registered in the application settings. The given URL must exactly match one of the registered URLs. This parameter is optional and should normally be set within the Smartcar Dashboard. | |
| [options.testMode] | Boolean |
false |
Deprecated, please use mode instead. Launch Smartcar Connect in test mode. |
| [options.mode] | String |
'live' |
Determine what mode Smartcar Connect should be launched in. Should be one of test, live or simulated. |
Generate the Smartcar Connect URL.
By default users are not shown the permission dialog if they have already
approved the set of scopes for this application. The application can elect
to always display the permissions dialog to the user by setting
approval_prompt to force.
Kind: instance method of AuthClient
Returns: String - Smartcar Connect URL to direct user to.
| Param | Type | Description |
|---|---|---|
| [scope] | Array.<String> |
List of permissions your application requires. The valid permission names are found in the API Reference. This is an optional parameter that should normally be set up within the Smartcar Dashboard. |
| [options] | Object |
|
| [options.forcePrompt] | Boolean |
Setting forcePrompt to true will show the permissions approval screen on every authentication attempt, even if the user has previously consented to the exact scope of permissions. |
| [options.singleSelect] | Boolean | Object |
An optional value that sets the behavior of the grant dialog displayed to the user. Object can contain two keys : - enabled - Boolean value, if set to true, single_select limits the user to selecting only one vehicle. - vin - String vin, if set, Smartcar will only authorize the vehicle with the specified VIN. See the Single Select guide for more information. |
| [options.state] | String |
OAuth state parameter passed to the redirect uri. This parameter may be used for identifying the user who initiated the request. |
| [options.makeBypass] | Object |
An optional parameter that allows users to bypass the car brand selection screen. For a complete list of supported makes, please see our API Reference documentation. |
| [options.flags] | Object |
Object of flags where key is the name of the flag value is string or boolean value. |
| [options.user] | String |
An optional unique identifier for a vehicle owner. This identifier is used to aggregate analytics across Connect sessions for each vehicle owner. |
Example
// Called with `scope` parameter.
authClient.getAuthUrl(['read_odometer', 'read_vehicle_info'], {
user: '61a3e3d2-5198-47ba-aabd-4623ce4a4042'
});Example
// Called with only `options` parameter.
authClient.getAuthUrl({
user: '61a3e3d2-5198-47ba-aabd-4623ce4a4042'
});Example
https://connect.smartcar.com/oauth/authorize?
response_type=code
&client_id=8229df9f-91a0-4ff0-a1ae-a1f38ee24d07
&scope=read_odometer read_vehicle_info
&redirect_uri=https://example.com/home
&state=0facda3319
&make=TESLA
&single_select=true
&single_select_vin=5YJSA1E14FF101307
&flags=country:DE color:00819D
&user=61a3e3d2-5198-47ba-aabd-4623ce4a4042authClient.exchangeCode(code) ⇒ Promise.<Access>
Exchange an authorization code for an access object.
Kind: instance method of AuthClient
Returns: Promise.<Access> - New set of Access and Refresh tokens.
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| code | String |
Authorization code to exchange for a Smartcar access token and refresh token. |
| [options.flags] | Object |
Object of flags where key is the name of the flag value is string or boolean value. |
authClient.exchangeRefreshToken(token) ⇒ Promise.<Access>
Exchange a refresh token for a new access object.
Kind: instance method of AuthClient
Returns: Promise.<Access> - New set of Access and Refresh tokens.
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| token | String |
Refresh token to exchange for a new set of Access and Refresh tokens. |
| [options.flags] | Object |
Object of flags where key is the name of the flag value is string or boolean value. |
Class to handle all errors from Smartcar API Please see our error guides to see a list of all the possible error types and codes of both v2.0 and v1.0 requests.
Kind: global class
- SmartcarError
- new SmartcarError(status, body, headers)
- .error :
string - .message :
string - .description :
string - .type :
string - .code :
string - .statusCode :
number - .requestId :
string - .resolution :
Resolution - .docURL :
string - .details :
Array.<object> - .Resolution :
Object
| Param | Type | Description |
|---|---|---|
| status | number |
response status |
| body | object |
response body |
| headers | object |
response headers |
Legacy field from V1 error depicting a category/type/description of the error.
Kind: static property of SmartcarError
Error message field inherited from StandardError
Kind: static property of SmartcarError
Description of meaning of the error.
Kind: static property of SmartcarError
Type of error
Kind: static property of SmartcarError
Error code
Kind: static property of SmartcarError
HTTP status code
Kind: static property of SmartcarError
Unique identifier for request
Kind: static property of SmartcarError
SmartcarError.resolution : Resolution
Possible resolution for fixing the error
Kind: static property of SmartcarError
Reference to Smartcar documentation
Kind: static property of SmartcarError
Further detail about the error in form of array of objects
Kind: static property of SmartcarError
Kind: static typedef of SmartcarError
Properties
| Name | Type | Description |
|---|---|---|
| type | String |
Possible hint to fixing the issue |
| url | String |
A URL to help resolve the issue or resume the operation |
Initializes a new Service object to make requests to the Smartcar API.
| Param | Type | Description |
|---|---|---|
| [options] | Object |
|
| [options.baseUrl] | String |
Host/Base URL for the requests |
| [options.auth] | Object |
authorization options |
| [options.headers] | Object |
headers to add |
| [options.apiVersion] | Object |
API version to use for requests |
Kind: global class
- Vehicle
- new Vehicle(id, token, [options])
- .permissions([paging]) ⇒
Promise.<Permissions> - .diagnosticSystemStatus() ⇒
Promise.<DiagnosticSystemStatusResponse> - .diagnosticTroubleCodes() ⇒
Promise.<DiagnosticTroubleCodesResponse> - .serviceHistory([startDate], [endDate]) ⇒
Promise.<Array.<ServiceHistory>> - .getChargeLimit() ⇒
Promise.<ChargeLimit> - .setChargeLimit(limit) ⇒
Promise.<ChargeLimit> - .sendDestination(latitude, longitude) ⇒
Promise.<ActionResponse> - .subscribe(webhookId) ⇒
Promise.<Object> - .unsubscribe(amt, webhookId) ⇒
Promise.<Meta> - .batch(paths) ⇒
Promise.<Batch> - .request(method, path, body, headers, apiVersion) ⇒
Promise.<Response> - .getSignals() ⇒
Promise.<SignalsRes> - .getSignal(signalCode) ⇒
Promise.<SignalRes> - .vin() ⇒
Vin - .charge() ⇒
Charge - .battery() ⇒
Battery - .batteryCapacity() ⇒
BatteryCapacity - .nominalCapacity() ⇒
NominalCapacity - .fuel() ⇒
Fuel - .tirePressure() ⇒
TirePressure - .engineOil() ⇒
EngineOil - .odometer() ⇒
Odometer - .location() ⇒
Location - .attributes() ⇒
Attributes - .lock() ⇒
ActionResponse - .unlock() ⇒
ActionResponse - .startCharge() ⇒
ActionResponse - .stopCharge() ⇒
ActionResponse - .disconnect() ⇒
ActionResponse - .lockStatus() ⇒
LockStatus
Initializes a new Vehicle to use for making requests to the Smartcar API.
| Param | Type | Default | Description |
|---|---|---|---|
| id | String |
The vehicle's unique identifier. Retrieve a user's vehicle id using getVehicles. | |
| token | String |
A valid access token | |
| [options] | Object |
||
| [options.unitSystem] | String |
metric |
The unit system to use for vehicle data must be either metric or imperial. |
| [options.version] | Object |
API version to use | |
| [options.flags] | Object |
Object of flags where key is the name of the flag and value is string or boolean value. |
vehicle.permissions([paging]) ⇒ Promise.<Permissions>
Fetch the list of permissions that this application has been granted
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| [paging] | Object |
|
| [paging.limit] | String |
number of permissions to return |
| [options.offset] | Object |
The current start index of the returned list of elements. |
vehicle.diagnosticSystemStatus() ⇒ Promise.<DiagnosticSystemStatusResponse>
Fetches diagnostic system status information for the vehicle.
Kind: instance method of Vehicle
Returns: Promise.<DiagnosticSystemStatusResponse> - -
The response containing diagnostic system statuses.
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
Example
{
"systems": [
{
"systemId": "SYSTEM_TPMS",
"status": "ALERT",
"description": "Left rear tire sensor battery low"
},
{
"systemId": "SYSTEM_AIRBAG",
"status": "OK",
"description": null
},
{
"systemId": "SYSTEM_ABS",
"status": "ALERT",
"description": null
},
// Additional diagnostic systems
]
}vehicle.diagnosticTroubleCodes() ⇒ Promise.<DiagnosticTroubleCodesResponse>
Fetches active diagnostic trouble codes (DTCs) for the vehicle.
Kind: instance method of Vehicle
Returns: Promise.<DiagnosticTroubleCodesResponse> - - The response containing active
diagnostic trouble codes.
Throws:
SmartcarError- If there is an error with the API request.
Example
{
"activeCodes": [
{
"code": "P302D",
"timestamp": "2024-09-05T14:48:00.000Z"
},
{
"code": "P303D",
"timestamp": null
},
// Additional codes as needed
]
}Returns a list of all the service records performed on the vehicle, filtered by the optional date range. If no dates are specified, records from the last year are returned.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - Vehicle Service History
| Param | Type | Description |
|---|---|---|
| [startDate] | String |
The start date for the record filter, either in 'YYYY-MM-DD' or 'YYYY-MM-DDTHH:MM:SS.SSSZ' format. |
| [endDate] | String |
The end date for the record filter, similar format to startDate. |
vehicle.getChargeLimit() ⇒ Promise.<ChargeLimit>
Fetch the charge limit for an electric vehicle
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
Example
{
limit: .7,
meta: {
requestId: '26c14915-0c26-43c5-8e42-9edfc2a66a0f',
}
}vehicle.setChargeLimit(limit) ⇒ Promise.<ChargeLimit>
Set the charge limit for an electric vehicle.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| limit | number |
a number between 0 and 1 |
Example
{
status: string,
meta: {
requestId: '26c14915-0c26-43c5-8e42-9edfc2a66a0f',
}
}vehicle.sendDestination(latitude, longitude) ⇒ Promise.<ActionResponse>
Send a destination to the vehicle's navigation system.
Kind: instance method of Vehicle
Returns: Promise.<ActionResponse> - - A Response object containing the status and metadata.
Throws:
SmartcarError- An instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| latitude | number |
Latitude of the destination. Must be a valid latitude value between -90 and 90 (inclusive). |
| longitude | number |
Longitude of the destination. Must be a valid longitude value between -180 and 180 (inclusive). |
Example
{
status: string,
meta: {
requestId: '26c14915-0c26-43c5-8e42-9edfc2a66a0f',
}
}Subscribe the vehicle to given webhook Id
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| webhookId | String |
Webhook Id to subscribe to. |
vehicle.unsubscribe(amt, webhookId) ⇒ Promise.<Meta>
Unsubscribe the vehicle from given webhook Id
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| amt | String |
Application management token to be used as authorization |
| webhookId | String |
Webhook Id to unsubscribe from. |
vehicle.batch(paths) ⇒ Promise.<Batch>
Make batch requests for supported items
Kind: instance method of Vehicle
Throws:
SmartcarError- on unsuccessful request. An instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - Batch Request
| Param | Type | Description |
|---|---|---|
| paths | Array.<String> |
A list of paths of endpoints to send requests to. |
vehicle.request(method, path, body, headers, apiVersion) ⇒ Promise.<Response>
General purpose method to make a request to a Smartcar endpoint.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| method | String |
The HTTP request method to use. |
| path | String |
The path to make the request to. |
| body | Object |
The request body. |
| headers | Object |
The headers to include in the request. |
| apiVersion | String |
The API version to use for the request. |
vehicle.getSignals() ⇒ Promise.<SignalsRes>
Get the vehicle signals (v3 endpoint)
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
vehicle.getSignal(signalCode) ⇒ Promise.<SignalRes>
Get a specific signal for a vehicle (v3 endpoint)
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
| Param | Type | Description |
|---|---|---|
| signalCode | String |
the signal code to retrieve |
vehicle.vin() ⇒ Vin
Returns the vehicle's manufacturer identifier (VIN).
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
vehicle.charge() ⇒ Charge
Returns the current charge status of the vehicle.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - EV charging status
vehicle.battery() ⇒ Battery
Returns the state of charge (SOC) and remaining range of an electric or plug-in hybrid vehicle's battery.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - EV battery level
vehicle.batteryCapacity() ⇒ BatteryCapacity
Returns the capacity of an electric or plug-in hybrid vehicle's battery.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - EV battery capacity
vehicle.nominalCapacity() ⇒ NominalCapacity
Returns a list of nominal rated battery capacities for a vehicle.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - nominal capacity
vehicle.fuel() ⇒ Fuel
Returns the status of the fuel remaining in the vehicle's gas tank.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - Fuel tank
vehicle.tirePressure() ⇒ TirePressure
Returns the air pressure of each of the vehicle's tires.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - Tire pressure
vehicle.engineOil() ⇒ EngineOil
Returns the remaining life span of a vehicle's engine oil
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - Engine oil life
vehicle.odometer() ⇒ Odometer
Returns the vehicle's last known odometer reading.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - Odometer
vehicle.location() ⇒ Location
Returns the last known location of the vehicle in geographic coordinates.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - Location
vehicle.attributes() ⇒ Attributes
Returns make model year and id of the vehicle
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - Vehicle attributes
vehicle.lock() ⇒ ActionResponse
Attempts to lock the vehicle.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
vehicle.unlock() ⇒ ActionResponse
Attempts to lock the vehicle.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - Unlock
vehicle.startCharge() ⇒ ActionResponse
Attempts to start charging the vehicle.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - EV start charge
vehicle.stopCharge() ⇒ ActionResponse
Attempts to stop charging the vehicle.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - EV stop charge
vehicle.disconnect() ⇒ ActionResponse
Disconnect this vehicle from the connected application. Note: Calling this method will invalidate your token's access to the vehicle. You will have to reauthorize the user to your application again if you wish to make requests to it again.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - Disconnect
Returns the lock status of the vehicle.
Kind: instance method of Vehicle
Throws:
SmartcarError- an instance of SmartcarError. See the errors section for all possible errors.
See: Smartcar API Doc - Lock Status
Every key here is the function name on vehicle This map is used to generate the methods dynamically. Every value is an object of the following fields :
- requestType: http request type, defaults to 'get' if not mentioned.
- path: url path to hit, defaults to the method name
- body: body for post requests.
Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| expiration | Date |
Date object which represents when the access token expires. |
| accessToken | String |
A token to be used for requests to the Smartcar API |
| refreshToken | String |
A token which is used to renew access when the current access token expires, expires in 60 days |
| refreshExpiration | Date |
Date object which represents when the refresh token expires. |
Example
{
expiration: new Date('2017-05-26T01:21:27.070Z'),
accessToken: '88704225-9f6c-4919-93e7-e0cec71317ce',
refreshToken: '60a9e801-6d26-4d88-926e-5c7f9fc13486',
refreshExpiration: new Date('2017-05-26T01:21:27.070Z'),
}Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| permissions | Array.<String> |
An array of permissions names. |
| [paging] | Object |
|
| [paging.count] | Number |
The total number of elements for the entire query (not just the given page). |
| [options.offset] | Number |
The current start index of the returned list of elements. |
| meta | Meta |
Example
{
permissions: ['read_vehicle_info'],
paging: {
count: 25,
offset: 10
},
meta: {
requestId: '26c14915-0c26-43c5-8e42-9edfc2a66a0f',
}
}Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| systemId | string |
The identifier for the vehicle's system. |
| status | string |
The status of the system, either 'OK' or 'ALERT'. |
| description | string | null |
Additional details about the system's status, if any. |
Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| systems | Array.<DiagnosticSystemStatus> |
An array of diagnostic system statuses. |
| meta | Meta |
Metadata about the request. |
Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| code | string |
The diagnostic trouble code identifier. |
| timestamp | string | null |
ISO 8601 formatted timestamp indicating when the code was triggered, may be null if not available. |
Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| activeCodes | Array.<DiagnosticTroubleCode> |
An array of active diagnostic trouble codes. |
| meta | Meta |
Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| serviceID | Number | null |
The unique identifier for the service record, or null if not available. |
| serviceDate | String |
The date and time the service was performed. |
| odometerDistance | Number |
The odometer reading at the time of service, in miles or kilometers based on the unit system. |
| serviceTasks | Array.<ServiceTask> |
A list of tasks performed during the service. |
| serviceDetails | ServiceDetails |
Details about the service provider and the type of service. |
| serviceCost | ServiceCost |
The cost of the service with currency. |
| meta | Meta |
Metadata related to the service record. |
Example
[
{
serviceId: 12345,
serviceDate: "2022-07-10T16:20:00.000Z",
odometerDistance: 50000,
serviceTasks: [
{
taskId: 01,
taskDescription: "oil change"
}
],
serviceDetails: {
type: "dealership" // "manual_entry" could be another possible value
},
serviceCost: {
totalCost: 100,
currency: 'USD'
},
meta: {
dataAge: new Date('2023-04-30T07:20:50.844Z'),
unitSystem: 'imperial',
requestId: 'b3c14915-0c26-43c5-8e42-9edfc2a66b2f',
fetchedAt: new Date('2023-04-30T07:20:51.844Z'),
}
}
// ... additional service records
]Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| limit | number |
the charge limit expressed as a decimal value between 0 and 1. |
Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| webhookId | String |
Webhook Id that the vehicle was subscribed to |
| vehicleId | String |
Current vehicle id that was subscribed to the webhook |
| meta | Meta |
Example
{
webhookId: 'dd214915-0c26-13c5-8e42-7edfc2ab320a',
vehicleId: '19c0cc8c-80e0-4182-9372-6ef903c7599c',
meta: {
requestId: '26c14915-0c26-43c5-8e42-9edfc2a66a0f',
}
}Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| ENDPOINT | function |
The response object for a given ENDPOINT where ENDPOINT is a Smartcar endpoint (i.e. /odometer, /fuel) or throws SmartcarError if the endpoint resulted in an error. |
Example
{
"odometer" : function() => returns odometer object or throws SmartcarError,
"location" : function() => returns odometer location or throws SmartcarError,
}Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| body | String |
The response body |
| meta | Meta |
Example
{
body: { distance: 59801.6373441601 },
meta: {
dataAge: 2022-01-20T02:55:25.041Z,
unitSystem: 'imperial',
requestId: 'f787849d-d228-482d-345f-459a5154sg73',
fetchedAt: 2022-01-20T02:55:25.041Z
}
}Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| body | SignalsResBody |
The signal response data. |
| [headers] | Object |
Response headers |
Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| data | Array.<SignalResBody> |
The array of signal objects. |
Example
{
"data": [
{
"id": "charge-activelimit",
"type": "signal",
"attributes": {
"code": "charge-activelimit",
"name": "ActiveLimit",
"group": "Charge",
"status": {
"value": "SUCCESS"
},
"body": {
"value": 80
}
},
"meta": {},
"links": {
"self": "/vehicles/tst2e255-d3c8-4f90-9fec-e6e68b98e9cb/signals/charge-activelimit"
}
},
{
"id": "charge-amperage",
"type": "signal",
"attributes": {
"code": "charge-amperage",
"name": "Amperage",
"group": "Charge",
"status": {
"value": "SUCCESS"
},
"body": {
"value": 0
}
},
"meta": {},
"links": {
"self": "/vehicles/tst2e255-d3c8-4f90-9fec-e6e68b98e9cb/signals/charge-amperage"
}
}
]
}Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| body | SignalResBody |
The signal response data. |
| [headers] | Object |
Response headers |
Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| id | String |
The signal code identifier. |
| type | String |
The type of signal, e.g., "signal". |
| attributes | Object |
The attributes of the signal |
| attributes.code | String |
The signal code. |
| attributes.name | String |
The name of the signal. |
| attributes.group | String |
The group to which the signal belongs. |
| attributes.status | Object |
The status of the signal. |
| attributes.status.value | String |
The value of the signal status, e.g., "SUCCESS". |
| attributes.body | Object |
The body of the signal containing the actual data. |
| meta | Object |
Metadata about the signal retrieval. |
| meta.retrievedAt | Number |
Timestamp when the signal was retrieved. |
| meta.oemUpdatedAt | Number |
Timestamp when the signal was last updated by the OEM. |
| links | Object |
Links related to the signal. |
| links.self | String |
The self-referential link for the signal. |
Example
{
"id": "odometer-traveleddistance",
"type": "signal",
"attributes": {
"code": "odometer-traveleddistance",
"name": "TraveledDistance",
"group": "Odometer",
"status": {
"value": "SUCCESS"
},
"body": {
"unit": "kilometers",
"value": 115071.50046584333
}
},
"meta": {
"retrievedAt": 1752104218549,
"oemUpdatedAt": 1752104118549
},
"links": {
"self":