What Is an API?

An API (application programming interface) is a set of rules that lets one program ask another program for data or to do a job. Your app sends a request in an agreed format, and the other system sends back a response, usually as JSON, without either side needing to know how the other works inside.

01 / The analogy

An API is the waiter in a restaurant

  1. You (the customer)

    = Your app

    Decides what it wants and places an order from the menu.

  2. The waiter

    = The API

    Takes the order to the kitchen in a format the kitchen understands and brings back the dish.

  3. The kitchen

    = The server and its database

    Does the actual work. You never walk in or see how it is done.

Menu
API documentation: what you can ask for
Your order
The request
The dish
The response (JSON)
“Sorry, we are out of that”
An error status code such as 404

02 / Try a real API

Send a live API request

This sends a real GET request from your browser to the free Open-Meteo weather API. No key or sign-up needed. Change the city or unit and watch the URL change: each query parameter is an instruction to the API.

1. The request

GET method · endpoint /v1/forecast

https://api.open-meteo.com/v1/forecast?latitude=40.71&longitude=-74.01&current=temperature_2m%2Cwind_speed_10m&temperature_unit=celsius
curl "https://api.open-meteo.com/v1/forecast?latitude=40.71&longitude=-74.01&current=temperature_2m%2Cwind_speed_10m&temperature_unit=celsius"

2. The response

Press Send request to see the status code, headers and JSON the API sends back.

The parts of an API call

Every request in the demo above has the same pieces. Learn these eight words and most API documentation becomes readable.

Endpoint
The URL you send the request to, like https://api.open-meteo.com/v1/forecast. Each endpoint does one job.
Method
The verb: GET reads, POST creates, PUT or PATCH updates, DELETE removes.
Parameters
Extra instructions in the URL after the ?, such as latitude=40.71 or temperature_unit=fahrenheit.
Headers
Labels on the request or response: the content type, an Authorization header carrying your API key, caching rules.
Body
The data you send with a POST or PUT, usually JSON, such as a new customer’s name and email.
Status code
A three-digit result: 2xx worked, 4xx means your request had a problem (404, 401, 429), 5xx means the server failed.
API key
A secret that identifies your app so the provider can grant access, apply limits and bill you.
Rate limit
A cap on requests per minute or day. Go over it and you get 429 Too Many Requests until the window resets.

03 / Compare

REST vs GraphQL vs webhooks vs SDKs

All four are ways for software to talk to other software. They differ in who starts the conversation and how you ask.

REST · You ask, it answers

Each thing has its own URL, and you use HTTP verbs on it: GET to read, POST to create, PUT or PATCH to change, DELETE to remove.

Best for: Most public web APIs. Simple, cacheable and easy to try in a browser.

Examples: Stripe, GitHub, Open-Meteo (the demo above)

GET /v1/users/42

200 OK
{ "id": 42, "name": "Ada", "email": "ada@example.com" }

API examples you use every day

  • Log in with Google

    The site redirects you to Google, and Google’s OAuth API hands back a token that proves who you are, without sharing your password.

  • Maps inside apps

    Uber, Airbnb and store locators embed Google Maps or Mapbox through their APIs instead of drawing maps themselves.

  • Checkout and payments

    Online stores send your card to Stripe or PayPal through an API, and a webhook tells the store when the payment succeeds.

  • Weather and travel

    Weather apps call forecast APIs. Flight sites query airline and booking APIs to compare fares in seconds.

  • AI assistants in other apps

    Tools that “add AI” usually send your text to the OpenAI, Anthropic or Google API and show the model’s reply.

  • Workflow automation

    No-code and AI workflow tools chain API calls: a new form entry triggers a webhook, which creates a CRM record and posts to Slack.

API vs website

WebsiteAPI
Built forPeople in a browserPrograms and apps
ReturnsHTML pages with layout and imagesStructured data, usually JSON
AccessOpen a URL and clickSend requests from code, often with an API key
ExampleA forecast page you read in a browserGET /v1/forecast returning temperature JSON

04 / Test yourself

API basics: 10-question quiz

  1. 1. In the restaurant analogy, which part is the API?

  2. 2. A request comes back with status 404. What happened?

  3. 3. Which HTTP method normally reads data without changing anything?

  4. 4. What is an API key for?

  5. 5. Stripe calls your server the moment a payment succeeds. That is a…

  6. 6. You get 429 Too Many Requests. What should your app do?

  7. 7. Which format do most web APIs use to send data back?

  8. 8. A weather app on your phone shows today’s forecast. Where does the forecast usually come from?

  9. 9. One request that asks for exactly the fields you list, from a single endpoint, describes…

  10. 10. Is the ChatGPT website the same thing as the OpenAI API?

0 of 10 answered

How to use this explainer

  1. 1. Read the restaurant analogy

    See how the customer, waiter and kitchen map to your app, the API and the server.

  2. 2. Send a live request

    Pick a city and unit, look at the GET URL, then press Send request to see the real status code, headers and JSON.

  3. 3. Compare API styles

    Switch between REST, GraphQL, webhooks and SDKs to see who starts the conversation and what a call looks like.

  4. 4. Take the quiz

    Answer ten questions on status codes, methods, keys and API styles, then check your score.

API questions, answered

What is an API in simple terms?

An API (application programming interface) is a set of rules that lets one piece of software ask another for data or to do something. Your app sends a request in an agreed format, and the other system sends back a response, usually as JSON.

What is an API with an example?

A weather app does not measure the weather itself. It sends a request such as GET /v1/forecast?latitude=40.71&longitude=-74.01 to a weather service’s API, gets back JSON with the temperature and wind, and shows it on screen. The live demo on this page sends exactly that kind of request.

How do APIs work?

A client sends a request to an endpoint URL with a method (such as GET or POST), optional headers like an API key, and sometimes a body. The server checks the request, does the work, and returns a status code (200 for success, 404 for not found, 500 for a server error) plus the data.

What is the difference between an API and a website?

A website returns pages designed for people to read in a browser. An API returns structured data, usually JSON, designed for programs to read. Many companies offer both: the website for humans and the API for developers who want to build on their data.

Is ChatGPT an API?

ChatGPT itself is an app for people. OpenAI also sells an API that lets developers send prompts from their own code and get model replies back, billed per token. Anthropic’s Claude and Google’s Gemini work the same way.

What is an API key?

An API key is a secret string that identifies which app is making a request. The provider uses it to allow access, apply rate limits and bill usage. Treat it like a password: keep it on your server and never publish it in front-end code or a public repository.

What is the difference between REST and GraphQL?

A REST API gives each resource its own URL and uses HTTP methods to read or change it. A GraphQL API has a single endpoint where you send a query listing exactly the fields you want. REST is simpler to start with; GraphQL avoids over-fetching when you need related data in one trip.

Chain APIs and AI into workflows

Tornic turns the AI coding CLIs you already use into visual, repeatable workflows, each step calling the tools and APIs your project needs.

Explore Tornic

Related free tools