Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.