Haider ali
Haider ali's Blog

Haider ali's Blog

Tired of finding api on google?

Tired of finding api on google?

Haider ali's photo
Haider ali
·Sep 21, 2021·

2 min read

I know its very hard to find apis, it takes ages to search for a good api. Well apiwrappers.js got your back, the developers of apiwrappers.js are finding the best apis on the net, making useful functions out of them and now they published this package, which is open source. In what why can this help you?

When they're first version came, they made functions which used promises for example

randomfunc().then(data => console.log(data))

Suppose randomfunc is an api wrapper function which gives you some random jokes, so the problem with promises were that you have to use .then or if you use Aysnc/Await, it would be same like you do a fetch request so what they did is now they made functions which work asynchronous and they take a callback function. Well this has not been applied to all functions only, two of the apis are using this because they wanted to know how the community responds to them, whether they like it or not. We today will show you some of the very good apis they have wrapped. Lets get started

Before we see some examples, here is the list of apis they have wrapped:

  • Chuck Norris API
  • Animal API (Cats, Dogs, Fox and etc)
  • Apple API
  • DadJoke API
  • Oxford API (One of the best ones, used by Google)
  • Meme API
  • Urban Dictionary
  • Currency Converter

Step One, install the package:

npm install apiwrappers.js

Step Two, import it using ES6

import { nameOfTheFunction } from 'apiwrappers.js'

Ok now lets get started with examples:

import { getChuckNorrisJoke } from 'apiwrappers.js'
getChuckNorrisJoke().then(data => console.log(data))

Again I'm saying, they will soon replace all of the functions from promises to callbacks in the next major update.

ChuckNorris api hmm nice, now lets see the Oxford: First of all get your Oxford api key from developer.oxforddictionaries.com and then come back to test the example.

import { Oxford } from 'apiwrappers.js'
const api = new Oxford(appId, appKey, language="en-gb")

api.getWordDefination('people').then(data => console.log(data))

Wow, I just got the definition of the word people, this is cool. Right?

Well here is some of the examples of apiwrappers.js

I'll some of the important links:

Share this