This is not an analogy, because sometimes it helps to be concrete.
You know commands that let you request data from your website? It looks something like this:
response = fetch(some_url); // or: an_image_object = giveMeAFile(“cat.jpeg”);
API means Application Programming Interface – programs talking to other programs.
It turns out, you can also request data from other websites, if they are configured that way. Sometimes these servers don’t even serve html to browsers, but only data for programs that request it. A browser uses HTTP to request HTML, but there is nothing that prevents non-browser-applications from requesting non-html-data.
weather_data_response = fetch(“www.example-weather-api.com/give-me-weather”);
console.log(“Today’s weather: ” + weather_data_response.json);
Reddit had some issues with it’s API in the past. I think it was free and they now charge for it. That means that you pay for an API-key, like a username and then you send the key as part of the request, otherwise you don’t get a response.The Reddit API let’s you receive post-data or send new posts programmatically, so you can develop your own app or a bot.
There are also APIs that have nothing to do with the web. You might have a device that can be controlled with software commands. The line between an API and a “library” or a “framework” are blurry. Something can be both an API and a library. I’d say you have an API whenever there are distinct software components talking to each other.
Latest Answers