The problem: systems that do not know each other
Your app needs weather data, or payment processing, or a map. It doesn't have direct access to the other company's database, and nor should it. It needs a well-defined, safe way to ask a question and get a predictable answer back, without knowing anything about how that system works internally.
What an API request actually is
An API defines a contract: send a request shaped like this, to this address, and you'll get a response shaped like that. A request usually says what you want and any details it needs (an order); the response comes back with the result or an error (the plate, or “we're out of that”).
The catch: waiting, and things going wrong
Every request takes time, and every request can fail. The other system might be slow, down, or say no. Good systems plan for this: timeouts so you're not waiting forever, retries for the occasional hiccup, and sensible fallbacks when the answer just isn't coming.
Written by
The Docerity teamEngineers who explain for a living