Blog / How the internet works /
How apps talk to servers
Open a weather app and the number changes. Refresh a feed and new posts appear. Tap “Pay” and money moves. None of that lives inside the app. The app is asking a server somewhere, and the server is answering.
Understanding that conversation explains a surprising amount: why apps need data, why they sometimes show a spinner, why “offline mode” is hard, and what goes wrong when an app says “something went wrong”.
The basic idea: ask and answer
An app on your phone is mostly the front of a shop: the shelves, the signs, the till. The stock room is on a server. When you need something, the app sends a request, and the server sends back a response.
That’s the whole pattern. Everything else is detail.
What a request looks like
Apps and websites use a set of rules called HTTP to talk, the same one your browser uses. I explained the journey in what actually happens when you type a web address. A request has a few parts:
- An address. Which server and which thing you want, for example a list of your orders.
- A method, which says what you want to do. The common ones are:
- GET: give me something (show my profile).
- POST: here’s something new (create this order).
- PUT or PATCH: change something (update my address).
- DELETE: remove something.
- Headers, small notes about the request, such as who you are or what format you’d like.
- A body, for requests that carry data, like the form you just filled in.
What a response looks like
The server replies with:
- A status code, a number that says how it went. You may have met some: 200 means OK, 404 means not found, 401 or 403 mean you’re not allowed, and 500 means the server itself had a problem.
- Headers, with extra information.
- A body, the actual content: a web page, an image or, very often, structured data.
Those status codes explain many error messages. A 404 is “that thing isn’t here”. A 500 is “we broke”. A 429 is “you’re asking too much, slow down”.
The language in the middle: APIs and JSON
Apps usually don’t ask for a whole web page. They ask for data and draw it themselves. The set of things an app may request is the server’s API, and the data usually comes back as JSON, a plain-text format with labels and values:
{
"order": 1042,
"status": "shipped",
"items": 3
}
The app reads that and puts “Shipped, 3 items” on the screen, in its own design. The same server can feed an iPhone app, an Android app and a website with the same data. This split between the app’s look and the server’s data is the heart of how modern software is built, a point I made in what a web app is made of. I also explained structured data for AI replies in JSON mode and schemas explained, which uses the same format.
How the server knows who you are
The server can’t see your face. It has to be told who is asking, on every request. Typically:
- You log in with a username and password (or a passkey, or a code).
- The server checks and sends back a token, a long random string that means “this person is logged in”.
- The app stores the token and attaches it to every later request.
- The server checks the token, finds your account and answers accordingly.
That’s why you stay logged in without retyping your password, and why logging out, or a token expiring, suddenly makes an app ask for your details again.
It’s also why secrets matter. Anything that identifies you or the app, such as a token or API key, must be protected. Putting keys inside an app’s code, where anyone can extract them, is a classic mistake; see never put API keys in front-end code and what an API key is and why you should never share it.
Why apps sometimes feel slow
Every request takes time. Several things add to it:
- Distance. Your request travels to a server and back. A server on another continent adds delay. This is partly why content networks exist; see what is a CDN and do you need one.
- Your connection. Weak mobile signal or congested Wi-Fi slows everything.
- Server work. The server might have to query a database, call other services, or do calculations before replying.
- Too many requests. An app that makes twenty small requests to draw one screen will feel slower than one that makes two.
- Big responses. Large images and heavy data take longer, and cost more if your data is expensive.
When you see a loading spinner, the app is waiting for a response.
Why offline is hard
If the app depends on the server for its data, no connection means no data. Apps that work offline must store a local copy, decide what happens to changes you make while offline, and then sync them later without clashing with changes made elsewhere. That is a real engineering challenge, which is why many apps simply say “no connection”.
Why apps ask for permission and updates
Some requests are the app’s own business; others use your phone’s features. When an app asks to use the camera, location or contacts, the phone’s operating system mediates. And when the server’s rules change, say a new field in the data, the app may need updating to understand it. This is one reason apps nag about updates, and why old versions stop working.
What often goes wrong
- The server is down or overloaded. You see error messages or endless spinners. Load balancers are one way large services reduce this.
- A bad connection that drops halfway through, leaving an action half done.
- An expired login token.
- Rate limits, when you or the app asks too often and the server says wait.
- A change on the server that the app doesn’t understand.
- Time and date mismatches between phone and server, which can break logins.
What it means if you build or run things
If you ever commission an app, add a plugin that connects to an outside service, or plan a website feature, the same pattern is underneath. Useful questions to ask:
- What does the app request, and how often?
- How is login handled, and where are the secrets stored?
- What happens when the server is slow or down?
- How big are the responses, and does that matter for users on costly data?
- What does the user see when something fails?
For people using a phone as their main device, a well-designed app is kind to data and patient with weak signal.
Key takeaways
- Apps ask, servers answer; that request-and-response pattern underlies almost everything.
- Requests use methods (GET, POST and others) and responses carry status codes and data, often as JSON.
- Tokens tell the server who you are on every request.
- Slowness comes from distance, connection, server work and too many or too large requests.
- Good apps plan for failure and for users on weak or expensive connections.
Related reading
Next time an app shows an error, can you guess which part of the conversation failed?