Skip to main content

Quick Start

Prerequisites

Complete Installation first. This page starts from authentication and gets you to your first successful API call in under 5 minutes.

Goal

By the end of this page you will be able to:

  1. Authenticate with a username and password to obtain an access token
  2. Use the token to query a list of elements

Step 1 — Set Environment Variables

Store credentials in environment variables — never hard-code them in source files:

export IDMP_HOST=http://localhost:6042   # Replace with your IDMP server address
export IDMP_USERNAME=your_username
export IDMP_PASSWORD=your_password

Step 2 — Log In and Get a Token

import org.openapitools.client.ApiClient;
import org.openapitools.client.api.UserResourceApi;
import org.openapitools.client.model.LoginReqDTO;
import org.openapitools.client.model.LoginRspDTO;

// 1. Create client with Bearer Token auth
ApiClient apiClient = new ApiClient("Authorization");
apiClient.setBasePath(System.getenv("IDMP_HOST"));

// 2. Log in
UserResourceApi userApi = apiClient.buildClient(UserResourceApi.class);
LoginReqDTO loginReq = new LoginReqDTO();
loginReq.setLoginName(System.getenv("IDMP_USERNAME"));
loginReq.setPassword(System.getenv("IDMP_PASSWORD"));

LoginRspDTO loginRsp = userApi.apiV1UsersLoginPost(loginReq);
System.out.println("Login successful, token: " + loginRsp.getToken());

// 3. Set the token — all subsequent requests carry it automatically
apiClient.setBearerToken(loginRsp.getToken());

Step 3 — Query Elements

import org.openapitools.client.api.ElementResourceApi;
import org.openapitools.client.api.ElementResourceApi.ApiV1ElementsGetQueryParams;
import org.openapitools.client.model.PageOfBasicElementDTO;

// Continuing from Step 2 — apiClient already has the token set
ElementResourceApi elementApi = apiClient.buildClient(ElementResourceApi.class);
ApiV1ElementsGetQueryParams params = new ApiV1ElementsGetQueryParams();
PageOfBasicElementDTO result = elementApi.apiV1ElementsGet(params);

System.out.println("Found " + result.getTotal() + " elements");

Next Steps