AND ANSWERS WITH SOLUTIONS 2024
Three Reasons to Use APIs - ANSWER Automation Tasks
Data Integration
Functionality
Two types of API Styles - ANSWER Synchronous APIs
Asynchronous APIs
When are APIs Synchronous - ANSWER APIs are usually designed to be synchronous when the data for
the request is readily available, such as when the data is stored in a database or in internal memory. The
server can instantly fetch this data and respond back immediately.
Benefits of Synchronous APIs - ANSWER Synchronous APIs enable the application to receive data
immediately. If the API is designed correctly, the application will have better performance because
everything happens quickly. However, if it is not designed correctly, the API request will be a bottleneck
because the application has to wait for the response.
What feature does synchronous programming use to handle requests - ANSWER Client side processing
what is a Synchronous API - ANSWER Synchronous APIs respond to a request directly, usually providing
data (or another appropriate response) immediately.
what is a Asynchronous API - ANSWER Asynchronous APIs provide a response to signify that the request
has been received, but the response won't have any actual data. The server processes the request, which
may take time, and sends a notification or triggers a callback with the data after the request has been
processed. The client can then act on that returned data
, When is a API Asynchrnous - ANSWER APIs are usually designed to be asynchronous when the request is
an action that takes some time for the server to process, or if the data isn't readily available. For
example, if the server has to make a request to a remote service to fetch the data, it can't guarantee that
it will receive the data immediately to send back to the client. Note that just because an API is
asynchronous doesn't necessarily mean that the client won't get the data immediately, just that
immediate data isn't guaranteed.
Benefits of Asynchronous APIs - ANSWER Benefits of an asynchronous API design
Asynchronous APIs enable the application to continue execution without being blocked for the amount
of time it takes for the server to process the request. As a result, the application may have better
performance because it can multi-task and make other requests soon after. Unnecessary or excessive use
of asynchronous calls can have the opposite effect, however.
what happens on the client side for Asynchronous APIs - ANSWER With asynchronous processing, the
design of the API on the server side defines what you want to do on the client side. Sometimes the client
can establish a listener or callback mechanism to receive these notifications and process them when
they are received. Also depending on the design of the application, your client may also need a queue to
store the requests to maintain the order for processing. Other API designs need the client to have a
polling mechanism to find out the status and progress of a given request.
Three most common API Architectures - ANSWER RPC- Remote Procedure Call
SOAP - Simple Object Access Protocol
REST - REpresentational State Transfer
What is RPC API - ANSWER Remote Procedure Call (RPC) is a request-response model that enables an
application (acting as a client) to make a procedure call to another application (acting as a server). The
"server" application is typically located on another system within the network.
How does RPC work? - ANSWER In the most common usage of RPC, the client makes a synchronous
request to the server and is blocked while the server processes the request. When the server is done
with the request, it sends a response back to the client, which unblocks its process. (This doesn't apply
for asynchronous requests, remember.)