Consica Labs

Consica Labs
Chapter 7

APIs — How Apps Talk

How apps communicate with each other

Introduction

When a weather app shows you today's forecast, it does not have its own weather station. When you log into a website using Google, the website does not store your Google password. In both cases, apps are talking to each other through APIs — Application Programming Interfaces.

An API is a messenger. It allows one piece of software to request data or services from another piece of software in a structured, predictable way. APIs are the glue that connects the modern internet — every app you use relies on dozens of APIs working behind the scenes.

In this chapter, you will learn what APIs are, how they work, real-world examples, and why they are essential to modern software.

How It Works

An API defines a set of rules that allow two applications to communicate. One app sends a request to the API endpoint (a specific URL), usually including authentication and parameters. The API processes the request, queries its own backend or database, and returns structured data — most commonly in JSON format.

Restaurant Waiter Analogy

You (your app) tell the waiter (the API) what you want from the menu (the available endpoints). The waiter goes to the kitchen (the backend), gives the order to the chefs (server code), and brings your food (the data) back to you. You never enter the kitchen — you only talk to the waiter. The menu tells you what is possible.

Real-World Examples

APIs are everywhere. Here are some common examples:

Weather App

Calls a weather service API (like OpenWeatherMap) to get current conditions and forecasts for your location.

Maps App

Calls the Google Maps API or Mapbox API to display maps, get directions, and search for places.

Login with Google

A website uses Google's OAuth API to verify your identity without ever seeing your password.

Deeper Dive

APIs typically return data in JSON (JavaScript Object Notation) — a lightweight, human-readable format that is easy for computers to parse. A JSON response from a weather API might look like: {"temp": 22, "condition": "sunny"}.

Many APIs are third-party APIs — services built by one company that other developers can use. Twitter has an API, Stripe has a payment API, Twilio has a messaging API. This is called integration — combining different services through their APIs.

Most APIs enforce rate limits — they restrict how many requests you can make in a given time period. This prevents abuse and ensures fair usage for all developers. A free weather API might allow 1,000 requests per day, while a paid plan allows millions.

Key Insight

APIs are the reason modern apps can be built so quickly. Instead of building everything from scratch, developers integrate existing APIs for payments, maps, messaging, AI, and more.

Advanced

At a deeper level, apis — how apps talk involves rules and patterns that engineers use worldwide. API follows standards so different brands and devices can still work together. That is why your phone, school laptop, and game console can all connect to the same network or use the same apps.

JSON does not happen in a straight line. Systems often use backup paths, error checking, and retries so information arrives correctly. When something fails, smart Endpoint helps the system recover instead of shutting down completely.

Scientists and engineers keep improving these systems every year — making them faster, safer, and more energy-efficient. The ideas you learn in this chapter are the same building blocks used in real data centers, robots, apps, and websites around the world.

Vocabulary Table

Term Definition
APIApplication Programming Interface — a set of rules that lets software applications communicate
JSONJavaScript Object Notation — a lightweight data format used in API responses
EndpointA specific URL where an API can be accessed (e.g. /api/weather)
Third-party APIAn API built by an external company or service for other developers to use
IntegrationConnecting different software systems together, often through APIs
Rate LimitA restriction on how many API requests a client can make in a given time period

Fun Facts

The term API was first used in 1968 in a paper about data structures. The concept is older than the internet itself.

Google Maps API is used by over 10 million websites worldwide. It processes billions of requests every day.

Twilio's API handles over 1 trillion API requests per year for SMS, voice, and video communications.

Stripe's payment API processes billions of dollars in transactions every year for millions of businesses.

The OpenAPI Specification (formerly Swagger) is the standard way to document REST APIs — it lets developers explore an API without writing any code.

Interactive Diagram

Launch the interactive diagram to see this in action.

Open Interactive Diagram

The interactive diagram for this chapter demonstrates APIs. It shows an API acting as a messenger between two applications, translating requests and responses.

What to explore:

  • click an app to make a request; watch the API receive it, translate it, and forward it; see the response come back through the API
  • an API (Application Programming Interface) is a contract that allows different software applications to communicate with each other

Knowledge Check

1. What does API stand for?

Answer: Application Programming Interface

2. In the restaurant waiter analogy, what does the waiter represent?

Answer: The API (messenger between customer and kitchen)

3. What format do most modern APIs use to return data?

Answer: JSON