Giter VIP home page Giter VIP logo

cobo-java-api's Introduction

The Official Java SDK for Cobo WaaS API

JitPack License: GPL v2 GitHub Release

About

This repository contains the official Java SDK for Cobo WaaS API, enabling developers to integrate with Cobo's Custodial and/or MPC services seamlessly using the Java programming language.

Documentation

To access the API documentation, navigate to the API references.

For more information on Cobo's Java SDK, refer to the Java SDK Guide.

Usage

Before You Begin

Ensure that you have created an account and configured Cobo's Custodial and/or MPC services. For detailed instructions, please refer to the Quickstart guide.

Requirements

  • JDK8
  • JDK17 or newer

Installation

Step 1. Add the JitPack repository to your build file

gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

maven:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Step 2. Add the dependency

gradle:

dependencies {
    implementation 'com.github.CoboGlobal:cobo-java-api:v0.90'
}

maven:

<dependency>
    <groupId>com.github.CoboGlobal</groupId>
    <artifactId>cobo-java-api</artifactId>
    <version>v0.90</version>
</dependency>

Code Sample

Generate Key Pair

import com.cobo.custody.api.client.impl.LocalSigner;

String[] key = LocalSigner.generateKeyPair();
String secretKey = key[0];
String apiKey = key[1];

For more information on the API key, please click here.

Initialize ApiSigner

ApiSigner can be instantiated through new LocalSigner("secretkey" )

In certain scenarios, the private key may be restricted from export, such as when it is stored in AWS Key Management Service (KMS). In such cases, please pass in a custom implementation using the ApiSigner interface:

import com.cobo.custody.api.client.ApiSigner;
new ApiSigner() {
    @Override
    public String sign(byte[] message) {
        return null;
    }

    @Override
    public String getPublicKey() {
        return null;
    }
}

Initialize RestClient

These can be instantiated using the corresponding factory method provided by CoboApiClientFactory.

import com.cobo.custody.api.client.CoboApiClientFactory;
import com.cobo.custody.api.client.CoboApiRestClient;
import com.cobo.custody.api.client.config.CoboApiConfig;
import com.cobo.custody.api.client.config.Env;
import com.cobo.custody.api.client.impl.LocalSigner;

CoboApiRestClient client = CoboApiClientFactory.newInstance(
                new LocalSigner(apiSecret),
                Env.DEV,
                false).newRestClient();

Complete Code Sample

import com.cobo.custody.api.client.CoboApiClientFactory;
import com.cobo.custody.api.client.CoboApiRestClient;
import com.cobo.custody.api.client.config.CoboApiConfig;
import com.cobo.custody.api.client.config.Env;
import com.cobo.custody.api.client.impl.LocalSigner;

String[] key = LocalSigner.generateKeyPair();
String secretKey = key[0];
String apiKey = key[1];

CoboApiRestClient client = CoboApiClientFactory.newInstance(
                new LocalSigner(secretKey),
                Env.DEV,
                false).newRestClient();
                
ApiResponse<OrgInfo> orgInfo = client.getOrgInfo()
System.out.println(orgInfo);

cobo-java-api's People

Contributors

haofengjiang avatar cobozhu avatar aereach avatar yangmingcobo avatar caixiao-qa avatar zhangjun725 avatar zhangcongcobo avatar zhanghuiwen1998 avatar zhimnin avatar merlin-ship-it avatar cchangyixue avatar lucentyang avatar jaminpeng avatar lwcobo avatar zhihaodeng-cobo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.