On this page 7 sections
Short answer: An API (Application Programming Interface) is a set of rules that lets one piece of software ask another piece of software for data or actions. Your app sends a request (for example, “give me today’s weather in Karachi”), and the other system sends back a response, usually as JSON data.
The restaurant analogy
You (the app) don’t walk into the kitchen (the server). You give your order to the waiter (the API), who brings back your food (the data). You don’t need to know how the kitchen works, only how to order.
How an API request works
- Endpoint: the URL you call, like
https://api.example.com/weather - Method: what you want to do:
GET(read),POST(create),PUT/PATCH(update),DELETE(remove) - Parameters and body: extra details, like the city name
- Headers: extra info such as an API key for authentication
- Response: data back, plus a status code (200 OK, 404 Not Found, 401 Unauthorized, 500 Server Error)
A tiny example in JavaScript:
const res = await fetch("https://api.example.com/weather?city=Karachi");
const data = await res.json();
console.log(data.temperature);And the JSON that might come back:
{ "city": "Karachi", "temperature": 31, "condition": "Sunny" }Types of APIs
- REST: the most common style for web APIs, using URLs and HTTP methods
- GraphQL: you ask for exactly the fields you want in one query
- Webhooks: the other system calls you when something happens (like “payment received”)
- SDKs and libraries: code packages that wrap an API so it’s easier to use
Everyday examples
- A weather app getting forecasts
- “Log in with Google” buttons
- Payment gateways processing cards
- Google Maps embedded on a contact page
- Courier tracking on an online store
- AI features calling models like ChatGPT or Claude. My AI SEO plugin uses an AI API to write meta descriptions.
API keys and security
- Keep API keys secret and on the server, never in public front-end code
- Use HTTPS
- Respect rate limits (how many requests you can make)
- Validate everything that comes in and goes out
How to try an API yourself
- Open a free public API (weather, jokes, countries)
- Paste the URL in your browser and look at the JSON
- Call it with
fetchin JavaScript orrequestsin Python - Show the data on a simple web page
That project teaches you the core of modern web development. Next steps are in the web development roadmap.
Frequently asked questions
What does API stand for?
Application Programming Interface.
Is an API the same as a website?
No. A website is for people to read. An API is for programs to exchange data, usually in JSON.
Are APIs free?
Some are free, many have free tiers with limits, and others are paid per request.
Do I need an API for my business website?
You probably already use several: maps, forms, payments, analytics and booking tools all work through APIs. Custom integrations connect your website to your CRM, inventory or other systems.
