Learning Library

← Back to Library

Synchronous vs Asynchronous API Communication

Key Points

  • Synchronous communication occurs when a user initiates an action (e.g., checking balance or updating address) and waits for an immediate response from the app.
  • Asynchronous communication lets the system notify the user independently of a request (e.g., alerts about suspicious activity) so timely action can be taken.
  • Event‑driven integration patterns such as webhook callbacks and publish‑subscribe messaging provide efficient ways to handle asynchronous interactions.
  • Apache Kafka is a leading open‑source event‑streaming platform where producers publish events to topics that consumer applications (like a mobile banking app) subscribe to for real‑time data.
  • The AsyncAPI specification defines message‑driven, protocol‑agnostic API flows, enabling consistent design and documentation of asynchronous APIs.

Full Transcript

# Synchronous vs Asynchronous API Communication **Source:** [https://www.youtube.com/watch?v=3ij-rga08H4](https://www.youtube.com/watch?v=3ij-rga08H4) **Duration:** 00:07:09 ## Summary - Synchronous communication occurs when a user initiates an action (e.g., checking balance or updating address) and waits for an immediate response from the app. - Asynchronous communication lets the system notify the user independently of a request (e.g., alerts about suspicious activity) so timely action can be taken. - Event‑driven integration patterns such as webhook callbacks and publish‑subscribe messaging provide efficient ways to handle asynchronous interactions. - Apache Kafka is a leading open‑source event‑streaming platform where producers publish events to topics that consumer applications (like a mobile banking app) subscribe to for real‑time data. - The AsyncAPI specification defines message‑driven, protocol‑agnostic API flows, enabling consistent design and documentation of asynchronous APIs. ## Sections - [00:00:00](https://www.youtube.com/watch?v=3ij-rga08H4&t=0s) **Untitled Section** - ## Full Transcript
0:00to understand async API and why it's 0:03important we first have to talk about 0:05two key Concepts 0:15those include synchronous communication 0:20and asynchronous communication 0:26let's say you just downloaded a mobile 0:29app let's take a mobile banking app for 0:32this example there are two sides that 0:35make up a great user experience 0:37first Sometimes you want to engage the 0:41app 0:49let's say it's that time of the month to 0:51pay your bill and you need to make sure 0:54that you have enough money in your 0:55account to cover it 0:57so 0:58you go into your account 1:01and you view your current balance you'd 1:04expect 1:06a response 1:09that's an answer to your question so 1:11you're asking the app what's my current 1:13balance 1:19let's say 1:20that answer was 1:22five hundred dollars 1:24let's also say you just moved into a new 1:27place and you need to update your 1:29mailing address with your bank so again 1:32you go into your app 1:34you go to Account Details and you update 1:40your address again your 1:43asking the app to update your address 1:46and you'd expect a response confirming 1:51that change was made 1:54so your address same 1:56in this situation this represents 1:59synchronous communication because both 2:01the application and the user are engaged 2:04at the same time 2:06other times the app wants to engage you 2:22so you open up your phone and you go to 2:26your you go to your mobile banking app 2:28and you see that there was a 2:30notification of 2:33suspicious activity 2:36detected on your account 2:39so there was a transaction on a remote 2:40system 2:42and this information was shared with the 2:45user it's really important in this 2:48situation for the user to be notified as 2:51soon as something happens so that they 2:54can act quickly 2:56you wouldn't want to have to go into 2:58your account every day to see if it's 3:00safe and secure you just want a need to 3:03be told when your account might be at 3:05risk 3:06so for this situation since the 3:09application and the user do not have to 3:12be engaged at the same time it 3:15represents asynchronous communication 3:19event-based approaches to integration 3:22like webhook callbacks or publish 3:25subscribe messaging Solutions are a more 3:28efficient way to facilitating 3:29asynchronous interactions 3:32Apache Kafka has emerged as a leading 3:37open source event streaming platform 3:39with Apache Kafka 3:42streams of events 3:44are published 3:48to topics 3:50that consuming applications like our 3:52mobile banking app can subscribe 3:55directly to 3:56for real-time access 3:59to business critical data 4:07and there are many uses for 4:09Apache Kafka 4:11take our mobile banking app example 4:14let's say they send you a personalized 4:17promotional offer 4:19based off of your account exceeding a 4:23certain limit 4:24or that you engaged in a level of of 4:28high spending that's a perfect example 4:31where it could be used 4:33so now that we have this understanding 4:36of both synchronous communication and 4:38asynchronous communication we can bring 4:41async API back into the picture 4:44to understand what it is and and how 4:46it's useful so the async API 4:49specification is used to describe 4:52message driven API flows it's protocol 4:56agnostic so you can use it for apis 5:00that use any asynchronous protocol 5:03for our situation 5:07were 5:11were using it as a specification to 5:14describe events on Kafka topics 5:32and this is really important because 5:35it's much like 5:38an open API 5:45which is used as a standard for 5:47describing 5:48apis 5:52events they they must be described in a 5:55way that captures enough information so 5:58that the user can make good use of it so 6:02essentially so you can build those Ultra 6:05responsive applications 6:08that we we talked about earlier 6:11but it doesn't stop it being described 6:13events they also have to be 6:17discoverable 6:26and when they're described it not only 6:28includes technical information but also 6:31vital business contacts as well 6:35so coming full circle 6:37we can use async API specification as a 6:42standard to describe events and we can 6:48use that 6:50when we do API management 6:53good API management 6:55when we're managing events across the 6:57Enterprise 6:59thank you if you like this video and 7:01want to see more like it please like And 7:03subscribe if you have questions please 7:06drop them in the comments below