npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

karmadata

v3.1.26

Published

Core JavaScript library for KarmaData API

Downloads

118

Readme

kd.js - Core library for KarmaData API

npm package

Usage

Documents

Examples

KarmaData provides a versatile API to access our database of healthcare data. Here are examples of how to use the kd.js library to access KD API, starting from the simplest.

Example 1: retrieving a random list of 10 physicians

// create a kd request
const request = kd.Request('Search', 'KdPhysician');
request.setUrlBase('https://api.karmadata.com');
request.setApiKey('-----'); // Please obtain API key by contacting KarmaData

// request data and wait for output
// API defaults to returning 10 results
request.requestData();
request.setAjaxDone((data) => {
  console.log(data);
});

Example 2: retrieving physicians that are female sole proprietors (using filters)

// create filters
const filter1 = kd.FilterItem('KdPhysician', 'Gender', 'String', 'Eq', ['Female']);
const filter2 = kd.FilterItem('KdPhysician', 'IsSoleProprietor', 'Boolean', 'Eq', [true]);

// create request and add those filters
const request = kd.Request('Search', 'KdPhysician');
request.setUrlBase('https://api.karmadata.com');
request.setApiKey('-----'); // Please obtain API key by contacting KarmaData
request.addFilterItem(filter1);
request.addFilterItem(filter2);

// request data and wait for output
request.requestData();
request.setAjaxDone((data) => {
  console.log(data);
});

Example 3: retrieving physicians that are female and belong to physician groups of size 5-10 (using FilterGroup)

// create filters
const filter1 = kd.FilterItem('KdPhysician', 'Gender', 'String', 'Eq', ['Female']);
const filter2 = kd.FilterItem('KdPhysicianGroup', 'NumberOfPhysicians', 'Number', 'Between', [5, 10]);

// create request and add those filters
const request = kd.Request('Search', 'KdPhysician');
request.setUrlBase('https://api.karmadata.com');
request.setApiKey('-----'); // Please obtain API key by contacting KarmaData
request.addFilterItem(filter1)
const group = request.createFilterGroup('And');
request.addFilterItem(filter2, group);

// request data and wait for output
request.requestData();
request.setAjaxDone((data) => {
  console.log(data);
});

Example 4: retrieve physicians that are sole proprietors and sort by graduation year

// create filters
const filter = kd.FilterItem('KdPhysician', 'IsSoleProprietor', 'Boolean', 'Eq', [true]);

// create request and add those filters
const request = kd.Request('Search', 'KdPhysician');
request.setUrlBase('https://api.karmadata.com');
request.setApiKey('-----'); // Please obtain API key by contacting KarmaData
request.addFilterItem(filter);

// adds sorting, then request data and wait for output
request.addSortOrderItem('GraduationYear', 'desc');
request.requestData();
request.setAjaxDone((data) => {
  console.log(data);
});

Fluent Style

kd.js now supports fluent style of constructing a request

let query = KdQuery('Search', 'KdCounty')
  .setUrlBase('https://api.karmadata.com')
  .setApiKey('-----') // Please obtain API key by contacting KarmaData
  .rows(1, 10)
  .where([
    FilterItem('KdCounty', 'GeoName', 'String', 'Eq', ['Plymouth'])
  ])
  .andExists({mainEntity: 'KdCounty'}, [
    FilterItem('KdState', 'GeoName', 'String', 'Eq', ['Massachusetts'])
  ]);
query.requestData()
  .then((data) => {
    console.log(data);
  });

Select request example

let query = kd.Query('Select')
  .setUrlBase('https://api.karmadata.com')
  .setApiKey('-----') // Please obtain API key by contacting KarmaData
  .rows(1, 100)
  .select([
      kd.SelectItem('Select', 'KdPhysicianGroup', 'KdLabel', 'String'),
      kd.SelectItem('Select', 'KdPhysician', 'Name.Text', 'String'),
      kd.SelectItem('Select', 'KdPhysician', 'IsClinicalInvestigator', 'Number'),
  ])
  .where([
      kd.FilterItem('KdPhysicianGroup', 'PracticeState', 'String', 'Eq', ['Massachusetts', 'California']),
      kd.FilterItem('KdPhysicianGroup', 'Popularity', 'Number', 'Gte', [1]),
  ]);

query.requestData()
  .then((data) => {
    console.log(data);
  });