Have ideas to improve npm?Join in the discussion! »

    @madaket/provider-api-client-js

    0.0.3 • Public • Published

    Madaket Health Provider API Javascript Client

    JavaScript client for Madaket Health Provider API

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

    Installation

    Inside your npm project:

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

    Quickstart

    var MadaketHealthApi = require('@madaket/provider-api-client-js');
     
    var API_KEY = "your-api-key";
    var API_SECRET = "your-api-secret"; // do not hard code this, load from ignored config or ENV variable
    MadaketHealthApi.ApiClient.instance.authorize(API_KEY, API_SECRET);
     
    var providerApi = new MadaketHealthApi.ProviderApi();
     
    var searchQuery = {
        npi: "",
        firstName: "Peter",
        middleName: "",
        lastName: "Shannon",
        licenseStates: [
            "MA"
        ],
        licenseNumber: "",
        phone: "",
        providerType: "MD",
        taxonomies: [
            ""
        ],
        maxResults: 10
    };
     
    var callback = function (error, data, response) {
        if (error) {
            console.error('API call ended in error. Returned data: ' + JSON.stringify(error.response.body));
        } else {
            console.log('API called successfully. Returned data: ' + JSON.stringify(data));
        }
    };
     
    providerApi.search({body: searchQuery}, callback);

    Documentation for API Endpoints

    See README.md docs inside this module in /node_modules/@madaket/provider-api-client-js/docs after downloading.

    Alternatively, 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:

    ?api_key=<your-api-key>&auth_token=<your-hashed-secret>

    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
    3. Concatenate <api_key><api_secret>
    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.

    Javascript implementation of the previous steps:

    function generate_auth_token(api_key, api_secret) {
            var now = Date.now();
            var timestamp = dateformat(now, "GMT:yyyy-mm-dd-HH-MM");
            timestamp = timestamp.substring(0, timestamp.length - 1);
            var cleartext = api_key + api_secret + timestamp;
     
            // Take SHA-256 hash, Base64 encode, URL Safe
            return CryptoJS.SHA256(cleartext)
                .toString(CryptoJS.enc.Base64)
                .replace(/\\+/g, '-')
                .replace(/\\//g, '_')
                .replace(/=+$/, '');
        }

    Keywords

    none

    Install

    npm i @madaket/provider-api-client-js

    DownloadsWeekly Downloads

    9

    Version

    0.0.3

    License

    SEE LICENSE IN LICENSE.md

    Last publish

    Collaborators

    • avatar