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.
- 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.
IllustrationThis 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 app | Who talks to whom | What comes back |
|---|---|---|
| A customer pays with mada or Apple Pay | Your app and the payment gateway | Approved or declined, with a reference number |
| A customer signs in with a phone number | Your app and a messaging service | A one-time code on the phone, then confirmation it matched |
| Order confirmation on WhatsApp | Your app and WhatsApp | Sent, or failed |
| Picking a delivery location | Your app and a maps service | Coordinates and a readable address |
| Showing products or free slots | Your app's screens and its own server | A 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:
- 1The address
Your app knows the payment service's address, like the address of an office you take a form to.
- 2The request
Your app sends exactly what the gateway asks for: amount, currency, order number and payment method.
- 3The identity
Your app attaches a secret key that proves the request comes from your store and not from someone using your name.
- 4The reply
The gateway answers in a known shape: status (approved or declined), a reference number, and the reason if it was declined.
- 5The 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.
- 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
- 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.
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.
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 FanannThe 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:
Pick the one that sounds like you to see the advice.
Always use a ready-made service. Nobody builds their own payment gateway. In Fanann you name the payment method and it is connected from one description.
You need an internal API that serves both with the same data. Fanann builds the website and the iOS and Android apps from the same conversation, on shared data.
Say a supplier wants to see your stock. Now you build your own API. Describe what the partner may and may not see, and ask for access by key.
Build a small app with one payment and one notification, then read the requests and replies in your project's code. It beats any theory lesson.
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:
- 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.
- Day 2Sign-in
Add phone sign-in with a one-time code, and watch what happens when you type a wrong code.
- Day 3A WhatsApp notice
Send the booking confirmation on WhatsApp, and find in the code the moment the request goes out.
- Day 4Payment and webhook
Add a deposit with mada or Apple Pay, and trace how a booking becomes Paid.
- 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?
Do I need to learn programming to use an API?
What is the difference between an API and a webhook?
How do I connect a payment gateway to my app?
Is using an API free?
What happens if my API key leaks?
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.