Java client SDK for the Smartcar API.
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.

Smartcar Java SDK Build Status Code Coverage JavaDoc



The recommended method for obtaining the SDK is via Gradle or Maven. Direct download links are also provided below.


compile "com.smartcar.sdk:java-sdk:1.0.11"



Jar Direct Download



For authentication, Smartcar uses the authorization code request flow of the OAuth 2.0 specification. Before you can make successful calls to the Smartcar platform, you will need to authenticate with Smartcar, and then obtain a valid access token for the target vehicle.

  1. Make sure you have your application set up in the Smartcar Developer Dashboard. You will need the following 3 pieces of information associated with your application:

    • Client ID
    • Client Secret
    • Redirect URI
  2. You can then generate an authentication URL for your user:

    // Setup
    String clientId = "";
    String clientSecret = "";
    String redirectUri = "";
    String[] scope = {};
    boolean development = true;
    // Initialize a new AuthClient with your credentials.
    AuthClient authClient = new AuthClient(clientId, clientSecret, redirectUri, scope, development);
    // Retrieve the auth URL to start the OAuth flow.
    String authUrl = authClient.getAuthUrl();
  3. Allow the user to complete their portion of the OAuth flow using the generated URL.

  4. Once the user is sent back to the redirect url, the required authorization code will be included in the query string:<AUTHORIZATION_CODE>

  5. Given the authorization code, you can now exchange it for an authorization token which can be used to access the Smartcar platform:

    Auth auth = authClient.exchangeCode(code);

Vehicle Data & Commands

Now that you have authenticated and can access the Smartcar platform, you can start making requests to vehicles.

  1. Obtain a list of authorized vehicles:

    SmartcarResponse<VehicleIds> vehicleIdsResponse = AuthClient.getVehicleIds(auth.getAccessToken());
    String[] vehicleIds = vehicleIdsResponse.getData().getVehicleIds();
  2. Create an instance of Vehicle:

    Vehicle vehicle = new Vehicle(vehicleIds[0], auth.getAccessToken());
  3. You can now access all information about the specified vehicle:

    // Retrieve the vehicle's VIN
    String vin =;
    // Read the vehicle's odometer
    SmartcarResponse<VehicleOdometer> odometerResponse = vehicle.odometer();
    VehicleOdometer odometerData = odometerResponse.getData();
    String odometer = odometerData.getDistance();
    // Retrieve the vehicle's location
    SmartcarResponse<VehicleLocation> locationResponse = vehicle.location();
    VehicleLocation locationData = locationResponse.getData();
    String latLong = locationData.getLatitude() + ", " + locationData.getLongitude();
    // Lock and unlock the vehicle