What Is an API? Requests, JSON, API Keys and Integration

14 min read · Updated: October 23, 2026

An API is the agreed way one program asks another program to "do this" or "give me this data." The asking program does not need to know how the other side works inside. If it asks the agreed way, it gets an answer. The forecast in a weather app and the map on a store's website often arrive this way, through an API, from another company's service.

What you'll learn

  • What an API is an agreement about, and between whom
  • What happens behind weather apps, maps and "Log in with Google"
  • What a web API request and response contain, and how to read JSON
  • Why API keys must stay secret, and why there are limits on the number of calls
  • What "API integration" means at work, and what to check before you connect two systems

Prerequisites: none. Words from IT exams, such as Japan's IT Passport exam, are explained in plain language too.

In everyday life

Open a weather app on your phone, and the forecast for where you are appears at once. But the company that made the app may not watch the sky itself. Often, it asks the server of a company that has weather data: "Please send the forecast for this place." A server is a computer that hands out data when asked.

The same thing happens in other places. A store's website may have a Google Maps map built into the page. A login screen may show a "Log in with Google" button. In each case, one program is asking a program run by another company to do a job.

For this to work, everyone has to ask in the same way. What can you ask for, how do you write the request, and what form does the answer take? An agreement that settles this in advance and is shared with others is called an API. It stands for application programming interface.

An API is an agreement about how to ask

An interface is the place where two things meet and connect. So an API is the agreement used where one program connects to another. The key point is who uses it. It is not made for people working a screen. It is made for programs.

The agreement mainly sets out the following.

  • The names of jobs you can ask for (for example, "look up the forecast")
  • The information to send with a request (for example, the place and the date)
  • The form of the answer (for example, temperature as a number, in °C)
  • The reply when something goes wrong (for example, "that place is unknown")

The asking side gets answers without knowing how the other side calculates the forecast. In turn, the answering side can rebuild its insides, as long as it keeps the agreement. The asking side can keep using it unchanged.

The agreement is usually written down as a document. This is called the specification, or the API documentation.

A weather app sends a request in the fixed way the API defines and gets a reply in a fixed form. The calculations and the database behind the API cannot be seen from outside Weather app Request Reply API (the fixed way to ask) Inside (hidden from outside) Forecasting Database Same agreement: inside can change
The asking side only knows how to use the API, the "service window." Left out: the key that identifies the user (the API key, explained later), the network in between, and the many programs inside the answering side.

Web APIs: asking over the internet

Some APIs, like those for weather and maps, ask a server on the other side of the internet. These are called web APIs. Today, when people say "API," they often mean a web API.

Most web APIs use HTTP, the same rules a browser uses to open a web page. In HTTP, the asking side sends a request, and the server sends back a response. HTTP itself is also covered in "What Does HTTPS Mean?"

The difference from a web page is what comes back. A web page returns text and images for people to read. A web API returns data in a form that programs can read easily.

Let's look at a request and a response for a made-up weather API. The server name "api.example.com" is reserved for examples. It is not a real service.

Example request to a weather API (GET asks for the Tokyo forecast and includes an API key), and the server's response (200 OK with JSON data) Request (asking side → server) GET /forecast?city=tokyo HTTP/1.1 Host: api.example.com server X-API-Key: (secret key) who asks Response (server → asking side) HTTP/1.1 200 OK 200 = success Content-Type: application/json { "city": "Tokyo", "weather": "Sunny", "high": 22 name: value }
An example from a made-up API. The name of the field that carries the key, and the way to ask, differ from service to service. Left out: many other fields, and the encryption added by HTTPS.

"GET" on the first line of the request is the kind of request: "I want to get data." This kind is called the HTTP method. Next, "/forecast?city=tokyo" is what you are asking for. Here it says "the forecast, for Tokyo."

"Host" on the second line is the name of the server. How a name is turned into a machine's number is explained in "How Does DNS Work?" The third line is a key that shows who is asking (more on this later).

"200" on the first line of the response is a number that means "it worked." This three-digit number is called the HTTP status code. Each result has its own number. For example, 404 means the item was not found, and 429 means too many requests.

For designing web APIs, an idea called REST is widely used. Roy Fielding, who helped write the HTTP standards, named it in his PhD dissertation in 2000. A common form gives each kind of thing (such as forecasts or orders) its own address. HTTP methods then say whether to get it, delete it and so on. An API like this is called a REST API.

JSON: a data format programs read easily

The part of the response inside "{ }" is written in JSON (pronounced like the name "Jason"). "application/json" on the second line of the response marks the body as JSON. Each pair joins a name and a value with ":", and pairs are separated by ",". Names and text values go inside double quotes ("…"), while numbers are written as they are.

Here is the example response as a table.

NameValueMeaning
city"Tokyo"Place (text)
weather"Sunny"Weather (text)
high22High temperature (number)

Notice that "22" has no unit. Is it °C, or °F (Fahrenheit, used in the US)? That is written in the API's specification, not in the JSON. If you use an API without reading the specification, mix-ups like this happen.

The JSON format is defined in RFC 8259, a 2017 standard. It is based on how the programming language JavaScript writes data. Today, almost every programming language can read and write it.

API keys: showing who is asking

Many web APIs do not accept unlimited requests from just anyone. They issue each user or company a long string of characters that cannot be guessed. This is called an API key. The asking side sends this key with every request.

When the server receives a key, it can tell which user sent the request. It then decides whether that user may use the feature. It also counts the calls to work out the fee. For example, Apple's weather API is called WeatherKit. As of October 2026, up to 500,000 calls a month are included in the cost of its developer membership.

Why keys must stay secret, and how to protect them

That is why an API key is kept secret, just like a password. Send it only over encrypted HTTPS ("What Is Encryption?"). Take special care not to write a key directly into a program's files. If that program is made public, the key is made public to the world too.

Putting a key inside a phone app or a web page is also dangerous. Anyone who has a copy of the app or page can pull out its contents and inspect them. Keep secret keys only on your own server. That server then adds the key and sends the request on.

Leaks really do happen, and often. GitHub is the best-known service for storing and sharing program code. The security company GitGuardian published a report in March 2025. In 2024, about 23.8 million secrets, such as keys and passwords, were found on public GitHub.

Google gives advice like the following for handling API keys.

  • Do not put keys in the code of apps or web pages. Do not put them where the code is stored either.
  • Restrict each key to the websites and features that may use it.
  • Delete keys you no longer use.
  • Replace keys with new ones on a regular schedule.

Some keys, however, are designed to sit in a page where people can see them. For example, the key that puts a map on a store's website is visible to anyone who views the page. This is a different kind of key. It is protected by a restriction such as "accept requests only from this store's website." Check the issuer's documentation to find out whether a key may be visible.

Limits on the number of calls (rate limits)

Many web APIs cap how many requests you can make in a set time. This is called a rate limit. It stops a few users from taking all of a server's capacity and making everyone else wait. It also stops a faulty program from repeating requests and running up costs.

For example, GitHub's API, as of October 2026, allows 60 requests an hour without anything that shows who is asking. If the request shows who the user is, you can make up to 5,000 requests an hour.

Over the limit, many servers reply "429 Too Many Requests." This number was defined in RFC 6585, a 2012 standard. The reply may also say how many seconds to wait before asking again. A well-built app follows this and waits before it tries again.

Behind "Log in with Google"

When you "Log in with Google" on another site, you are not giving that site your Google password. The screen where you type the password belongs to Google. The site receives a proof issued by Google that says "this really is the person." It contains no password.

This method is based on rules called OAuth (pronounced "oh-auth"). OAuth lets you give another app permission to use something, up to a set limit, without handing over your password. The current version, OAuth 2.0, became a standard in 2012.

Permissions and proofs are passed around as data called tokens. A token is like a pass with an expiry date that works only for certain things. If one leaks, the damage is smaller and shorter than if a password leaked.

For logging in, a set of rules called OpenID Connect is used. It adds a way to say "who this person is" on top of OAuth 2.0. Google's login follows it too. The proof of who you are arrives in a token called an ID token.

When you press Log in with Google on a store's website, you are sent to Google's screen and type your password only into Google. Google then gives the site proof of who you are You Store site Google ① Button ② Redirect ③ Password ④ Proof of ID ⑤ Done Only Google sees the password
The password in ③ goes to Google without passing through the store's site. Left out: the first-time question "may we share your information?" In a real step ④, a one-time code first arrives through the browser, and the site exchanges it with Google for the proof.

APIs are not only for the web

The word API was in use long before web APIs spread. For example, when an app wants to save a file, it asks the OS. The OS (operating system) is the base software that manages a computer's or phone's parts and lends them to apps. The way to ask it is also an API, and each OS has its own ("What Is an Operating System?").

A program that bundles often-used features into ready-made parts is called a library. Drawing a graph or calculating dates are examples of such parts. A library also has an API: which part to call, and how. These calls happen inside the same device, so they do not go over the internet.

TypeWho you askPathExample
OS APIThe OSInside the same deviceSave a file
Library APIA ready-made part (program)Inside the same programCalculate a date
Web APIAnother serverThe internetGet the weather forecast

What "API integration" means at work

At companies, you often hear "let's integrate these two systems through an API." It means making separate systems exchange data automatically through APIs. Nobody has to export data from one screen and import it into the other by hand.

One example is accounting software that pulls in a bank account's deposits and withdrawals automatically. In Japan, amendments to the Banking Act and related laws set up a system for this kind of link. They passed in May 2017 and took effect in June 2018. Banks were required to make efforts to set up API connections with household-budget and accounting service companies.

Another use is passing an online shop's orders to a delivery company automatically. In each case, a service that an outside company provides in the cloud is connected to a company's own systems ("What Is Cloud Computing?").

What to check before connecting

  • Which data flows, and in which direction (if it includes personal data, also the rules for handling it)
  • Whose permissions the connection uses, and whether it allows only what is needed (the principle of least privilege)
  • What happens if the other side's API goes down or its agreement changes
  • The limit on the number of calls, and the fees
  • Who keeps the API keys and tokens, and where

Common misconceptions

Myth: An API means an internet service

In fact, "API" covers every agreement for how programs ask each other for things. Operating systems and libraries have APIs too. Web APIs have become so familiar that people often say "API" to mean "web API," so the two get mixed up.

Myth: With "Log in with Google," the site gets your Google password

In fact, as shown above, you type the password only into Google's screen. The site receives a time-limited proof (a token) instead. The screens switch in a flash, so it is easy to miss where you are typing. However, there is also phishing, which shows a fake login screen. Before typing, check that the name in the address bar is Google's real one (accounts.google.com).

Myth: If you accidentally publish an API key, deleting it from the file fixes the problem

In fact, the key stays in earlier versions kept in the code store, and with anyone who already copied it. The basic fix is to disable the key with its issuer and create a new one. GitGuardian's March 2025 report found that about 70% of secrets leaked in 2022 could still be used at that time. Once the key disappears from the file, the problem only looks solved.

By the numbers

ItemFigureDate / source
REST proposed2000Fielding's PhD dissertation
OAuth 2.0 standardOctober 2012RFC 6749
"Too Many Requests" (429) standardApril 2012RFC 6585
Current JSON standardDecember 2017RFC 8259
Current standard for HTTP semanticsJune 2022RFC 9110
GitHub API rate limit60 an hour (not showing who asks), 5,000 (showing who asks)October 2026, GitHub
WeatherKit calls included in the membership cost500,000 a monthOctober 2026, Apple
Secrets found on public GitHubAbout 23.8 million2024, GitGuardian (March 2025 report)
Japan's law change that set up bank API linksPassed May 2017, in force June 2018Financial Services Agency, Japan

Standards stay in use for a long time. Rate limits and fees, though, often change for business reasons. When you use an API, check the provider's current documentation.

Learn more

Read next

Articles in the series “Networks and the internet”

  1. How Is Data Sent Over the Internet? Packets and Routers
  2. What Is an IP Address? IPv4, IPv6 and Private IPs Explained
  3. How Does Wi-Fi Work? Radio, Bands and Why Speeds Vary
  4. What Does HTTPS Mean? What the Padlock Does and Doesn't Do
  5. How Does DNS Work? From Domain Names to IP Addresses
  6. What Is 5G? How It Differs From 4G in Speed and Latency
  7. TCP vs UDP: What's the Difference? Reliability vs Speed
  8. How Does Bluetooth Work? Pairing, Hopping and BLE Explained
  9. What Is IoT? How Everyday Things Connect to the Internet
  10. What Is Ethernet? How a Wired LAN Carries Your Data
  11. What Is an API? Requests, JSON, API Keys and Integration
  12. How Do Web Browsers Work? What Happens After You Type a URL

Questions on this topic: Web Technology Basics

Sources

All explainers