Coder Social home page Coder Social logo

node-dadata's Introduction

node-dadata

Tiny NPM module for the REST API of dadata.ru

usage example

var dadata = require('dadata')(process.env.DADATA_API_KEY, process.env.DADATA_SECRET_KEY);
dadata('address', ['мск сухонска 11/-89'], function (err, res) {
  console.log(err);
  console.log(res);
});

formal docs

Before use, this service must be properly configured: you have to provide your API_KEY and SECRET_KEY to the constructor.

  var DaData = require('dadata'),
      dadata_account_1 = new DaData('<API_KEY_1>', '<SECRET_KEY_1>'),
      dadata_account_2 = new DaData('<API_KEY_2>', '<SECRET_KEY_2>');

If you don't plan to utilize multiple instances of dadata service, it's also possible to use the short notation.

  var dadata = require('dadata')('<YOUR_API_KEY>', '<YOUR_SECRET_KEY>');

Exposed dadata service is the function of 3 arguments (function (apiType, queries, callback) {...}), where:

  • api type -- one of ['address', 'birthdate', 'email', 'name', 'phone'];
  • queries array -- array of one or more strings;
  • callback -- function (error, result) {...}; if everything's fine, then error is undefined and result contains a dadata response (an array of objects, corresponding to your array of queries); if something went wrong, error will contain an object with code and message fields, and result will be undefined.

node-dadata's People

Contributors

uqee avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.