Skip to contentTalk to us
Building apps

What is an API? A plain explanation with real examples

What is an API and how does it work? A plain explanation using a store or booking app: payments, WhatsApp alerts, maps and sign-in, and how to connect them without code.

Fanann Team9 min read
WhatsApp
Quick answer

An API (application programming interface) is a written agreement for how one program asks another for something and what reply it gets back. When a customer pays in your store, your app sends a request to the payment gateway's API and the reply comes back: approved or declined. The fastest way to understand APIs is to build a real app in Fanann that connects payments, WhatsApp and sign-in, then trace each request and reply yourself.

People look for this as
  • what is an API in simple terms
  • what is an API with examples
  • how does an API work
  • API vs webhook difference
  • how to connect a payment gateway to my app
  • do I need to code to use an API

What is an API, in one sentence?

API stands for application programming interface. In one sentence: it is the agreed way one program asks another program for something, knowing in advance what shape the reply will take.

Picture the order window at a restaurant. You do not walk into the kitchen or learn how the food is cooked. You order in a set way, "one burger, no onions", and a plate comes back that you recognize. The window is the API, the kitchen is the other service, and you are your app.

Illustration: hands holding a phone with an app open. Behind the screen, almost every button can send a request to another service through an API.Illustration
Illustration: hands holding a phone with an app open. Behind the screen, almost every button can send a request to another service through an API.

This guide is for anyone who wants to understand how software actually works: a student, a shop owner, a founder building a first app. Instead of abstract examples, we use an app you already understand: a small store that sells, takes payments and sends notifications, or an appointment booking app.

Where are the APIs in your own app?

Open any modern online store and most of what happens is requests going back and forth between your app and other services. These are the common ones in a store or booking app:

Moment in your appWho talks to whomWhat comes back
A customer pays with mada or Apple PayYour app and the payment gatewayApproved or declined, with a reference number
A customer signs in with a phone numberYour app and a messaging serviceA one-time code on the phone, then confirmation it matched
Order confirmation on WhatsAppYour app and WhatsAppSent, or failed
Picking a delivery locationYour app and a maps serviceCoordinates and a readable address
Showing products or free slotsYour app's screens and its own serverA list of products and prices, or open appointments

Notice the last row: your app has an internal API of its own. The part running in the browser or on the phone asks the part running on the server for data. If that split is new to you, read frontend vs backend.

How does an API request work, step by step?

Take the payment moment in your store. A customer taps "Pay now" on a cart worth 250 riyals. Here is what happens in a few seconds:

  1. 1
    The address

    Your app knows the payment service's address, like the address of an office you take a form to.

  2. 2
    The request

    Your app sends exactly what the gateway asks for: amount, currency, order number and payment method.

  3. 3
    The identity

    Your app attaches a secret key that proves the request comes from your store and not from someone using your name.

  4. 4
    The reply

    The gateway answers in a known shape: status (approved or declined), a reference number, and the reason if it was declined.

  5. 5
    The action

    Your app reads the reply and marks the order as paid and shows the thank-you page, or asks the customer to try again.

Request
What your app sends: what it wants, with which data
Response
What comes back: the result and data, or an error
Key
Proof that the request really comes from you
Documentation
The service's guide to what it accepts and returns

Every API in the world follows this same idea, however different the details. Understand one good example and you can read the rest.

What is the difference between an API and a webhook?

With an API, your app does the asking. But some things happen outside your app: the customer finishes paying on the bank's page, then closes the browser before coming back. How does your store learn the order is paid? That is the job of a webhook: the service itself calls your app and tells it what happened.

API: you ask
  • Your app sends the request when it needs something
  • Example: show me the open appointments
  • The reply comes back to that same request
  • Right for what the user wants right now
Webhook: they tell you
  • The service sends a notice when an event happens
  • Example: payment succeeded, or booking cancelled
  • Arrives even if the customer closed the page
  • Right for confirming things that happen outside your app

A well-built store uses both: it asks the gateway for the status when the customer returns, and it receives the payment notice by webhook as a safety net. That way a paid order is never lost because the customer's connection dropped.

Are APIs safe, and what are API keys?

Most paid or sensitive services ask for an API key: a long string that works like a password for your app. Whoever holds the key can make requests in your name, which makes it the most valuable part of any connection.

Quick safety checklist for any connectionTap an item when it is done. Your progress is kept in this browser.

How do I connect payments, WhatsApp and sign-in without writing code?

The traditional route: read each service's documentation, write the code for requests and replies, handle errors and test every case. It teaches a lot, but each connection takes weeks. In Fanann you describe the app in Arabic or English and it is built with the connections in place, and you review the plan before anything is built in plan mode.

Local payment methods are ready to connect: mada, Apple Pay, STC Pay, Tabby, Tamara, KNET, Benefit and Fawry, along with phone sign-in with a one-time code, WhatsApp notifications and Google sign-in. The full list is on the integrations page and the payments page.

Example: a perfume store with payments and alerts

Build an online perfume store in Arabic and English. Customers sign in with their mobile number and a one-time code. A cart, and checkout with mada, Apple Pay and Tabby. When payment succeeds, the order status changes to Paid and the customer gets a WhatsApp confirmation with the order number. If the payment is declined, show a clear message and a Try again button. An owner page lists orders and their status. In the plan, explain each outside service you will connect and why.

Try it in Fanann

The last sentence of that prompt is the learning trick: ask for every service to be explained. After the build, open your project's code, read the part that sends the payment request, and ask Neo, the assistant, about any line you do not follow. The project is yours and you can export it.

Should I build my own API or use a ready-made one?

Everyone asks this once the idea clicks. The answer depends on what you need:

What do you need the API for?

Pick the one that sounds like you to see the advice.

How can I learn APIs by building in a week?

If your goal is to understand software, here is a short plan that turns the concept into real experience with your own app:

  1. Day 1An app with no connections

    Build a simple booking app in Fanann that lists and saves appointments. This is where you meet the internal API.

  2. Day 2Sign-in

    Add phone sign-in with a one-time code, and watch what happens when you type a wrong code.

  3. Day 3A WhatsApp notice

    Send the booking confirmation on WhatsApp, and find in the code the moment the request goes out.

  4. Day 4Payment and webhook

    Add a deposit with mada or Apple Pay, and trace how a booking becomes Paid.

  5. Day 5Testing

    Ask the QA Engineer to try the app and report bugs with screenshots, then fix them.

Do not memorize the definition of an API. Send a real request, read the reply, and you will understand it for good.

Key takeaways

  • An API works like a restaurant's order window: you ask in a set way, get a reply in a known shape, and never enter the kitchen.
  • Every modern app uses several APIs: payments, messaging, maps, sign-in, and its own internal one for its data.
  • A webhook is the reverse: the service calls your app on its own when something happens, such as a successful payment.
  • API keys are passwords. Never put them in a public page or paste them into a chat.
  • You learn APIs faster by connecting them to your own app and reading what happened than by memorizing definitions.

Frequently asked questions

What is an API in simple terms?
It is the agreed way one program asks another for something and knows the shape of the reply. Like a restaurant's order window: you order in a set way and get what you asked for without entering the kitchen.
Do I need to learn programming to use an API?
Not if your goal is a working app. In Fanann you describe what you want and the connection to payments, WhatsApp or sign-in is built for you. If you want to learn, read your project's code after the build and ask the assistant about each part.
What is the difference between an API and a webhook?
With an API, your app asks the service. With a webhook, the service calls your app when an event happens, such as a successful payment or a cancelled booking.
How do I connect a payment gateway to my app?
You need a merchant account with the payment provider, then you connect your app and test both approved and declined payments. In Fanann you name the methods in your description, such as mada, Apple Pay, Tabby, KNET or Fawry, and try them in the preview.
Is using an API free?
It depends on the service: some charge per transaction or message, others set usage limits. Read each provider's terms. What your Fanann plan includes depends on your plan and is shown on the pricing page.
What happens if my API key leaks?
Whoever has it can send requests in your name. Sign in to the service, revoke the key and create a new one right away, then keep it on the server, never in a page.

Ask your AI assistant about this

Copy this prompt into the AI assistant you use, then add the details of your own case.

I am reading this guide: “What is an API? A plain explanation with real examples” https://fanann.com/en/blog/what-is-an-api-explained/ My question: what is an API in simple terms Use that page as a source and explain the answer step by step for my situation, tell me what to check before I start, and cite the page link.

Terms in this article

Your idea deserves to see the light.

Describe it in Arabic or English and Fanann builds, tests and ships it — no coding knowledge needed. Start free, no credit card.