Skip to content

From the team

API-first development for web, mobile and partners

One backend serving the website, the mobile app and partner integrations costs a little more to design and much less to live with. Here is how it works.

5 min read

API-first development means building the backend of a product as a service with a documented interface, before or alongside any screen that uses it, so that a website, a mobile app and a partner's system can all talk to the same thing. This article is for business owners and product managers deciding how a product should be built, and for developers who want to explain why the extra discipline up front pays for itself. You will almost certainly need more than one client for your backend, and API-first is the cheapest way to be ready for that.

What is API-first development?

In a traditional web application, the backend and the pages are one thing. The server builds a page, fills it with data, and sends it to the browser. That works well until you need a mobile app, and then you discover that the logic for what a customer can see, order or edit lives inside the page templates, where nothing else can reach it.

API-first turns that inside out. The backend exposes a set of endpoints: get products, create an order, update a profile, list invoices. The endpoints enforce the business rules and permissions. Everything a user sees is a client that calls them: the website, the mobile apps, the admin panel, a partner's integration.

The backend becomes the single source of truth. A rule such as "customers cannot cancel an order after it has shipped" is written once, tested once, and holds everywhere.

Why does one backend for web, mobile and partners cost less?

The saving is not in the first build. An API-first backend takes somewhat more care to design, because the interface has to be thought about rather than emerging from the pages. The saving comes afterwards, and it comes several times:

  • The mobile app is a client, not a second product. When the app arrives, it connects to the endpoints that already exist. Nobody rebuilds the ordering logic in a second language.
  • Partners integrate without custom work. A distributor who wants to place orders from their own system uses the same API your website uses, with their own credentials. The alternative is a bespoke integration per partner.
  • Automated testing gets easier. An endpoint has a defined input and output. It can be tested without a browser, which makes the tests faster, more reliable and far more numerous.
  • Bilingual products are simpler. Locale becomes a parameter on the request. The backend returns Arabic or English content from one set of endpoints, and every client gets both languages without separate work.

How should an API be versioned and documented?

An API is a promise. The moment a mobile app or a partner depends on it, you cannot change a response shape without breaking them.

Versioning is how you keep the promise while still evolving. The simplest workable approach is a version in the URL path, with a rule that a published version never changes in a way that breaks a client: fields can be added, never removed or renamed. When a breaking change is genuinely needed, a new version is published and the old one is kept running for a stated period while clients migrate.

Documentation is not optional in this model, because the people consuming the API are not always in the room. The standard is a machine-readable specification that describes every endpoint, its parameters, its responses and its errors, generated from the code so it cannot go stale. A partner should be able to integrate from the documentation alone, without a call.

How do you handle authentication across website, app and partners?

Three kinds of caller need three kinds of credential, and conflating them is a common mistake.

Users on the website and in the app authenticate as themselves, typically with short-lived tokens issued at login and refreshed silently. Permissions are enforced by the backend on every request, never trusted from the client.

Partners authenticate as an organisation, with credentials that can be issued, scoped to the endpoints they need, rate-limited and revoked without affecting anyone else.

Internal tools such as an admin panel or a reporting system authenticate as staff, with roles. The same permission model applies, which is the whole point: one place decides who can do what.

Whatever the mechanism, it must be there from the first endpoint; retrofitting it later is painful.

When is API-first the wrong approach?

It is the wrong approach when there will only ever be one client and it is a simple one. A content site, a small internal form, a brochure with a contact page: these do not need an API layer, and adding one is ceremony.

It also demands that someone owns the interface design. An API that grows endpoint by endpoint with no one thinking about consistency becomes as tangled as the templates it replaced. In our process the interface is designed in the discovery workshop alongside the data model, and each two-week iteration ends in a working demo where the endpoints are exercised by a real client, so the API and the screens are proven together rather than in sequence.

If you expect a mobile app, a partner integration or a second frontend within the life of the product, build API-first from the start. It is far cheaper than building it twice.