Working with APIs

API stands for Application Programming Interface. They are used to connect us to all sorts of useful information that we use everyday. The way it works is by calling an API with a request for data. Usually this is called a GET request, and it is sent to a provider of information with a set of parameters. The parameters help identify the kind of data you want to receive from the provider. Recently my team and I did a project using the Cornell Lab of Ornithology’s eBird API. Our app was used to gather recent bird sightings and displayed them on a map for our users to see. For this purpose our API call looked like this:

const request = require('request-promise');
request('http://ebird.org/ws1.1/data/obs/geo/recent?lng=90&lat=40')
.then((data) => {
cb(data);
})
.catch((err) => {
console.error(err);
});
},
};

We queried this API for birds within given coordinates and in return we got our data in json format.

{ lng: -90.0632465,
locName: 'Woldenberg Park',
howMany: 2,
sciName: 'Leucophaeus atricilla',
obsValid: true,
locationPrivate: false,
obsDt: '2017-06-27 14:41',
obsReviewed: false,
comName: 'Laughing Gull',
lat: 29.9524014,
locID: 'L947421' },

We were able to use this data in all sorts of ways to make our app educational and fun for our end users. There are a ton of API’s out there that can add some great info to your next project.