Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics (retiring) AJAX and APIs What Is an API?

what is exactly API ?

i wondering about API. after i searching on google and many website, i got many definition about it and make me confused about what is exactly API. anyone who can explain to me what is exactly API? that is just way or software ?

1 Answer

Dane Parchment
MOD
Dane Parchment
Treehouse Moderator 11,075 Points

An API or more aptly Application Programming Interface is basically a library of code that allows programmers to interact or get information from an external source.

Let's say you are tasked with creating a specific feature for your application. Say you have to get the weather in a logged in user's location, to determine if your app should give them coupons for say rainy day gear, or outdoor activity items.

Your app however, does not have a real-time database for gather weather. So after searching online you come across a database for weather in any location around the world from NOAA. It would be great if you could have access to their database, but that won't be possible since you don't work for them. However, after further research on their site, you notice that they have an API, perusing around on it you realize that you can send a GET request to their API and get back JSON of the weather in a location you specified in the GET request.

Using that you are able to send a GET request and retrieve the necessary data so that you can finish creating your feature.

What I just described is how you would use an API to get data from an external source that you don't actually have access to, but instead are given some access through the use of an API.

thank you dane! now, i got it....