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

Java Unit Testing in Java Why Test? Defining a Unit

What is an API? Can anyone explain with example? There are too many definitions which confuses me.

I am looking for the easiest way to understand in Layman's language with an example. The answer which I can give if anyone asks me question in an INTERVIEW

Steve Hunter Craig Dennis Steven Parker

2 Answers

Steven Parker
Steven Parker
229,695 Points

An API is basically just a set of rules for communicating with a service. What the service does, what you can ask of it, the format for making requests, and what you will get back and in what format. Essentially the "instruction manual" for the service.

Using an API (known as "consuming") is the process of writing code that will follow these rules to send requests to and handle responses from the service.

Implementing an API service is the process of writing the code that will provide the service according to the defined rules.

API examples would include a weather service (like openweathermap.org) or a photo image service (like unsplash.com).

API is working Like a Wetter in Rasturant take the orders go to ketschen and bring the food back.

Steven Parker
Steven Parker
229,695 Points

I think you meant "waiter" but I think of the API as more like the menu.