Changelog

Java Library Quickstart

Configure Project

  1. First install the library from maven and add it to your project.
<dependency>
   <groupId>co.dapi</groupId>
   <artifactId>dapi-java</artifactId>
   <version>1.0.0</version>
</dependency>
  1. Import Dapi's library in your code.
import co.dapi.*;
import co.dapi.types.*;
import co.dapi.response.*;
  1. Create a Dapi app with your App Secret
class MainTestClass {
    private DapiApp myApp;

    public MainTestClass() {
        var myAppConfig = new Config("YOUR_APP_SECRET");
        myApp = new DapiApp(myAppConfig);
    }
}
  1. Now you can use any of the functions of the DapiApp instance, myApp. Here is an example for getAccounts.
class MainTestClass {
    public void TestFunc() {
        try {
            var resp = myApp.getAccounts("YOUR_ACCESS_TOKEN", "YOUR_USER_SECRET");
            // do something with the resp
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Complete example

You need to replace the placeholders in this code snippet(appSecret, accessToken, userSecret) with your own values, and to handle the response received.

import co.dapi.*;
import co.dapi.types.*;
import co.dapi.response.*;
import okhttp3.Response;

import java.util.HashMap;

public class MainTestClass {
    private DapiApp myApp;

    public MainTestClass() {
        var myAppConfig = new Config("YOUR_APP_SECRET");
        myApp = new DapiApp(myAppConfig);
    }

    public void TestFunc() {
        try {
            var resp = myApp.getAccounts("YOUR_ACCESS_TOKEN", "YOUR_USER_SECRET");
            // do something with the resp
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        var test = new MainTestClass();
        test.TestFunc();
    }
}