Madaket API Client for clean, high quality Provider Data
Last updated 2 years ago by dan-madaket .
SEE LICENSE IN LICENSE.md · Original npm · Tarball · package.json
$ cnpm install @madaket/provider-api-client-ts 
SYNC missed versions from official npm registry.

Madaket Health Provider API Typescript Client

Typescript client for Madaket Health Provider API

RESTful JSON Endpoints by Madaket Health for clean, high-quality Provider Data


Inside your npm project:

npm install @madaket/provider-api-client-ts --save


import { AuthUtil } from '@madaket/provider-api-client-ts/auth';
import { ProviderApi, ProviderApiApiKeys, ProviderDataSourceQuery } from '@madaket/provider-api-client-ts/api';

const API_KEY = 'your-api-key';
const API_SECRET = 'your-api-secret'; // do not hard code this, load from ignored config or ENV variable

const providerApi = new ProviderApi();
providerApi.setApiKey(ProviderApiApiKeys.api_key, API_KEY);
providerApi.setApiKey(ProviderApiApiKeys.auth_token, AuthUtil.generateAuthToken(API_KEY, API_SECRET));

const query = new ProviderDataSourceQuery();
query.firstName = "James";
query.lastName = "Gibbs";

const res = providerApi.search(query)
    .then((res) => {
    .error((err) => {

Documentation for API Endpoints

Check out the swagger UI or the swagger spec

Documentation for Authentication

The above library pushes Authentication under the hood. However, if you'd like to pass over the library for your own client, the following details the method for authenticating with the server.

To Authenticate each request, include your issued API Key and a hash of your API Secret as query parameters:


To hash the secret:

  1. Get the current date and format it as yyyy-mm-dd-HH-MM (in GMT)
  2. Remove the last character from the end (effectively resulting in yyyy-mm-dd-HH-M) to create the <timestamp>
  3. Concatenate <api_key><api_secret><timestamp>
  4. Take the SHA-256 hash of the concatenated string
  5. Base64-SafeUrl encode the resulting bytes

The token will be valid for up to 10 minutes after it is created.

Typescript implementation of the previous steps:

import * as dateformat from 'dateformat';
import * as CryptoJS from 'crypto-js';

export class AuthUtil {

  public static generateAuthToken(api_key: string, api_secret: string) {
    const now = Date.now();
    let timestamp = dateformat(now, "GMT:yyyy-mm-dd-HH-MM");
    timestamp = timestamp.substring(0, timestamp.length - 1);
    const cleartext = api_key + api_secret + timestamp;

    // Take SHA-256 hash, Base64 encode, URL Safe
    return CryptoJS.SHA256(cleartext)
      .replace(/\+/g, '-')
      .replace(/\//g, '_')
      .replace(/=+$/, '');


Current Tags

  • 0.0.3                                ...           latest (2 years ago)

1 Versions

  • 0.0.3                                ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (6)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |