1.0.0-alpha.5 • Published 4 years ago

@rds/sdk v1.0.0-alpha.5

Weekly downloads
6
License
Apache-2.0
Repository
github
Last release
4 years ago

RDS - JS

WARNING: THIS PROJECT IS IN EARLY DEVELOPMENT STAGE. CONTENT OR CODE SHOULD ONLY BE USED FOR TESTING OR EVALUATION PURPOSES.

npm Travis (.com) branch Coveralls github branch NPM semantic-release code style: prettier

Rich Data Services (or RDS) is a suite of REST APIs designed by Metadata Technology North America (MTNA) to meet various needs for data engineers, managers, custodians, and consumers. RDS provides a range of services including data profiling, mapping, transformation, validation, ingestion, and dissemination. For more information about each of these APIs and how you can incorporate or consume them as part of your work flow please visit the MTNA website.

RDS-JS is TypeScript/JavaScript library to simplify and faciliate interacting with any given RDS API. By using this SDK you will add to your project the benefit of strong types and easy to use helper functions that directly reflect the RDS API.

Make RDS queries easy. Write strongly typed code. Use RDS-JS.

References

RDS API DocumentationExamplesContributingDeveloper DocumentationChangelog

Quick start

Using NPM

Install the sdk into your project.

npm install @rds/sdk

Initialization

Import RdsServer and initialize to indicate where the RDS API is hosted. This must be done a single time before performing any queries.

import { RdsServer } from '@rds/sdk';
RdsServer.init('https://', 'covid19.richdataservices.com');

RDS Query Controller

This service is used to query data products for both record level and aggregate data.

Count

Get the number of records in a dataset

import { HttpResponse, RdsQueryController } from '@rds/sdk';

const CATALOG_ID = 'covid19';
const DATA_PRODUCT_ID = 'us_jhu_ccse_country';

RdsQueryController
  .count(CATALOG_ID, DATA_PRODUCT_ID)
  .then((res: HttpResponse<number>) =>
    { console.log(`Found ${res.parsedBody} records!`); }
  );

Select

Running a select query on the specified data product returns record level microdata.

import { AmchartsDataSet, HttpResponse, RdsQueryController, RdsSelectParameters } from '@rds/sdk';

const CATALOG_ID = 'covid19';
const DATA_PRODUCT_ID = 'us_jhu_ccse_country';
const PARAMS: RdsSelectParameters = {
  cols: 'date_stamp,cnt_confirmed,cnt_death,cnt_recovered',
  where: '(iso3166_1=US)',
  metadata: true,
  limit: 5000,
  format: 'amcharts'
};

RdsQueryController
  .select<AmchartsDataSet>(CATALOG_ID, DATA_PRODUCT_ID, PARAMS)
  .then((res: HttpResponse<AmchartsDataSet>) =>
    { /** Make a cool visualization */ }
  );

Tabulate

Running tabulations on the specified data product returns aggregate level data about the dimensions and measures specified.

import { AmchartsDataSet, HttpResponse, RdsQueryController, RdsTabulateParameters } from '@rds/sdk';

const CATALOG_ID = 'covid19';
const DATA_PRODUCT_ID = 'us_jhu_ccse_country';
const PARAMS: RdsTabulateParameters = {
  dims: 'iso3166_1',
  measure: 'cnt_confirmed:SUM(cnt_confirmed),cnt_death:SUM(cnt_death),cnt_recovered:SUM(cnt_recovered)',
  orderby: 'cnt_confirmed DESC',
  metadata: true,
  limit: 10
};

RdsQueryController
  .tabulate<AmchartsDataSet>(CATALOG_ID, DATA_PRODUCT_ID, PARAMS)
  .then((res: HttpResponse<AmchartsDataSet>) =>
    { /** Make a cool visualization */ }
  );