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) Introduction to Node.js The Tools at our Disposal

APIs

I have checked wikipedia etc, and I'm pretty sure I have worked with them already, but I still don't really get what APIs are!

Could anyone explain them in plain language? I think it would really aid my development.

5 Answers

Kevin Korte
Kevin Korte
28,135 Points

API stands for application program interface.

It's a way for you, the developer to interface with said application. And API sets the rules for how we shall communicate with it. It'll detail what requests you can send to the server, what the server expects, and how to get data back out.

So through an API, I can get data out of that website's database. I might be able to cause an action to happen through an API.

For instance a basic weather API, might mean on my website, when a visitor loads the page, I send a simple API request, and the weather's server returns to me information on what the weather is like. I can than display that weather on my own website.

More advanced usage of API's allow you to take action. For instance, if I had a task manager with an API, if the user validated their task manager credentials with my site, than say when they took action on my site, I could send an api request to modify a task on their task manager site.

All this to say, and API is simply a way for two websites to communicate to each other.

Nejc Vukovic
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Nejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 Points

Hi.

Well I'm not sure if I'm the right person to explain, but humour me and let me try.

Application Programming Interface (API) in plain could be explained as sets of rules how to use the implementations and how to use functions it has, how to declare variables, get data from the API, what to use when referring to it's methods and how.

It's like when you add a Node.js module from GitHub and the README.md contains the initial guidelines how to use the bundled module: how to implement it, pass in configurations how to get it working in your project ( without breaking the module itself and your own app).

For any given API you can see the documentation what happens when you request data from it and how will it be represented back to you in the response. And in what way you should request the data to get the right output and in the way you want it to.

If anybody finds this 101 faulty please share the right info - would like to get my knowledge updated if not right.

Regards.

Thanks for the answers!

So an API is an interface for an application that you use when programming to integrate that application into yours?

Kevin Korte
Kevin Korte
28,135 Points

Correct, to clarify it's not a graphical user interface, it's all code based.

For instance, one more example. I built a test site that had a monthly subscription feature like treehouse. I let web service stripe actually manage the subscriptions of the users on my site. So when a user subscripbed, I made an API call to stripe to let them know, stripe issued a customer id, and added that customer to the plan, I received the stripe customer id and stored it in my database for future reference.

If the user wanted to change their subscription, they did that on my site, and through another API call to stripe, I passed along the details of what just changed, so stripe could update the customer in the plan.

If the customer wanted to see their account details, I would send a request to stripe for it, stripe would send back details like the last 4 of the card, what plan they were on, when their next billing date was, etc. In evey sense, stripe was the master, and through api calls I was able to keep my database in sync with stripe.

And all of this from never leaving my site. The user never knew I was using stripe.

Great - thanks!

Anthony c
Anthony c
20,907 Points

I asked this question today, and received some helpful answers:

https://teamtreehouse.com/community/what-is-an-api-in-plain-english

look at big boy showing off -_-