DEV Community

Cover image for Tired of finding api on google?
Haider Ali
Haider Ali

Posted on

Tired of finding api on google?

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))
Enter fullscreen mode Exit fullscreen mode

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'
Enter fullscreen mode Exit fullscreen mode

Ok now lets get started with examples:

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

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 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))
Enter fullscreen mode Exit fullscreen mode

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:

Top comments (0)