r/AskProgramming • u/cellwall-999 • Mar 26 '20
APIs Explained ...
I dunno but I don't understand APIs fluently. Does anyone know of an informative article or perhaps a website or just personally explain to me frankly wtf APIs are an why we need them ...
Edit: Thanks everyone for your empathetic contributions. Guess what; I have a better understanding of APIs now than I did before.
53
Upvotes
7
u/SeerUD Mar 26 '20
Your application needs data, programmatically, so you fetch that data from some remote source via the remote source's exposed interface. API - application programming interface. That's basically the what.
Interface here is the bit that's probably most confusing; the interface is really just something you know the shape of that you can "call".
"API" really is that vague by the way. APIs aren't always web services, or remote services of any kind. Libraries that you consume when building applications have an API. It's just something you consume programmatically in your application to do something. What most people talk about when they say API though is "web service" or something similar (e.g. a REST API, maybe a gRPC service, that sort of thing).
Why do you need them? Well, can your application do literally everything on it's own? Probably not. And there might be someone that's already built what you need. Maybe it's someone on your own team. So you would use an API to centralise that logic / data and use it in many places.
An example; you want to get weather information for your home town. There's almost definitely someone who already has that data, and has publicly exposed it via an API. You can use their API to fetch the data and use it in your application.