ELI5: What is an API exactly?

r/

I know but i still don’t know exactly.

Edit: I know now, no need for more examples, thank you all for the clear examples and explainations!

Comments

  1. embassyrow Avatar

    In simple terms: It’s how computer systems and software talk to each other and exchange information (aka structured data).

  2. GendoIkari_82 Avatar

    The word has 2 related but different main meanings.

    1. Any piece of code that other programmers can call to do stuff so that they don’t have to write everything from scratch. So if I’m writing a program and want to resize the window, I don’t have to interact directly with the internal workings of Windows code to do that; I can just call an API that microsoft provides to do it.

    2. A URL that a program can call to get or send information. Basically the same thing as a website, except instead of returning HTML data that you see in your browser, it returns data in other formats that your programming language can read and interact with.

  3. USAF_DTom Avatar

    Think of it like a bridge. You are new to an area. You don’t know where the bridge goes but you know that it connects to something like the piece of land that you are currently on. You can talk with people over on that other side, and share ideas and information, without really knowing who they are because of this bridge. That’s what an API is. A bridge to different programs.

  4. fixermark Avatar

    Application Programming Interface.

    You know how, like, Microsoft Word has rules for what the interface does to make your document? “Click here to open a menu, right-click on this text to get a menu, press this button to make the text bold, typing on your keyboard will add text but only if the document window has keyboard focus,” and so on?

    APIs are those rules for software libraries that make whatever. “To make this play music, call this function with a filename to load. Then call ‘play’ to get an object back that represents the sound being played. You can call ‘pause’ on that object to halt the sound,” and so on. It’s the rules for the code to write to make things happen in someone else’s code.

    Much like you can use Word without knowing any of the lines of code inside, a good API lets you use the library or other program from your own program without knowing any of the code inside (though, to my experience, those are rarer than you’d hope!).

  5. TheLuminary Avatar

    An API is a programming interface. Its how different applications allow themselves to be interacted with.

    Think of an API as the internal version of a user interface. The API defines how other programs can talk to it, what they need to do to get specific information and what information needs to be provided to have the program do actions that other programs want done.

    For a very basic example of an API, think of a lock.

    A lock has two endpoints. One is the keyhole, the other is the latch.

    You can check the state of the latch, by pulling on the latch. You can also check the state of the keyhole by looking at the keyhole.

    You can also open the latch, by providing a correct key into the keyhole endpoint and executing the operation through a turn.

    You can then check the state of the latch again, to verify that the open operation succeeded.

  6. europeanputin Avatar

    Well, you and me, we have a conversation. It’s in English, but we know the rules of the language – how nouns work, how to use plural, the tenses and so forth. English is just one of many languages people use to converse. API is like a language for computers to converse. It could be structured in many ways, but it’s essentially one computer giving information to another. Depending on how it’s built, another may need to respond immediately or not respond at all.

    Some of the most famous languages of API are JSON and XML format. It offers a clear structure of how certain data must be communicated between one another, so that the developers need to only worry about what is communicated, not how it’s communicated.

  7. adsfew Avatar

    The active pharmaceutical ingredient is the compound or molecule in a medicine or drug that is responsible for the therapeutic effect.

    Drugs do contain other molecules in their formulation that can improve traits like stability or drug delivery that play a key role in the drug’s efficacy. The brand-name vs generic may have the same API, but changes in formulation can affect how effective it is. Sometimes the same manufacturer has changed their formulation and then realized it was worse for the performance of their medicine and had to revert it.

  8. thecuriousiguana Avatar

    You know when you drive up to the order point at a McDonald’s?

    And you’ve read the instructions on the menu. So you can say “Big Mac, medium fries and Coke please”.

    And the guy might say “do you want to have a large meal for an extra dollar?”

    And you agree.

    Then he hands over a card machine. And you know what to do, you put your card in and type your number. And he gets your money.

    And then he tells you where to go to get your food. And the order is right, exactly what you wanted

    That’s an API.

    A set of instructions that you (a piece of software) can exchange with the system (the McDonald’s) with a set of rules to follow, such that they can exchange information and end up getting what each wanted.

    Try driving to the wrong spot, telling that you want “yeasted baked dough, split with minced up cow that’s that’s been heated and denatured with the fruit of a nightshade related plant, some leaves, bacteria aged milk and boiled, pureed vegetable mush, served with deep fried tuber and phosphoric acid with flavours” then throwing down an amount of gold that should cover it. You won’t get your meal and you’ll be asked to leave, even though you did in fact say what you wanted. But you didn’t follow the agreed rules for the interaction, so they didn’t understand.

    .

  9. jdoe5 Avatar

    Stands for Application Programming Interface. I think the key word there is “interface”. It defines the rules and details about how two things work with eachother.

    An analogy would be at a restaurant. The waiter/waitress would be the API between you and the kitchen.

    I think part of what makes it confusing is that it’s so abstract. To understand it better it makes sense to think of it in regards to a specific application.

  10. TattooMyInitialOnYou Avatar

    In essence, it’s a set of rules for getting information: you ask like this, I will respond like this.

    Having a standardised, published, set of rules means that anyone can ask a question and get a response in a standard way.

    Without an API, you need to be sneaky to ask a question, usually by listening in on the “conversation” with the official way questions are asked, and then pretending to be them.

  11. berael Avatar

    An API is a menu.

    If someone wants to give you access to their food, but not to their kitchen, they give you a menu. Now you know what you can order.

    If someone wants to give you access to their program, but not to their code, they give you an API. You can use the API to ask the program for information and to send information to the program, but you can only “order from the menu” and you can’t get into the code directly.

  12. ProMensCornHusker Avatar

    If you think of “programs” as countries, then API’s are like a shipping route for information between countries, but you have to plan and build the shipping routes.

    APIs are how programs are able to “talk” to each other and interact.

    (That’s like super generic but this is ELI5)

  13. BronchitisCat Avatar

    API stands for Application Programming Interface. In the most basic, simple definition, it’s a way for a programmer to interact with someone’s code without having to actually understand how their code does what it does.

    Think about a car – you press gas pedal, car goes faster. You press brake pedal, car goes slower. You turn this circular steering wheel thing, and car moves in that direction. That’s all you need to know in order to operate the car. You don’t know (and, specifically, you don’t need to know) how “under the hood”, the fuel is being injected into the engine, how the intake manifold, serpentine belt, transmission fluid, brake calipers, etc. are all working together to carry out your command of “Car go faster”, “Car go right”.

    Programming is very similar. I may write some code that doesn’t something super complicated, like encrypting and transmitting credit card payment details over the web. You come along and want to create some e-commerce website like Amazon. You know how you want it to look, you know that you want people to be able to pay with a credit card, but you don’t know how all that stuff works. So rather than trying to research and figure out how to handle end to end encryption, you can instead just access my code and tell your code “When a user hits the submit button, grab the credit card number in this field, then go to this other guy’s code and do this function called submit_payment. Here’s the dollar amount and the credit card number that that function requires to work.

  14. pie-en-argent Avatar

    Application

    Programming

    Interface

    In the most common context (a web site), it’s a way the website owner creates for other programs to incorporate its functionality.

    To bring that down to the ELI5 level, let‘s consider a simple one, random.org—a website that generates random numbers. If you visit the site and ask for random numbers, it provides them in a nicely formatted web page, which is great if you want them for human consumption.

    Bus suppose you’re writing a program that will use the numbers. All the extra stuff that makes it look good is worse than useless in that context. Instead of making you dig through that stuff, they provide a special URL that you can add parameters to (to specify how many numbers, what range, etc.) and get the result back in a raw machine-readable format. That URL, and the set of parameters you use with it, is the site’s API.

  15. doglywolf Avatar

    So you can ask a computer your sitting at for info from file on it very easily . (Excel or SQL query)

    API is just having one computer here , ask another computer there for info from that file the same way just over long distances.. Basically just adding the computers phone number in the request and wording a the same request in a different way and the other computer being like ok this checks out , here you go you can have this info.

    It can also work the other way where you are telling the other computer to do something for you depending on what instructions are set up and allowed on the other end.

  16. EclipseQQ Avatar

    Imagine it as a way two systems or software components talk to each other, like how a plug connects to a socket to transfer power.

    The Plug: Think of this as the software that wants something from the system (like a device, application, or service). For example, if you’re using a weather app, the app is the “plug” wanting to get data about the weather.

    The Socket: This is the system that provides the service (like a weather database, payment service, or a third-party application). It has a specific way (protocol) that it accepts requests, just like a socket has a specific shape that fits the plug.

    Now, here’s how the API fits into this analogy:

    API = The Connector/Standard: An API is like the interface of the socket that specifies how the plug (the app or software) should connect to the system. Just as a socket has a particular shape and wiring that fits a plug, an API has specific rules (like what data to send, the format, and which requests are allowed) that the plug (your software) must follow.

    When the app (the plug) is connected to the service (the socket) through the API, it can request data or perform actions. The API ensures the connection works smoothly and securely, allowing the two to exchange information, much like how plugging into a socket lets you use electrical power.

    So, the API makes sure the “plug” and “socket” fit together properly, allowing them to communicate. Without the API (like without the right socket), the plug can’t connect or get the service it needs.

  17. halkun Avatar

    When you program a computer on the most basic level, you don’t have access to anything. If I were to write a C program with no API to access the underlying systems, all I would be able to do is take in arguments from the command line, do simple operations like mathematics and counting, and return a number to the operating system when the program terminates. No graphics, no text, no other input, just a glorified calculator.

    An Application Programming Interface (API) gives a program a way to request things from the computer. It provides commands that makes these system useful. For example, in C you can use the libC API to get a “Print Function” to print text to a screen (printf) , or ask the computer for blocks of memory, (malloc) or ask the operating system to open a file. (open) . There are even more advanced APIs that give you access to the GPU (OpenGL) or allow you to connect to the internet (sockets) An API just gives you a standard way to interface with the computer system for resources so you can do useful things.

  18. L1terallyUrDad Avatar

    Application Program Interface. It’s a way that a front-end application, like the weather app on your phone, can reach out over the internet and consume services. In the example of the weather app, sitting out on the Internet are various weather services. In the case of the iPhone, they are using a service from Weather.com.

    When the front-end app starts up, it will effectively login to the API service and requests data like the current conditions for your location. There are different API formats, but the most common one is RESTful API, which is a standard way that applications can understand the language of the service. The data is returned in a couple of different common languages (XML, JSON) so the application knows what data bits are what.

    When I refer to front-end application, it could be a mobile app, a web browser, or even a back-end process that needs to gather data from other services like maybe a database.