Skip to content

An automatically generated Java client library for Factom Harmony Connect.

License

Notifications You must be signed in to change notification settings

FPriv/factom-harmony-connect-java-client

Repository files navigation

harmony-connect-client

Harmony Connect

  • API version: 1.0.19
    • Build date: 2019-02-19T17:12:36.829940300-06:00[America/Chicago]

An easy to use API that helps you access the Factom blockchain.

For more information, please visit https://docs.harmony.factom.com

Automatically generated by the OpenAPI Generator

Requirements

Building the API client library requires:

  1. Java 1.7+
  2. Maven/Gradle

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn clean deploy

Refer to the OSSRH Guide for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>factomProject</groupId>
  <artifactId>harmony-connect-client</artifactId>
  <version>1.0.7</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "factomProject:harmony-connect-client:1.0.7"

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/harmony-connect-client-1.0.7.jar
  • target/lib/*.jar

Getting Started

Please follow the installation instruction and execute the following Java code:

import harmony_connect_client.*;
import harmony_connect_client.auth.*;
import harmony_connect_client.model.*;
import harmony_connect_client.api.ChainsApi;

import java.io.File;
import java.util.*;

public class ChainsApiExample {

    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        
        // Configure API key authorization: AppId
        ApiKeyAuth AppId = (ApiKeyAuth) defaultClient.getAuthentication("AppId");
        AppId.setApiKey("YOUR API KEY");
        // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
        //AppId.setApiKeyPrefix("Token");

        // Configure API key authorization: AppKey
        ApiKeyAuth AppKey = (ApiKeyAuth) defaultClient.getAuthentication("AppKey");
        AppKey.setApiKey("YOUR API KEY");
        // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
        //AppKey.setApiKeyPrefix("Token");

        // Configure base path. Default is https://ephemeral.api.factom.com/v1
        defaultClient.setBasePath("YOUR BASE PATH");

        ChainsApi apiInstance = new ChainsApi();
        String chainId = "6a6d796c77cc5654bb8600e9cb36e94c7767a7bb99d6abcfb0ab54b8187c7df8"; // String | Chain identifier
        try {
            Chain result = apiInstance.getChainByID(chainId);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling ChainsApi#getChainByID");
            e.printStackTrace();
        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://ephemeral.api.factom.com/v1

Class Method HTTP request Description
ChainsApi getChainByID GET /chains/{chain_id} Get Chain Info
ChainsApi getChains GET /chains Get All Chains
ChainsApi postChain POST /chains Create a Chain
ChainsApi postChainSearch POST /chains/search Search Chains
EntriesApi getEntriesByChainID GET /chains/{chain_id}/entries Get Chain's Entries
EntriesApi getEntryByHash GET /chains/{chain_id}/entries/{entry_hash} Get Entry Info
EntriesApi getFirstEntry GET /chains/{chain_id}/entries/first Get Chain's First Entry
EntriesApi getLastEntry GET /chains/{chain_id}/entries/last Get Chain's Last Entry
EntriesApi postEntriesSearch POST /chains/{chain_id}/entries/search Search Chain's Entries
EntriesApi postEntryToChainID POST /chains/{chain_id}/entries Create an Entry
IdentitiesApi getIdChainbyId GET /identities/{identity_chain_id} Get Identity Chain Info
IdentitiesApi getKeybyEntryHash GET /identities/{identity_chain_id}/keys/{key_string} Get Key Info
IdentitiesApi getKeysbyIdChainId GET /identities/{identity_chain_id}/keys Get Identity Chain's Keys
IdentitiesApi postIdChain POST /identities Create Identity Chain
IdentitiesApi postKeytoIdChainId POST /identities/{identity_chain_id}/keys Replace Identity Key
InfoApi getApiInfo GET / API Info
ProofsApi getAnchorbySearch GET /anchors/{object_id} Get Object's Anchors
ProofsApi getReceiptsbyEntry GET /receipts/{entry_hash} Get Entry's Receipts
ProofsApi getSearch GET /search Search

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

AppId

  • Type: API key
  • API key parameter name: app_id
  • Location: HTTP header

AppKey

  • Type: API key
  • API key parameter name: app_key
  • Location: HTTP header

Documentation for Changing the BasePath

When you move to a public or private blockchain plan, you'll need to update your basepath to match your new API address. You can see your current API basepath on the Application Details page in your Harmony Dev portal..

ApiClient defaultClient = Configuration.getDefaultApiClient();

defaultClient.setBasePath("YOUR BASE PATH");

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Support

For more information, you can view the Connect documentation at https://docs.harmony.factom.com

For additional support, contact us at harmony-support@factom.com