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 Node.js Basics (2014) Building a Command Line Application Preparation and Planning

4 Answers

Alex Gervais
Alex Gervais
5,290 Points

At its most basic level an Application Programming Interface (API) helps different software applications interact/communicate with each-other. Let's say Google developed an application (ex. google maps) and you wanted to include part of it in your website, they provide an API (an interface) that defines the rules for how your website can 'talk' to google maps and retrieve the information it needs. Take a TV for example, without the buttons on the remote or front of the TV, we wouldn't be able to tell the TV to turn on, change channel, or do anything. It's the same with applications, it needs to have an interface so other applications can communicate with it.

In Node Js for example: console.log();

console is an API

var http = require('http');

http is an API.

So, these are pre defined node objects which are also called as APIs. These are interfaces, a middle ware to program an application.

Vedant Laskar
Vedant Laskar
6,755 Points

just to added on top of that, an API is a function that does the job for you.

To add to Alex's response, you can also think of an API as a way to call other "Native" API's as well. For instance, there is a really nice technology that I'm building with right now called "NativeScript". https://www.nativescript.org/. This technology allows you to build Native mobile apps in JavaScript!!!! Really exciting, but with their API, you can "call" Android and IOS hardware with their methods, and their build system translates it to Java and Objective-C so it can run independently from the web on a mobile phone. My point in this rant is to not limit yourself to just the web and its technology. There is a lot of exciting stuff going on with hardware/javascript as well.

https://developer.mozilla.org/en-US/docs/Web/API

Check that link out. If you would like some abstractions, or have more questions, I can give some more examples and answers.