API — Application Programming Interface
Also: APIs
A doorway that lets one program talk to another. Apps use an API to send your request to the model and get the answer back.
- You orderA program sends a request: here is the text, here is what to do.
- The waiter carries itThe API delivers it to the model and waits.
- The kitchen cooksThe model produces the answer.
- The plate comes backThe answer returns to the program, which shows it to you.
An API is the doorway between programs. Every chat app uses one behind the scenes; programmers can use the same doorway directly.
The fuller definition
An Application Programming Interface is a defined way for software components to interact. It specifies available operations and how requests and results are represented.
Go deeper
- Client program
Ask for record A01
- Interface
Defined request and response
- Service
Return the matching record
A simplified relationship, not a screenshot or a complete design.
A concrete example
A small program asks a document service for the title of record A01 and reads the JSON response.
The distinction that matters
An API is an interface, not a model. APIs can be local library calls or remote network services.
Try it: ask for a document, read the response
This local browser simulation demonstrates a small read-only API. It does not contact an AI provider, access your files, or require a key.
Your program sends
GET /documents/A01 HTTP/1.1
Accept: application/jsonThe service returns
{
"id": "A01",
"title": "Fictional supply agreement",
"pages": 4
}200 means this request succeeded. 404 means this example has no matching document. 403 means this simulated caller is denied access. Real services define their own response details.
See a complete API you can program in Python
Save this as local_api.py and run it with Python 3. It binds only to your own computer at 127.0.0.1. This teaching server has no authentication and is not a production service. The permission checkbox above is a separate simulation, not a feature of this code.
# Python 3: a complete local teaching API. No external packages.
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
records = {"A01": {"id": "A01", "title": "Fictional supply agreement", "pages": 4},
"A02": {"id": "A02", "title": "Fictional inspection email", "pages": 1}}
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
prefix = "/documents/"
key = self.path[len(prefix):] if self.path.startswith(prefix) else ""
data = records.get(key)
status = 200 if data else 404
body = json.dumps(data or {"error": "Document not found"}).encode()
self.send_response(status)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
HTTPServer(("127.0.0.1", 8765), Handler).serve_forever()With the server running, open a second terminal and run this client:
python -c "import urllib.request; print(urllib.request.urlopen('http://127.0.0.1:8765/documents/A01').read().decode())"The client makes an HTTP request; the server looks up the ID and returns JSON. Stop the server with Control+C. No language model is involved: an API can expose ordinary data as well as AI services.
Related terms
HTTP — Hypertext Transfer Protocol
The set of rules computers use to send pages and requests over the web.
APIs & softwareEndpoint
An address a program calls to do a set task. One address might accept a file; another might return a reply.
APIs & softwareJSON — JavaScript Object Notation
A tidy text format for data, made of labels and values in curly brackets. Programs use it to pass information around.
Where it is taught
APIs and JSON: connect a model to a small programSource and further reading
MDN · Application Programming InterfaceThe definition and example are written for this library. The link gives background, official documentation or legal authority as labelled. Legal scope depends on the jurisdiction and current text; product features depend on release and settings.