Skip to content

MindSphere SDK V2 for Java – Getting Started

Prerequisites to use the MindSphere SDK V2 for Java

  • Java 8 is available.
  • Gradle or Maven is used as build tool.
  • User authorization token or service credentials with required scopes for APIs are available.
  • Environment variable HOST_ENVIRONMENT is set to current region. When hosting an application in Cloud Foundry, the variable must be added in the manifest file:


    If not specified, HOST_ENVIRONMENT defaults to eu1.


Service credentials can be set as environment variables, so the client can fetch a token itself.

    Specifies service credentials ID

    Specify service credentials secret

    Specifies the tenant name


You are responsible for keeping the credentials safe. You decide whether it is safe to supply the credentials via environment variables.

Installation Instructions

Downloading the MindSphere SDK V2 for Java

Download the MindSphere SDK for Java from the Siemens Industry Online Support (SIOS) Portal. The jar and pom files of the core module and the service modules have the following structure:



  • {x.y.z} is the version number of the MindSphere Core SDK for Java (e.g. 2.0.0).The file {service_name}-sdk-{x.y.z}.pom is required for downloading the transitive dependencies of the MindSphere Core SDK for Java.
  • {x.y} is the version number of the API Specification (e.g. 3.0). The file {service_name}-sdk-{x.y}.pom is required for downloading the transitive dependencies of the MindSphere Service SDK for Java.

Adding MindSphere SDK V2 Dependencies

  1. Create the core and service module folder structure as your local Maven repository :

where $PATH is:

  • On Mac: ~/.m2/repository
  • On Windows: C:\Users\{user_name}\.m2\repository
  • On Linux: /home/{user_name}/.m2/repository

2.Register the repository and include dependencies in the build config file of your project.

<!-- Modify the following sections of the pom.xml file -->
<!-- 1. Register the repository in the repositories section -->

<!-- 2. Add Core dependency in the dependencies section (optional) -->

<!-- 3. Add Service dependency in the dependencies section -->
// Modify the following sections of the build.gradle file
// 1. Register the repository in the repositories section
repositories {
        maven {
          url file('{Absolute_path_of_the_created_repository_folder}')

// 2. Add Core dependency in the dependencies section (optional)
compile 'com.siemens.mindsphere:mindsphere-sdk-java-core:{x.y.z}'

// 3. Add Service dependency in the dependencies section
compile 'com.siemens.mindsphere:{service_name}-sdk:{x.y}'


All the MindSphere service modules have an implicit dependency on the core module, so adding the core module dependency is optional.

Further implementation of the SDK libraries has been shown in a sample project that you can download and test in local or on mindsphere application. Please refer to this repository: mindsphere-java-sdk-examples.

API Client and Credentials Configuration

The lowest-level building blocks of the API are RestClientConfig and MindsphereCredentials. These objects are instantiated using a builder pattern and shared between client instances.

Client Configuration

The following code block shows an example of how to build a RestClientConfig object:

RestClientConfig config = RestClientConfig.builder()

The RestClientConfig can be configured using the following optional parameters:

Name Description Type Default value
connectionTimeoutInSeconds Connection timeout in seconds Integer 100
socketTimeoutInSeconds Socket timeout in seconds Integer 100
proxyHost Host address of the proxy String
proxyPort Proxy port Integer
proxyUsername Username to login to the proxy String
proxyPassword Password to login to the proxy String
hostEnvironment Current Region String eu1
proxySchema Schema used by the proxy String http

Credentials Configuration

The MindsphereCredentials object can be built with a user token or with service credentials to fetch a technical token.

The following configuration parameters are available for the MindsphereCredentials object:

Name Description Type Use Case
authorization Bearer token, if available. String user token
keyStoreClientId App service credential ID String technical token
keyStoreClientSecret App service credential secret String technical token
appName Application name String technical token
appVersion Application version String technical token
hostTenant Host tenant String technical token
userTenant User tenant String technical token
clientId Tenant service credentials ID String technical token
clientSecret Tenant service credentials secret String technical token
tenant Tenant String technical token

Refer to the code samples for creating MindsphereCredentials objects for more information.

API Client Instantiation and Usage

An API client instance using RestClientConfig and MindsphereCredentials objects passed as (optional) parameters using a builder pattern.

Code sample using the IoT TimeSeries API client, placeholders are indicated by angluar brackets < >:

@RequestMapping(method = RequestMethod.GET, value = "/{entity}/{propertySetName}")
public Timeseries getTimeSeriesAsObject(@PathVariable("entity") String entity,
    @PathVariable("propertySetName") String property_set_name,
    @RequestHeader("Authorization") String token) throws MindsphereException

    //Construct MindsphereCredentials object
    MindsphereCredentials credentials = MindsphereCredentials.userTokenBuilder()

    //Construct RestClientConfig object
    RestClientConfig config = RestClientConfig.builder()

    //Construct TimeSeriesClient object
    TimeSeriesClient timeseries_client = TimeSeriesClient.builder()

    //Construct GetTimeseriesRequest object
    GetTimeseriesRequest request_object = new GetTimeseriesRequest();

    List<TimeseriesData> timeseries_data_list = null;
    try {
        timeseries_data_list = timeseries_client.getTimeseries(request_object);
    } catch (MindsphereException e) {
        // Exception handling

    return timeseries_data_list;

Any questions left?

Ask the community

Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.

Last update: December 16, 2021