# @credfin/client

> A wrapper that handles authentication with the Credfin API ([docs](https://credfin.io/api/v1/docs)).

Latest version **0.2.0** (published 2021-07-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @credfin/client
pnpm add @credfin/client
yarn add @credfin/client
bun add @credfin/client
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2021-07-26 |
| First published | 2020-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | credfin.damon, hans-credfin, frankie_credfin, jisuc |

## Links

- npm: https://www.npmjs.com/package/@credfin/client
- Repository: https://github.com/Credfin-Australia/credfin-client-node
- Homepage: https://github.com/Credfin-Australia/credfin-client-node#readme
- Issues: https://github.com/Credfin-Australia/credfin-client-node/issues
- npm.io page: https://npm.io/package/@credfin/client

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.19.2

## Recent versions

- 0.2.0 (latest) — 2021-07-26
- 0.1.15 — 2020-08-08
- 0.1.14 — 2020-08-08
- 0.1.13 — 2020-07-30
- 0.1.12 — 2020-07-25
- 0.1.10 — 2020-07-21
- 0.1.9 — 2020-07-21
- 0.1.8 — 2020-07-21
- 0.1.6 — 2020-07-21
- 0.1.5 — 2020-07-21
- 0.1.4 — 2020-07-20
- 0.1.3 — 2020-07-20
- 0.1.2 — 2020-07-20
- 0.1.1 — 2020-07-20
- 0.1.0 — 2020-07-20

## README

# Credfin Client

A wrapper that handles authentication with the Credfin API ([docs](https://credfin.io/api/v1/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](https://credfin.io/docs/v1/hmac-authentication).

## Prerequisites

- A secret and identifier pair can be created through the dashboard at https://credfin.io/dashboard/tokens.
- A webhook must be registered at https://credfin.io/dashboard/webhooks.

## Installation

The package is available on [NPM](https://www.npmjs.com/package/@credfin/client).

```bash
# NPM

npm install @credfin/client

# OR Yarn

yarn add @credfin/client
```

## API Reference

```typescript
// 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

```typescript
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](https://credfin.io/api/docs/) for more information.

---
_Source: https://npm.io/package/@credfin/client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
