Service Clients (SDKs)

How to use our generated service clients

Overview

To simplify access to the Trinsic APIs, we have published service clients in common languages for your use. The service clients do not add any additional functionality, but make it incredibly easy to interact with our various APIs.

All of our service clients have been generated using Autorest. Every function corresponds to an endpoint in one of our APIs and is documented next to the endpoint documentation in our API Reference guides. The packages are also documented such that IntelliSense in an IDE describes the functions available and the parameters for each of them.

Languages

We are planning to release additional SDKs in other web languages. Please contact us if you are interested in using a different language SDK for your application.

Retry Policy

The service clients are automatically configured with a retry policy that attempts to re-call our APIs on a failed request. This is not optimal, and we recommend instantiating each client with the optional parameter of noRetryPolicy: true to combat this.

This is demonstrated in each of the examples for instantiation.

Nuget and ASP.NET Core

Our .Net client is published on nuget.org.

Install

Install it using one of the options below:

Install-Package Trinsic.ServiceClients
dotnet add package Trinsic.ServiceClients
<PackageReference Include="Trinsic.ServiceClients"/>

Instantiate

To instantiate clients to interact with various APIs, follow the ASP.NET example below:

public class Startup {
  public void ConfigureServices(IServiceCollection services) {
    services.AddTrinsicClient(options => {
      // For CredentialsClient and WalletClient
      options.AccessToken = apiKey;
      // For ProviderClient
      options.ProviderKey = providerKey;
    });
    // ...
  }
  // ...
}
using Microsoft.AspNetCore.Mvc;
// ...

public class SampleController : ControllerBase {
  private readonly ICredentialsServiceClient _credentialsClient;
  private readonly IProviderServiceClient _providerClient;
  private readonly IWalletServiceClient _walletClient;
  // ...
  
  public SampleController(ICredentialsServiceClient credentialsClient, IProviderServiceClient providerClient, IWalletServiceClient walletClient) {
    _credentialsClient = credentialsClient;
    _providerClient = providerClient;
    _walletClient = walletClient;
    // ...
  }
}

View our C# example on GitHub.

NPM and Nodejs

Our Javascript client is published on npmjs.com.

Install

Install it using npm:

npm install --save @trinsic/service-clients

Instantiate

To instantiate clients to interact with various APIs, follow the example below:

const {
  CredentialsServiceClient,
  ProviderServiceClient,
  WalletServiceClient,
  Credentials,
  ProviderCredentials 
} = require("@trinsic/service-clients");

// Credentials API
const credentialsClient = new CredentialsServiceClient(
    new Credentials(apiKey),
    { noRetryPolicy: true }
);

// Provider API
const providerClient = new ProviderServiceClient(
    new ProviderCredentials(providerKey),
    { noRetryPolicy: true }
);

// Wallet API
const walletClient = new WalletServiceClient(
    new Credentials(apiKey),
    { noRetryPolicy: true }
);

For more examples, view our NodeJS sample on GitHub or one of our examples.

Python

Our Python client is published on PyPi.org.

Install

Install it using pip:

pip install trinsic

Instantiate

To instantiate clients to interact with various APIs, follow the example below:

from trinsic.service_clients import CredentialsClient, WalletClient, ProviderClient, ServiceClientCredentials


# Credentials API
credentials_client = CredentialsClient(ServiceClientCredentials(api_key))
credentials_client.config.retry_policy.retries = 0

# Wallet API
wallet_client = WalletClient(ServiceClientCredentials(api_key))
wallet_client.config.retry_policy.retries = 0

# Provider API
provider_client = ProviderClient(ServiceClientCredentials(provider_key))
provider_client.config.retry_policy.retries = 0

Ruby

Our Ruby client is published on RubyGems.org.

Install

Install it using gem:

gem install trinsic_service_clients

Instantiate

To instantiate clients to interact with various APIs, follow the example below:

require 'trinsic_service_clients'

# Create credentials objects
token_credentials = TrinsicServiceClients::TokenCredentials.new(api_key)
provider_credentials = TrinsicServiceClients::TokenCredentials.new(provider_key)

# Credentials API
credentials_client = TrinsicServiceClients::CredentialsClient.new token_credentials
credentials_client.middlewares = TrinsicServiceClients::NoRetryPolicy

# Wallet API
wallet_client = TrinsicServiceClients::WalletClient.new token_credentials
wallet_client.middlewares = TrinsicServiceClients::NoRetryPolicy

# Provider API
provider_client = TrinsicServiceClients::ProviderClient.new provider_credentials
provider_client.middlewares = TrinsicServiceClients::NoRetryPolicy