Skip to content
MintFlow Articles

What is an API? A plain-English guide with real examples

How one program asks another for data or a favor, shown with a live weather request, a card payment and an AI model call, plus keys, errors and what APIs cost

On this page
  1. What is an API, in plain English?
  2. How does an API work?
  3. Three real examples of APIs
  4. A weather API: ask a question, get data
  5. A payment API: ask for something to happen
  6. An AI model API: send text, get text
  7. What types of API are there?
  8. What is an API key, and how do you keep it safe?
  9. What do API error codes mean?
  10. How much does an API cost?
  11. API vs SDK, webhook and MCP: what's the difference?
  12. How to make your first API request
  13. Frequently asked questions

An API (application programming interface) is a set of rules that lets one program ask another for data, or ask it to do something, and get back an answer in a predictable format. When a weather app shows you the temperature, it usually didn't measure anything. It sent a request to a weather service's API and displayed the reply.

You use APIs all day without seeing them: checking out in an online store, plotting a route on a map, chatting with an AI assistant inside another app. This guide explains how they work using three real ones (weather, payments and AI models), then shows you how to make your first request in a browser tab, with no account.

What is an API, in plain English?

Start with the word interface. A person uses an app through buttons, menus and screens. A program can't click a button reliably, so the app's maker offers a second way in, built for code. MDN describes an API as a contract between the application offering it and whatever wants to use it, and IBM uses the same word.

A contract is a better picture than the usual restaurant-waiter comparison, because it captures what matters:

  • It says what you may ask for. A weather API might offer "current temperature" and "ten-day forecast", and nothing else.
  • It says how to ask. Which address to contact, which details to include, how to prove who you are.
  • It says what you'll get back. The reply's format is documented, so your code knows where to find each value.
  • It hides everything else. You don't need to know which database or language the other side runs on, and it can change all of that without breaking your app, as long as the contract holds.

The idea is older than the web. Wikipedia and Nordic APIs both trace the term to a 1968 conference paper on remote computer graphics, which Wikipedia credits to Ira Cotton and Frank Greatorex. Today, when someone says "API", they mostly mean a web API: one you reach over the internet.

How does an API work?

Web APIs work by request and response. Your program (the client) sends a message to the provider's computer (the server), and the server sends one back.

A request has up to five parts:

Part What it does Example
Endpoint The address for a specific job https://api.stripe.com/v1/payment_intents
Method The kind of action GET to read, POST to submit, PATCH to change part of something, DELETE to remove it
Parameters The details of your question latitude=40.71&longitude=-74.01
Headers Extra information, often your credentials x-api-key: YOUR_KEY
Body Data you're sending A chat message for an AI model

The response has a status code, which says whether it worked, and usually a body with the data. That body is most often JSON, a plain-text format for structured data that many programming languages support.

Three real examples of APIs

A weather API: ask a question, get data

Open-Meteo is a good first API because non-commercial use is free and needs no key. This address asks for the current temperature and wind speed in New York, in American units:

https://api.open-meteo.com/v1/forecast?latitude=40.71&longitude=-74.01&current=temperature_2m,wind_speed_10m&temperature_unit=fahrenheit&wind_speed_unit=mph

Everything before the question mark is the endpoint. Everything after it is parameters, joined by &. The reply to that request early on 3 December 2026 included this (shortened):

{
  "latitude": 40.710335,
  "longitude": -73.99308,
  "elevation": 27.0,
  "current_units": {
    "temperature_2m": "°F",
    "wind_speed_10m": "mp/h"
  },
  "current": {
    "time": "2026-12-03T06:45",
    "temperature_2m": 38.3,
    "wind_speed_10m": 5.1
  }
}

So it was 38.3 °F with a light wind. The time is GMT, the default, and the coordinates differ slightly from the request because Open-Meteo answers for the nearest cell on its weather grid. Small details like these are why you read an API's documentation before you trust its numbers.

The US National Weather Service runs a free API too, at api.weather.gov. It doesn't use keys yet, but it does require a User-Agent header that identifies your app. It also takes two steps: you send coordinates to the /points endpoint, and the reply contains the address of the forecast for that spot. Using one answer to make the next request is very common.

A payment API: ask for something to happen

Reading data is only half of it. When a store uses Stripe, its server asks Stripe's API to set up a payment:

curl https://api.stripe.com/v1/payment_intents \
  -u "YOUR_TEST_KEY:" \
  -d amount=2500 \
  -d currency=usd

That's a POST request, because it creates something (curl switches to POST when you add -d data). Stripe replies with a PaymentIntent, an object with its own ID and a status such as requires_payment_method. No money has moved yet. The customer still has to supply a card and the payment has to be confirmed.

Three things here come up in lots of APIs:

  • Read the units. Stripe takes amounts in the smallest unit of the currency, so 2500 means $25.00. Send 25 and you've asked for 25 cents, which is below Stripe's $0.50 minimum for US dollars.
  • Use the test environment. Stripe's sandboxes have their own keys, with prefixes such as sk_test_ and rk_test_, and test cards that never move funds. Live keys have live in the prefix.
  • Plan for retries. If your connection drops after you send a payment request, did it go through? Stripe lets you attach an idempotency key, a unique label for the request, so a repeat with the same label doesn't do the job twice.

An AI model API: send text, get text

Chatbots have APIs as well, and that's how other apps add AI features without training a model. This is the shape of a request to Anthropic's Messages API, based on its quickstart:

curl https://api.anthropic.com/v1/messages \
  -H "content-type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2026-10-21" \
  -d '{
    "model": "claude-opus-5-5",
    "max_tokens": 16000,
    "messages": [
      {"role": "user", "content": "Explain APIs in one sentence."}
    ]
  }'

The reply is JSON containing Claude's answer and a usage section that counts the tokens you'll pay for. OpenAI's version is similar in spirit and different in detail: the endpoint is https://api.openai.com/v1/responses, the key goes in an Authorization: Bearer header, and the question goes in a field called input. Two companies, two contracts. Code written for one won't work on the other without changes.

If you want to know what the model does with that text once it arrives, our guide to how large language models work picks up from there.

What types of API are there?

You'll see APIs sorted in two ways. The first is by who can use them:

  • Public: open to outside developers, free or paid. All three examples above are public.
  • Partner: open only to approved business partners.
  • Private: used inside one company, for example between its mobile app and its own servers.

The second is by style:

  • REST is the most popular style for web APIs, according to AWS. Roy Fielding described it in his 2000 dissertation. Each thing has an address, you act on it with standard HTTP methods, and each request carries everything the server needs. MDN notes that HTTP APIs in general are sometimes called "RESTful", even when they don't meet every REST constraint.
  • GraphQL lets the client send a query listing exactly the fields it wants.
  • RPC styles, including gRPC, work like calling a function on someone else's computer.
  • SOAP is an older, stricter style based on XML. AWS says it was more popular in the past.
  • WebSocket APIs keep a connection open so both sides can send messages, which suits live updates.

Not every API involves the internet. Operating systems and programming libraries have them too, and so does your browser. Its Geolocation API is what a website uses to ask for your location.

What is an API key, and how do you keep it safe?

An API key is a long string that identifies the app making the request. Providers use it to check access, count usage and bill the right account. Some APIs use access tokens instead of keys, or alongside them. A token can represent a specific user, and that's what happens when you let one app read your data in another.

Treat a secret key like a password with a credit card attached. Anyone who has it can spend your money.

  • Never put a secret key in a web page or mobile app. Users can extract it. OpenAI tells developers to send requests through their own server instead.
  • Keep keys out of your code. Store them in environment variables or a secrets manager, and don't commit them to a repository, even a private one.
  • Give each key the least access it needs. Stripe now recommends restricted keys over its all-access secret keys for new projects.
  • Set a spending limit if the provider offers one.
  • If a key leaks, replace it first. GitHub scans public repositories for exposed secrets for free, and its advice is to rotate the credential right away. Deleting the line isn't enough, because the old version stays in the history.

Some keys are meant to be seen. Stripe's publishable keys (pk_) are designed for front-end code and can't create charges or read account data. Check the docs to know which kind you have.

What do API error codes mean?

Codes starting with 2 mean success, 4 means something is wrong with the request, and 5 means something broke on the server. These are the ones you'll meet first:

Code Meaning What to try
200 OK It worked Nothing
201 Created It worked and made something new Save the new item's ID
400 Bad Request The server couldn't process your request Look for a typo or a missing field
401 Unauthorized You haven't proved who you are Check the key and the header name
403 Forbidden You aren't allowed to do this Check permissions; on api.weather.gov, add a User-Agent
404 Not Found That address or item doesn't exist Check the URL and the ID
429 Too Many Requests You hit a rate limit Wait, then retry more slowly
500 Internal Server Error The server failed Retry later
503 Service Unavailable The server is overloaded or down Retry later

Read the body of the error too. Open-Meteo, for instance, returns a 400 with a reason field that explains the problem.

Rate limits deserve a note, since beginners run into them quickly. They cap how many requests you can make in a period, to prevent abuse and share capacity. Open-Meteo's free tier allows up to 600 calls a minute, 5,000 an hour and 10,000 a day. Anthropic limits both requests and tokens per minute, and its 429 replies often include a retry-after header with the number of seconds to wait.

How much does an API cost?

Anything from nothing to a large monthly bill. The pricing model usually follows what the API does:

API How it charges Price
National Weather Service Free public data $0
Open-Meteo Free for non-commercial use, up to 10,000 calls a day $0; paid plans for commercial use
OpenWeather One Call 4.0 Per call 1,000 calls a day free, then $0.0015 each
Apple WeatherKit Included, then monthly plans 500,000 calls a month with an Apple Developer Program membership, then from $49.99 a month
Stripe Per payment 2.9% + 30¢ for an online payment with a domestic card in the US, no setup or monthly fee
Claude Haiku 5.5 Per token $0.10 per million input tokens, $0.50 output (prompts up to 100,000 tokens)
Claude Opus 5.5 Per token $4 input, $20 output per million
GPT-6.2 Sol Per token $2 input, $10 output per million (prompts up to 272K tokens)
Gemini 4 Carbon Per token $4 input, $20 output per million, double its November price

Stripe's fee can be higher: manually entered cards cost US businesses 3.4% + 30¢, and international cards cost extra too. On OpenWeather, turn down the daily cap if you want to stay free, because new One Call subscriptions are set to 2,000 calls a day by default and only the first 1,000 cost nothing.

AI prices look strange until you work one out. The sample reply in Anthropic's quickstart used 21 input tokens and 305 output tokens. On Claude Opus 5.5, that comes to about $0.006, a little over half a cent. Multiply by 100,000 requests and it's about $618. Our guide to what AI tokens are and how they set your bill has the full price table and ways to spend less.

API vs SDK, webhook and MCP: what's the difference?

  • SDK (software development kit): a package of tools and libraries for a particular language or platform. It often wraps an API, so you can write client.messages.create(...) in Python instead of building the request by hand.
  • Webhook: the reverse direction. Rather than you asking "has the payment cleared yet?" every few seconds, the service sends a message to your address when it does. Stripe uses webhooks for events such as a bank confirming a payment or a customer disputing a charge.
  • MCP (Model Context Protocol): a shared standard that lets AI apps use outside tools. An MCP server often sits on top of a normal API, so an assistant can use it without custom code for each app. Our explainer on what MCP is and how it works has the details.

How to make your first API request

You can do the first step right now.

  1. Use your browser. Paste the Open-Meteo address from the weather example into the address bar and press Enter. Opening a URL is a GET request, so you'll see the raw JSON.

  2. Change a parameter. Swap in the coordinates of your own town. Longitudes in North and South America are negative. Then remove &temperature_unit=fahrenheit to get Celsius.

  3. Break it on purpose. Misspell temperature_2m and read the error.

  4. Do it in code. This Python script uses only the standard library, so there's nothing extra to install:

    import json
    from urllib.request import urlopen
    
    url = (
        "https://api.open-meteo.com/v1/forecast"
        "?latitude=40.71&longitude=-74.01"
        "&current=temperature_2m,wind_speed_10m"
        "&temperature_unit=fahrenheit&wind_speed_unit=mph"
    )
    
    with urlopen(url) as response:
        data = json.load(response)
    
    print("New York is at", data["current"]["temperature_2m"], "degrees F")
    
  5. Move on to an API with a key. A free weather plan or a Stripe sandbox is a safe place to practice, because a mistake won't cost you anything.

Whatever you pick next, find three pages in its docs before you write code: authentication, rate limits and versioning. The last one is easy to skip and matters later. Stripe's current version is 2026-11-18.endive, and it ships releases with breaking changes twice a year. Anthropic's 2026-10-21 version removed some older request settings, including temperature, so a tutorial written before then may now return an error if you copy it with the new version header.

Frequently asked questions

What does API stand for?

API stands for application programming interface. It's the set of rules one program follows to request data or actions from another.

What is an example of an API?

A weather app asking Open-Meteo or the US National Weather Service for the current temperature is a simple one. Others include an online store asking Stripe to take a payment, or an app sending your question to Claude or a GPT model.

Are APIs free to use?

Some are. The US National Weather Service's API is free, and Open-Meteo is free for non-commercial use. Others charge per call, per payment or, for AI models, per token.

Does ChatGPT Plus include API access?

No. OpenAI bills ChatGPT and its API separately, and Plus doesn't come with monthly API credits. ChatGPT's Pro plans and eligible Business workspaces do, and so do Claude's Max, Ultra and Team plans.

What is a REST API?

It's a web API that follows the REST style: each resource has its own address, and you use standard HTTP methods such as GET and POST on it. In everyday use, people apply the label loosely to most HTTP APIs.

Do you need to know how to code to use an API?

Not to try one: pasting an Open-Meteo address into your browser is a real API request. Building something useful with it takes some code, or a no-code tool that makes the requests for you.

Sources

Was this helpful?

Keep reading

Two screens of code side by side behind a keyboard, for a comparison of Cursor vs Copilot
AI Coding Tools
AI & Dev Tools

Cursor vs Copilot: Grok Build (formerly Cursor) or GitHub Copilot?

Cursor vs Copilot in December 2026: what each plan costs, why the same Claude tokens cost you more in Cursor, what the Grok Build rename changes and which one to pick.

17 min read

GitHub's Octocat figurine in front of a monitor, for a guide to GitHub Copilot plans
AI Coding Tools
AI & Dev Tools

GitHub Copilot plans explained: Free, Pro, Pro+, Max, Business and Enterprise prices and AI credits

Every GitHub Copilot plan in December 2026, from Free and Student to Pro, Pro+, Max, Business and Enterprise: prices, AI credits, models and what happened to premium requests.

19 min read

Man on a video call at his desk with a notebook beside the laptop, where the best AI meeting assistant takes the notes
Best AI Tools
AI & Dev Tools

Best AI meeting assistant in 2026: Fathom, Granola, Otter, Fireflies and the built-in options compared

The best AI meeting assistants in December 2026: Fathom, Granola, Otter, Fireflies and the AI in Zoom, Teams and Meet compared on price, free limits, bots and consent.

24 min read