Socket
Socket
Sign inDemoInstall

company-api

Package Overview
Dependencies
65
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    company-api

A library to lookup NUM records recursively to produce an aggregated result.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

company-api

An API for aggregating NUM Contacts Module and Images Module Records into a single object using the NUM Protocol.

Installation For Local Testing

  • git clone git@github.com:NUMtechnology/company-api.git
  • cd company-api
  • npm install
  • Open test/index.html in your browser.

Installation For Use In An Application

  • npm install -s company-api

Simple Application Usage in JavaScript

const companyApi = require('company-api');

// Create an API instance
const api = companyApi.createCompanyApi();

// Use it to look up a domain
api.lookupDomain('numexample.com').then((result) => {
  console.log(JSON.stringify(result));
}, (err)=>{
  console.error('ERROR: ', JSON.stringify(err));
});

Simple Application Usage in TypeScript

import { createCompanyApi } from 'company-api';

// Create an API instance
const api = createCompanyApi();

// Use it to look up a domain
api.lookupDomain('numexample.com').then((result) => {
  console.log(JSON.stringify(result));
}, (err)=>{
  console.error('ERROR: ', JSON.stringify(err));
});

Controlling the Recursion Levels

import { createCompanyApi, CompanyApiOptions } from 'company-api';

// Create an API instance
const api = createCompanyApi();

const versionMap = new Map<number, string>();
// Module 1 (Contacts) is currently at version 2, the others will default to version 1.
// An empty map can be supplied which sets the default version for each NUM module ('2' for Contacts, '1' for everything else).
versionMap.set(1,'2');
versionMap.set(3,'1.5'); // E.g. use v1.5 of the Images module (if such a version exists)

const options = new CompanyApiOptions(
    2, // The number of levels for Contacts records. 0 returns no contacts data.
    1, // The number of levels for Images records.   0 returns no images data.
    versionMap 
  );

// Use it to look up a domain
api.lookupDomain('numexample.com', options).then((result) => {
  console.log(JSON.stringify(result));
}, (err)=>{
  console.error('ERROR: ', JSON.stringify(err));
});

Supplying an Existing NUMClient Object

If you already have a NUMClient object you can re-use it.

import { createClient } from 'num-client';
import { createCompanyApi } from 'company-api';

// (from another part of your application)
const existingClient = createClient();

// Inject the existing client when creating the API instance
const api = createCompanyApi(existingClient);

// Use it to look up a domain
api.lookupDomain('numexample.com').then((result) => {
  console.log(JSON.stringify(result));
}, (err)=>{
  console.error('ERROR: ', JSON.stringify(err));
});

FAQs

Last updated on 17 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc