What is API?

465 viewsEngineeringOther

What is exactly API and why we call it like that? I am learning web development, and always come across APIs. I would love to learn it through an analogy.

In: Engineering

32 Answers

Anonymous 0 Comments

Suppose I’m replacing the kitchen in my house. I start by ripping out everything that is in there so I just have bare walls. I order wood, nails, screws and the other stuff I need to put the new kitchen in, and I use my tools to assemble them into cupboards, counter tops, cupboard doors and things. But then I need to put a fridge and a dishwasher in the kitchen too. In theory, I could order metal, paint, pipes and all the other stuff and build a fridge from scratch, and build a dishwasher from scratch. But instead, I know that there are factories out there that can build a fridge and build a dishwasher far better than I can, for a far lower cost. So i go to the store and buy a fridge someone else has made, and I buy a dishwasher someone else has made, and then all I have to do is find the right electric plug and plumbing connections for water for the dishwasher, connect them up, and I have a fridge and a dishwasher in my kitchen.

This is like building a computer program. Some of the things I want to do myself. I want to have the freedom to customise certain parts of the program to do exactly what I want. In my kitchen I want a specific layout of cupboards and counter tops. So I make those parts myself. But then there are the complicated and hard to make things. An API is a system in a computer that lets me connect up to something someone else has made, that provides a set of functionality far easier and more efficiently than I could ever do myself. An API is essentially a way to connect to something someone else has made. It is like the doors on the fridge or dishwasher and the electrical and plumbing connections. I know how to connect to it, and I know how to get out of it what I want, but I don’t need to understand what is going on inside.

Anonymous 0 Comments

You can think if it as a url, you don’t visit this url on your browser because it doesn’t return a graphical interface like other websites, it returns pure data. So you use it to make requests to the server and get the data you need. Example: when you open the Reddit mobile app it calls the Reddit API sending it your account details and asking it for you home feed, then that API returns pure data (post titles, content, comments…etc) and the app displays it graphically.

Anonymous 0 Comments

If I have an application that processes mortgage applications, and as part of that applications logic, I need to access a database of mortgage rates, an API is a middleman application that I can send a message to “give me the rates”, and it will do the querying, filtering and sorting of the data for me before sending it back in the format my application can work with.

It’s a middleman application between different applications or between applications and data sources.

Based on the other replies i guess there are other types if APIs but in my experience as a middleware API developer, that’s what it is.

Anonymous 0 Comments

If I’m a website and I want to get data from somewhere else, maybe information about the weather or something, an API is what I can use to communicate with the weather service

Another use case is when you have a database with information about a school, for example. The API could allow you to ask for information about the teachers, the students, the grades, enter new information into the database, etc., without you having to write the SQL code to get that data yourself (which is great because you don’t really want anyone to be able to interact directly with the database as they might have bad intentions)

Add someone else said, it’s like a menu. The cooks can probably make a huge variety of things that aren’t on the menu, but that’s not what you want the customer to be able to order. An API lets you request the data the service wants you to have access to and nothing else (hopefully)

Anonymous 0 Comments

It’s an access point really. You have some server that you want other people to use. This could basically be anything. You need a way for people to get information and put in information. That’s what an API is an interface for others to use.

Anonymous 0 Comments

You have 2 softwares and you want these two softwares to communicate or share data , so you create a programmed interface which acts as a middleman for this , that’s Application Programming Interface for ya.

Anonymous 0 Comments

In interview questions I ask people to explain an API to someone non technical. It’s amazing how few great developers can do this.

It’s how computers talk to each other.

For a slightly more complicated answer:

One computer provides a service for others, perhaps translation.

The API is the rules for how to use that service.

So it might say you need to provide text and Lang in a querystring like this:

http://translate.com?text=hello&lang=Spanish

And the computer will reply result=hola

Anonymous 0 Comments

It’s the interface to a lot of functionality.

Think of your car. It has a million parts and a LOT going on.

But you don’t care about those million parts. You care about the layer between you and that complexity.

So to you, you have “start the car” as an option. Push the gas, the brake, turn left or right, maybe go in reverse.

Those controls are your API. They let you control the complexity of a car without knowing anything at all about how the car actually works.

In tech it’s the same thing. You don’t need to know how google works, because you can call an API that just says “search” or “get map of location x,y” or “send this email” or whatever. That layer that lets you use those functions is the API.

Anonymous 0 Comments

You when when you go to a public office or to a bank to get something done you often have to fill out a bunch of forms? That’s an API. It is some sort of standardized way of information exchange that whoever performs the service understands. It can be an office, a bank, a utility piece of software, or a computer server. Your program uses APIs to get things done. The API describes what can be done, and what information is required to get it done.

Anonymous 0 Comments

It’s a description of an interface. For example when i use a web API i could send json data in a POST to make the website do something like search for data. The would describe the fields i need to put in that json like (“search”:”<string>”). Once the API is documented and written in stone essentially, I can write code against it because it should not change. Also, extra fields like “uppercase”: True, help to describe the API’s capabilities. There maybe dozens option flags/values to tweak the search results or it could only need the search string. Knowing this you can write your code to take advantage of some all or none of its features. But at the end of the day a human looks at a web page, but an app or a machine does’t need the pretty UI, they can use the API to get the data.