1.0.16 • Published 7 years ago

irkfdb-node-client v1.0.16

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

irkfdb.in node client Build Status

NodeJS API Client for the Internet Rajinikanth Facts Database. Its a wrapper class for the free database of Rajinikanth Facts hosted by irkfdb.in

Install

Using npm

npm install irkfdb-node-client

Usage

To get the categories

var irkfdb = require('irkfdb-node-client')

irkfdb.getCategories().then(function (data) {
   console.log(data);
});

Sample Response

{
  "status": "OK",
  "resultSet":
   { "data":
      [ "nsfw",
        "geeky"
      ]
   }
}

In case of API failure, the response would be as follows Sample Response

{
  "status": "FAIL",
  "errMessage": "<err message>"
}

To get the random fact

var irkfdb = require('irkfdb-node-client')

irkfdb.getRandomFact().then(function (data) {
   console.log(data);
});

Sample Response

{
    "status": "OK",
    "resultSet": {
        "data": [{
            "hash_id": "42e9f7c05e6b04bd9bc137ef10e0d86e",
            "db_id": 522,
            "fact": "Rajinikanth can over-write a locked variable.",
            "categories": ["geeky"],
            "sources": ["api.icndb.com"]
        }],
        "total_facts": 100
    }
}

To get the random fact from the selected category/categories

var irkfdb = require('irkfdb-node-client')

// random fact belonging to one category
irkfdb.fromCategories('geeky').getRandomFact().then(function (data) {
    console.log(data);
});

//or for multiple categories
irkfdb.fromCategories('nsfw,geeky').getRandomFact().then(function (data) {
    console.log(data);
});
// OR
irkfdb.fromCategories(['nsfw','geeky']).getRandomFact().then(function (data) {
    console.log(data);
});

To exclude the fact from the particular category/categories

var irkfdb = require('irkfdb-node-client')

// random fact not belonging to one category
irkfdb.excludeCategories('geeky').getRandomFact().then(function (data) {
    console.log(data);
});

//or for multiple categories
irkfdb.excludeCategories('nsfw,geeky').getRandomFact().then(function (data) {
    console.log(data);
});
// OR
irkfdb.excludeCategories(['nsfw','geeky']).getRandomFact().then(function (data) {
    console.log(data);
});
1.0.16

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago