0.2.0 • Published 3 years ago

@credfin/client v0.2.0

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

Credfin Client

A wrapper that handles authentication with the Credfin API (docs).

Built and Tested on Node version 14.15.4

The exported function createCredfinClient creates an Axios instance that automatically creates the requisite authentication headers. The resultant Axios instance can then be used as usual.

For Python and PHP language usage, check the HMAC integration docs.

Prerequisites

Installation

The package is available on NPM.

# NPM

npm install @credfin/client

# OR Yarn

yarn add @credfin/client

API Reference

// Values required to generate authorization headers
interface CredfinApiToken {
  secret: string;
  identifier: string;
}

// Request details
interface HmacOptions {
  method: string;
  path: string;
  body?: string;
}

// the function used internally by createCredfinClient is exposed
// if you prefer to use your own HTTP request library
function generateHmacHeaders(token: CredfinApiToken, options: HmacOptions): Record<string, string>;

// Method to create an axios instance with authorization headers
function createCredfinClient(token: CredfinApiToken): AxiosInstance;

Example

import {createCredfinClient} from '@credin/client';

const secret = process.env.CREDFIN_SECRET;
const identifier = process.env.CREDFIN_IDENTIFIER;

import {createCredfinClient} from '@credfin/client';

const example = async () => {
  const bundleId = 0; // Check webhooks for specific bundle id
  const urlPath = `/api/v1/applications/${bundleId})/bundle`;

  const client = createCredfinClient({secret, identififer});

  try {
    const response = await client.get(urlPath);
  } catch (error) {
    // handle the error
  }
};

example();

Response data is dependent on the API requests used. Check API docs for more information.

0.2.0

3 years ago

0.1.14

4 years ago

0.1.15

4 years ago

0.1.13

4 years ago

0.1.12

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.0

4 years ago

1.0.0

4 years ago