API Access & Documentation

The Ultimate Comprehensive Guide to Mastering API Architectures

By the Domain India teamPublished 9 min read
Knowledge base article
Contents (12 sections)

An API architecture is the set of choices that decide how two pieces of software talk: the style of the calls, the data format, how clients prove who they are, and how the API changes over time without breaking anyone. This guide explains the main API styles in use in 2026, when each one fits, the design rules that apply to all of them, and where each style can run on Domain India hosting.

Key takeaways

Use REST with JSON and an OpenAPI description for most public and business APIs. Choose GraphQL when many different clients need different slices of related data, gRPC for fast service-to-service calls inside your own system, webhooks to tell other systems that something happened, and WebSockets, server-sent events or a message broker (MQTT, AMQP, Kafka) for real-time and event streams. Whatever the style: HTTPS everywhere, proper authentication, versioning, rate limits and consistent errors. PHP and Node.js REST APIs run on shared hosting; brokers, gRPC and WebSocket servers need a VPS.

1. What an API architecture covers

Every API, whatever its style, answers the same questions:

  • Interface: what can a client ask for, and at which address (endpoints, operations or topics)?
  • Data format: JSON, XML, Protocol Buffers or another encoding.
  • Transport: plain HTTP request and response, a long-lived connection, or messages through a broker.
  • Security: how clients authenticate, what each one may do, and how traffic is encrypted.
  • Change: how new versions ship without breaking existing clients.

Inside the application, keep a thin layer that validates requests apart from the business logic and the database code. Then you can add a second style later, such as webhooks or GraphQL, without rewriting the core.

2. The main API styles compared

StyleHow it worksBest forWatch out for
RESTResources at URLs, HTTP methods, usually JSONPublic APIs, web and mobile back ends, CRUDChatty clients needing many calls for one screen
GraphQLOne endpoint; the client asks for exactly the fields it needsMany clients needing different data from a connected modelCaching, query cost limits and access rules per field
gRPCTyped remote calls over HTTP/2 with Protocol BuffersFast calls between your own servicesBrowsers need gRPC-Web or a proxy; not human-readable
SOAPXML envelopes described by a WSDL contractExisting enterprise, banking and government integrationsVerbose; rarely chosen for new public APIs
WebhooksYour server sends an HTTP POST to a subscriber when an event happensPayment, order and form notificationsRetries, duplicate delivery and signature checks
WebSockets and server-sent eventsA long-lived connection pushes updates to the clientChat, live dashboards, notificationsNeeds a server built for many open connections
Message brokers (MQTT, AMQP, Kafka)Publishers and subscribers exchange messages through a brokerIoT, background jobs, event streams between servicesYou run and monitor the broker
JSON-RPCA method name and parameters in a small JSON messageSimple internal tools, some blockchain and editor protocolsLess tooling than REST

REST in practice

A REST API exposes resources such as /v1/orders/123 and uses HTTP methods for actions: GET to read, POST to create, PUT or PATCH to update, DELETE to remove. Responses use HTTP status codes, and the API itself keeps no session between requests, which makes it easy to scale and cache.

http
GET /v1/orders/123 HTTP/1.1
Host: api.example.com
Authorization: Bearer <access-token>
Accept: application/json

GraphQL in practice

The client sends one query naming exactly the fields it wants, across related objects such as an order, its customer and its items, and gets back that shape in one response. Protect a public GraphQL API with query depth and cost limits, and check permissions on every field, not only on the endpoint.

Webhooks in practice

When an event happens, your system POSTs a JSON payload to the subscriber's URL. Good webhooks carry an event ID and a timestamp, are signed with a shared secret (usually an HMAC header) and are retried on failure. Receivers should verify the signature, reply quickly with a 2xx, do the heavy work afterwards, and ignore an event ID they have already processed.

3. Specifications are not styles

Two names often listed as API styles are really ways of describing an API:

  • OpenAPI (formerly Swagger) describes HTTP APIs, usually REST, in YAML or JSON. Version 3.1 and later align with JSON Schema. From one file you can generate documentation, client libraries, mock servers and request validation.
  • AsyncAPI does the same for event-driven APIs over brokers and WebSockets. Its current major version is 3.

Keep the description in version control next to the code.

4. Styles you can usually skip for new projects

  • OData is a standard for queryable REST APIs. It still matters when you integrate with Microsoft products and business intelligence tools, but it is rarely chosen for a new, general API.
  • XML-RPC is a legacy protocol. WordPress still exposes xmlrpc.php, a frequent target of password-guessing attacks; turn it off if nothing you use needs it.
  • Falcor and RSocket saw little adoption outside a few companies and have little active development. Use GraphQL or gRPC streaming instead.

5. Design rules for every API

HTTPS only
Encrypt every request with TLS, including internal calls where you can. Never send tokens over plain HTTP.
Authenticate properly
Use OAuth 2.0 with PKCE for user-facing apps, and scoped API keys or client credentials for server-to-server calls. Keep keys out of source code.
Version from day one
Put a major version in the path, such as /v1/, or in a header. Add fields freely, but never remove or rename them within a version.
Rate-limit
Limit requests per client and answer excess with 429 Too Many Requests and a Retry-After header.
Consistent errors
Return the right status code and a structured error body. RFC 9457 problem details is a good standard format.
Make retries safe
Accept an idempotency key on POST requests that create payments or orders, so a retried request can't create a duplicate.
Paginate lists
Use cursor-based pagination for large or changing lists, and set a maximum page size.
Log and monitor
Record status codes, latency and errors per endpoint, without logging tokens or personal data.

For authentication in depth, see the evolution of API authentication. For testing, see API testing with Postman.

6. Architecture patterns around your APIs

An API gateway puts one entry point, handling TLS, authentication, rate limits and routing, in front of several services. A backend for frontend is a small API shaped for one client, such as a mobile app. Event-driven designs let services react to published events instead of calling each other, which decouples them but makes tracing harder. Microservices pay off when separate teams own separate parts; for a small team, one well-structured application with one API is usually faster to build and run.

7. Choosing a style

  1. Start with REST and OpenAPI.
    It is the most widely understood choice, works with every language and tool, and caches well.
  2. Add GraphQL
    when several different front ends keep asking for new combinations of the same data.
  3. Use gRPC
    for high-volume calls between services you control.
  4. Add webhooks
    when partners need to know about events without polling you.
  5. Add real-time channels or a broker
    only when users genuinely need live updates or you have background work to spread across workers.

8. Running APIs on Domain India

Shared hosting (cPanel, DirectAdmin). REST and GraphQL APIs written in PHP run well, and so do webhook receivers. Node.js and Python apps can run through the control panel's application tools; see deploying a Node.js app on shared hosting. Some PHP functions, including socket and process functions, are disabled; check PHP disabled functions on shared hosting before you rely on an SDK. On our cPanel servers a request that takes longer than about 60 seconds is stopped with an error on most sites (90 seconds at the most), so move long work to a background job. Brokers, gRPC servers and WebSocket servers are not suited to shared hosting.

App Platform. Deploy API services from Git: Node.js apps are detected automatically, and any other language runs from a Dockerfile. The App Platform does not support WebSockets. See getting started with the App Platform.

VPS. A self-managed VPS with full root access runs anything above, including gRPC, WebSocket servers and brokers such as Mosquitto, RabbitMQ or Kafka. The cards show live prices, excluding 18% GST.

App Starter
₹100/mo + GST
  • 512 MB RAM per app
  • 1 vCPU
  • 5 GB NVMe SSD
  • PostgreSQL Database
See plan details
VPS Starter
₹552.65/mo + GST
  • 1 vCPU
  • 2 GB DDR4 RAM
  • 64 GB NVMe SSD Storage
  • 2 TB Monthly Bandwidth
See plan details

Frequently asked questions

What is the difference between REST and GraphQL?

REST exposes separate resources at their own URLs and uses HTTP methods on them. GraphQL exposes one endpoint where the client describes exactly which fields it wants. REST is simpler to cache and secure; GraphQL reduces over-fetching when many clients need different combinations of related data.

Is OpenAPI an API style?

No. OpenAPI is a specification for describing HTTP APIs, usually REST, in YAML or JSON. From that description you can generate documentation, client libraries and tests. AsyncAPI does the same for event-driven APIs.

When should I use gRPC?

Use gRPC for fast, typed calls between services you control, especially at high volume. It runs over HTTP/2 with Protocol Buffers, so browsers need gRPC-Web or a proxy, which makes REST a better fit for public APIs.

How should I version an API?

Put a major version in the path, such as /v1/, or in a header. Within a version, only add fields and endpoints; never remove or rename them. Release a new major version for breaking changes and give clients time to move.

Can I host a REST API on Domain India shared hosting?

Yes. REST and GraphQL APIs in PHP run on shared hosting, and Node.js or Python apps can run through the control panel's application tools. Some PHP functions are disabled, and requests longer than about 60 seconds time out on most cPanel sites, so long jobs should run in the background.

Where can I run WebSockets or a message broker?

On a VPS, where you have root access to run WebSocket servers and brokers such as Mosquitto, RabbitMQ or Kafka. They are not suited to shared hosting, and the Domain India App Platform does not support WebSockets.

Ready to build? Deploy a service on the App Platform, compare VPS plans for brokers and real-time servers, or open a support ticket if you are unsure where your API should run.

Put your API online

Deploy API services from Git, or choose a self-managed VPS when you need full control.

See the App Platform

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
API Architectures Explained (2026) | Domain India