0.0.2400-7.1854 • Published 2 years ago

@threesigmaxyz/zkauth-api-client v0.0.2400-7.1854

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

zkAuth API Client Github Actions License: MIT

banner

The zkAuth API Client is a TypeScript/JavaScript client for the zkAuth API. It provides a wrapper around the zkAuth API that allows you to easily access resources from the zkAuth API.

Getting Started

In order to use the zkAuth API Client, you will need to install the following dependencies:

  • Node.js - A JavaScript runtime environment.
  • NPM - A package manager for JavaScript.

Installation

Once you have installed the dependencies, you can install the zkAuth API Client by running the following command:

npm install @threesigmaxyz/zkauth-api-client

Authentication

In order to a connect to the zkAuth API, you will need an API key. The following table lists the default API key for each environment:

EnvironmentUrlAPI KeyStatus
Testnethttps://zkauth-api.sigmascorpii-dev.com5660a9b6-7c6f-492a-b9fe-72af6e587658✅ Live
Mainnethttps://api.zkauth.threesigma.xyzN/A🏗️ WIP

Note that this API key is only for testing purposes and should not be used in production. To request an API key, please contact us here.

Usage

The zkAuth ApiClient is a wrapper around the zkAuth API that allows you to easily access resources from the zkAuth API. The API resources are grouped by entity type (e.g. account, provider, etc.).

Create a client

In order to connect to the zkAuth API, you will need to create an instance of the ApiClient class:

import { ApiClient } from '@threesigmaxyz/zkauth-api-client';

const api = new ApiClient({
    BASE: 'https://zkauth-api.sigmascorpii-dev.com',
    VERSION: 'v1',
    HEADERS: {
        'x-api-key': "5660a9b6-7c6f-492a-b9fe-72af6e587658"
    }
});

The api should provide access to all of the resources available in the zkAuth API.

List all providers

To list all of the providers in the zkAuth API, you can use the getApiProviders method:

const providers = await api.providers.getApiProviders(1, 20);
console.log(providers);

The method supports pagination, so you can specify the page number and page size as parameters.

Get account details

You can get the details of an account by using the getApiAccounts method:

const accountId = '65b725cb-7151-4607-8eba-966f31c5f42d';
const account = await api.accounts.getApiAccounts(accountId);
console.log(account);

Search accounts

Optionally, you can search for accounts by using the getApiAccounts1 method:

const providerId = 'google';    // The Google provider ID.
const subjectId = '1234567890'; // The subject ID of the user.

// Search for accounts with the given provider ID and subject ID.
const accounts = await api.accounts.getApiAccounts1();

console.log(accounts);

About Us

Three Sigma is a venture builder firm focused on blockchain engineering, research, and investment. Our mission is to advance the adoption of blockchain technology and contribute towards the healthy development of the Web3 space. If you are interested in joining our team, please contact us here.