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.

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
210,155 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
210,155 Points

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