Skip to content
unit-financePublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

61 Commits

Folders and files

Repository files navigation

Unit API SDKs

Official client libraries for the Unit API, generated from the Unit OpenAPI specification.

Language Package Registry
TypeScript / JavaScript @unit-finance/unit-openapi-node-sdk npm
Java co.unit:unit-openapi-java-sdk Maven Central
Python unit-openapi-python-sdk PyPI
Ruby unit_openapi_ruby_sdk RubyGems

Versioning

There are two kinds of version number:

  • Release version (vX.Y.Z): the version of a GitHub Release of this repository. Each release covers all four SDKs and lists what changed.
  • Package version: the version each SDK is published with on its own registry. Package versions are independent, so the Node, Java, Python, and Ruby packages usually have different numbers, and a release only publishes the SDKs whose package version changed.

To see which package versions a release contains and which API spec version they were generated from, look at spec-version.json at that release's tag.

Authentication

Every request needs a Unit API token, sent as a bearer token. Create one in the Unit Dashboard and keep it out of source control, for example in a UNIT_TOKEN environment variable.

The examples below target the sandbox (https://api.s.unit.sh). Use https://api.unit.co in production.

TypeScript / JavaScript

npm install @unit-finance/unit-openapi-node-sdk
import { AccountsApi, Configuration } from "@unit-finance/unit-openapi-node-sdk";

const config = new Configuration({
  basePath: "https://api.s.unit.sh",
  accessToken: process.env.UNIT_TOKEN,
});

const accounts = new AccountsApi(config);
const { data } = await accounts.getAccount({ accountId: "10001" });
console.log(data);

Java

Maven:

<dependency>
  <groupId>co.unit</groupId>
  <artifactId>unit-openapi-java-sdk</artifactId>
  <version>LATEST_VERSION</version>
</dependency>

Gradle:

implementation "co.unit:unit-openapi-java-sdk:LATEST_VERSION"
import com.unit.finance.sdk.ApiClient;
import com.unit.finance.sdk.Configuration;
import com.unit.finance.sdk.api.AccountsApi;
import com.unit.finance.sdk.auth.HttpBearerAuth;

ApiClient client = Configuration.getDefaultApiClient();
client.setBasePath("https://api.s.unit.sh");
((HttpBearerAuth) client.getAuthentication("bearerAuth"))
    .setBearerToken(System.getenv("UNIT_TOKEN"));

AccountsApi accounts = new AccountsApi(client);
System.out.println(accounts.getAccount("10001", null, null));

Python

pip install unit-openapi-python-sdk
import os
import unit_finance_sdk

configuration = unit_finance_sdk.Configuration(
    host="https://api.s.unit.sh",
    access_token=os.environ["UNIT_TOKEN"],
)

with unit_finance_sdk.ApiClient(configuration) as client:
    accounts = unit_finance_sdk.AccountsApi(client)
    print(accounts.get_account("10001"))

Ruby

gem install unit_openapi_ruby_sdk
require "unit_openapi_ruby_sdk"

UnitFinanceSdk.configure do |config|
  config.host = "api.s.unit.sh"
  config.access_token = ENV.fetch("UNIT_TOKEN")
end

accounts = UnitFinanceSdk::AccountsApi.new
p accounts.get_account("10001")

Contributing

The code in this repository is generated, so edits made here are overwritten on the next release. To report a bug or request a change, open an issue.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages