Operations about vehicles
- Batch - Batch
- LockStatus - Returns the lock status for a vehicle and the open status of its doors, windows, storage units, sunroof and charging port where available. The open status array(s) will be empty if a vehicle has partial support. The request will error if lock status can not be retrieved from the vehicle or the brand is not supported.
- Disconnect - Revoke Access
- Get - Vehicle Info
- GetEngineOil - Engine Oil Life
- GetFuelTank - Fuel Tank (US Only)
- GetLocation - Location
- GetOdometer - Odometer
- GetPermissions - Application Permissions
- GetTirePressure - Tire Pressure
- GetVin - Returns the vehicle’s manufacturer identifier.
- ListVehicles - All Vehicles
- LockUnlock - Lock/Unlock Vehicle
Description Returns a list of responses from multiple Smartcar endpoints, all combined into a single request. Note: Batch requests is a paid feature. Please contact us to upgrade your plan and obtain access.
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.Batch(ctx, operations.BatchRequest{
RequestBody: []string{
"/odometer",
},
VehicleID: "architecto",
})
if err != nil {
log.Fatal(err)
}
if res.BatchResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.BatchRequest | ✔️ | The request object to use for the request. |
*operations.BatchResponse, error
Returns the lock status for a vehicle and the open status of its doors, windows, storage units, sunroof and charging port where available. The open status array(s) will be empty if a vehicle has partial support. The request will error if lock status can not be retrieved from the vehicle or the brand is not supported.
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.LockStatus(ctx, operations.LockStatusRequest{
VehicleID: "ipsa",
})
if err != nil {
log.Fatal(err)
}
if res.SecurityRead != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.LockStatusRequest | ✔️ | The request object to use for the request. |
*operations.LockStatusResponse, error
Description
Revoke access for the current requesting application. This is the correct way to disconnect a vehicle.
Response body
Name | Type | Boolean |
---|---|---|
status | string | If the request is successful, Smartcar will return “success” (HTTP 200 status). |
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.Disconnect(ctx, operations.DisconnectRequest{
VehicleID: "reiciendis",
})
if err != nil {
log.Fatal(err)
}
if res.Status != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.DisconnectRequest | ✔️ | The request object to use for the request. |
*operations.DisconnectResponse, error
Permission
Returns a single vehicle object, containing identifying information.
Permission
read_vehicle_info
Response Body
Name | Type | Description |
---|---|---|
id |
string | A vehicle ID (UUID v4). |
make |
string | The manufacturer of the vehicle. |
model |
integer | The model of the vehicle. |
year |
integer | The model year. |
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.Get(ctx, operations.GetVehicleRequest{
VehicleID: "est",
})
if err != nil {
log.Fatal(err)
}
if res.VehicleInfo != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetVehicleRequest | ✔️ | The request object to use for the request. |
*operations.GetVehicleResponse, error
Description
Returns the remaining life span of a vehicle’s engine oil.
Permission
read_engine_oil
Response body
Name | Type | Boolean |
---|---|---|
lifeRemaining |
number | The engine oil’s remaining life span (as a percentage). Oil life is based on the current quality of the oil. (in percent). |
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.GetEngineOil(ctx, operations.GetEngineOilRequest{
VehicleID: "mollitia",
})
if err != nil {
log.Fatal(err)
}
if res.EngineOil != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetEngineOilRequest | ✔️ | The request object to use for the request. |
*operations.GetEngineOilResponse, error
Description
Returns the status of the fuel remaining in the vehicle’s gas tank. Note: The fuel tank API is only available for vehicles sold in the United States.
Permission
read_fuel
Response Body
Name | Type | Desciprtion |
---|---|---|
range |
number | The estimated remaining distance the car can travel (in kilometers by default or in miles using the sc-unit-system). |
percentRemaining |
number | The remaining level of fuel in the tank (in percent). |
amountRemaining |
number | The amount of fuel in the tank (in liters by default or in gallons (U.S.) using the sc-unit-system). |
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.GetFuelTank(ctx, operations.GetFuelTankRequest{
VehicleID: "laborum",
})
if err != nil {
log.Fatal(err)
}
if res.FuelTank != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetFuelTankRequest | ✔️ | The request object to use for the request. |
*operations.GetFuelTankResponse, error
Description
Retrieve latitude and longitude of a vehicle.
Permission
read_location
Response Body
Name | Type | Desciprtion |
---|---|---|
latitude |
number | The latitude (in degrees). |
longitude |
number | The longitude (in degrees). |
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.GetLocation(ctx, operations.GetLocationRequest{
VehicleID: "36ab27d0-fd9d-4455-823a-ce30af709ffc",
})
if err != nil {
log.Fatal(err)
}
if res.Location != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetLocationRequest | ✔️ | The request object to use for the request. |
*operations.GetLocationResponse, error
Description
Returns the vehicle’s last known odometer reading.
Permission
read_odometer
Response Body
Name | Type | Desciprtion |
---|---|---|
distance |
number | The current odometer of the vehicle (in kilometers by default or in miles using the sc-unit-system). |
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.GetOdometer(ctx, operations.GetOdometerRequest{
VehicleID: "dolores",
})
if err != nil {
log.Fatal(err)
}
if res.Odometer != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetOdometerRequest | ✔️ | The request object to use for the request. |
*operations.GetOdometerResponse, error
Description
Returns a list of the permissions that have been granted to your application in relation to this vehicle.
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
limit |
integer | false | Number of permissions to return (default: 25). |
offset |
integer | false | A vehicle ID (UUID v4). |
Response Body
Name | Type | Desciprtion |
---|---|---|
permissions |
array | An array of permissions. |
permissions.[] |
string | A permission. |
paging |
object | Metadata about the current list of elements. |
paging.count |
integer | The total number of elements for the entire query (not just the given page). |
paging.offset |
integer | The current start index of the returned list of elements. |
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.GetPermissions(ctx, operations.GetPermissionsRequest{
Limit: gosdkv2.Int64(210382),
Offset: gosdkv2.Int64(358152),
VehicleID: "explicabo",
})
if err != nil {
log.Fatal(err)
}
if res.Permission != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetPermissionsRequest | ✔️ | The request object to use for the request. |
*operations.GetPermissionsResponse, error
Description
Returns the air pressure of each of the vehicle’s tires. Permission
read_tires
Example Response
Name | Type | Description |
---|---|---|
frontLeft |
number | The current air pressure of the front left tire (in kilopascals by default or in pounds per square inch using the sc-unit-system). |
frontRight |
number | The current air pressure of the front right tire (in kilopascals by default or in pounds per square inch using the sc-unit-system). |
backLeft |
number | The current air pressure of the back left tire (in kilopascals by default or in pounds per square inch using the sc-unit-system). |
backRight |
number | The current air pressure of the back right tire (in kilopascals by default or in pounds per square inch using the sc-unit-system). |
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.GetTirePressure(ctx, operations.GetTirePressureRequest{
VehicleID: "nobis",
})
if err != nil {
log.Fatal(err)
}
if res.TirePressure != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetTirePressureRequest | ✔️ | The request object to use for the request. |
*operations.GetTirePressureResponse, error
Description
Returns the vehicle’s manufacturer identifier.
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.GetVin(ctx, operations.GetVinRequest{
VehicleID: "enim",
})
if err != nil {
log.Fatal(err)
}
if res.VinInfo != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.GetVinRequest | ✔️ | The request object to use for the request. |
*operations.GetVinResponse, error
Description
Returns a paged list of all vehicles connected to the application for the current authorized user.
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
limit |
integer | false | Number of vehicles to return (default: 10). |
offset |
integer | false | A vehicle ID (UUID v4). |
Response Body
Name | Type | Desciprtion |
---|---|---|
vehicles |
array | An array of vehicle IDs. |
vehicles.[] |
string | A vehicle ID (UUID v4). |
paging |
object | Metadata about the current list of elements. |
paging.count |
integer | The total number of elements for the entire query (not just the given page). |
paging.offset |
integer | The current start index of the returned list of elements. |
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.ListVehicles(ctx, operations.ListVehiclesRequest{
Limit: gosdkv2.Int64(607831),
Offset: gosdkv2.Int64(363711),
})
if err != nil {
log.Fatal(err)
}
if res.VehiclesResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.ListVehiclesRequest | ✔️ | The request object to use for the request. |
*operations.ListVehiclesResponse, error
Description
Unlock the vehicle
Permission
control_security
Response body
Name | Type | Boolean |
---|---|---|
status | string | If the request is successful, Smartcar will return “success” (HTTP 200 status). |
package main
import(
"context"
"log"
gosdkv2 "github.com/smartcar/go-sdk-v2"
"github.com/smartcar/go-sdk-v2/pkg/models/shared"
"github.com/smartcar/go-sdk-v2/pkg/models/operations"
)
func main() {
s := gosdkv2.New(
gosdkv2.WithSecurity(shared.Security{
BasicAuth: &shared.SchemeBasicAuth{
Password: "",
Username: "",
},
}),
)
ctx := context.Background()
res, err := s.Vehicles.LockUnlock(ctx, operations.LockUnlockRequest{
SecurityAction: &shared.SecurityAction{
Action: shared.SecurityActionActionUnlock.ToPointer(),
},
VehicleID: "minima",
})
if err != nil {
log.Fatal(err)
}
if res.SuccessResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.LockUnlockRequest | ✔️ | The request object to use for the request. |