0.0.7 • Published 7 years ago

getyourbit v0.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

GetYourBit.com client

This library allows you to make requests easily.

Examples

const GetYourBit = require('getyourbit');
const api = new GetYourBit.Api('https://ip.getyourbit.com');

api.auth('login', 'password').then(() => {
  return api.request('/lookup/8.8.8.8/');
})
.then((body) => {
  return api.request('/me/', {locale: 'en-US'}).then((body) => {
    console.log(body.data);
  });
})
.then((res) => {
  return api.scroll('/find/', {
    size: 500,
    query: {
      country: 'nepal'
    }
  }, (body, chunkData, fullData) => {
    console.log(chunkData.length);
  });
})
.then((fullData) => {
  console.log(fullData.length);
  return api.logout();
})
.catch((err) => {
  console.error(err);
});

Api

.auth(login, password, options={})

Login to the API. You can get login and password on the site after a subscription.
options is request module options.
Free services don't require authorization.

.logout()

Logout from the API. It gives an error without authorization before.

.request(url, data={}, options={})

Request to the API without scrolling to get data.
It returns all response body as object.

.scroll(url, data={}, options={}, callback=null)

.scroll(url, data={}, callback=null)

.scroll(url, callback=null)

Request to the API with scrolling to get data. You can pass callback to control every chunk. You will get three arguments:

  • body - chunk response body
  • chunkData - chunk data
  • fullData - full data by the current chunk

It returns the full data at the end

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago