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 Interactive Web Pages with JavaScript JavaScript and the DOM Where to Look for Help - Documentation

What is an API?

Hello!

I am not clear on what an API is.

I don't recollect it being covered in previous videos, and I have researched it outside of Treehouse to little avail.

My understanding of it would be that and API is a way to communicate with a server? But how? Through what type of code?

Can anybody offer a layman's explanation?

Thank you in advance.

Hi Jennelle, Thanks for asking this question because I too wondered what the heck API is as you're correct, it's not explained previously.

5 Answers

Hey,

Happy Holidays, an API is an application programming interface which allows people who have access usually to an API key to get certain data. For instance, if I wanted live weather updates, I might use an online platform with an API to get live weather updates. I would write some code and that would display my results.

Try this link: http://stackoverflow.com/questions/7440379/what-exactly-is-the-meaning-of-an-api

You could also try out the Ajax Basics course on treehouse.

Course: http://teamtreehouse.com/library/ajax-basics

Regards,

Richard.

Thanks guys! All these answers really helped. Just to put it up here for easy access, this is the content of the link Richard Duffy recommended:

What is an API?

An application programming interface (API) is a particular set of rules ('code') and specifications that software programs can follow to communicate with each other. It serves as an interface between different software programs and facilitates their interaction, similar to the way the user interface facilitates interaction between humans and computers.

How is it used?

The same way any set of rules are used.

When and where is it used?

Depends upon realm and API, naturally. Consider these:

The x86 (IA-32) Instruction Set (very useful ;-) A BIOS interrupt call OpenGL which is often exposed as a C library Core Windows system calls: WinAPI The Classes and Methods in Ruby's core library The Document Object Model exposed by browsers to JavaScript Web services, such as those provided by Facebook's Graph API An implementation of a protocol such as JNI in Java

Richard Nash
Richard Nash
24,862 Points

An API is a gateway to somebody else's data. To get a twitter feed or Facebook post or a SoundCloud song, etc... you use an API. This is different from embedding using something like an iFrame, which is basically a little website within another website. Using an API gives you more control over the data you retrieve and how you present it.

Hope that helps clarify things a little more for you :-)

Kevin Korte
Kevin Korte
28,149 Points

Richard covered it. It allows you to get data from other services. For instance if you wanted to display the weather on your website. As far as the language, that's up to you.

Here are some code samples in multiple languages from a weather API

http://www.wunderground.com/weather/api/d/docs?d=resources/code-samples

Jeremy Castanza
Jeremy Castanza
12,081 Points

I liked Richard's explanation of API, but wanted to see if I'm getting this straight with relation to this course on Javascript and the DOM.

If we're viewing APIs in the context of a conversation between two systems or pieces of technology (i.e. a gateway to someone else's data), is it fair to say that the DOM serves as an API between a given browser's data and the Javascript programming language?