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.
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
| Style | How it works | Best for | Watch out for |
|---|---|---|---|
| REST | Resources at URLs, HTTP methods, usually JSON | Public APIs, web and mobile back ends, CRUD | Chatty clients needing many calls for one screen |
| GraphQL | One endpoint; the client asks for exactly the fields it needs | Many clients needing different data from a connected model | Caching, query cost limits and access rules per field |
| gRPC | Typed remote calls over HTTP/2 with Protocol Buffers | Fast calls between your own services | Browsers need gRPC-Web or a proxy; not human-readable |
| SOAP | XML envelopes described by a WSDL contract | Existing enterprise, banking and government integrations | Verbose; rarely chosen for new public APIs |
| Webhooks | Your server sends an HTTP POST to a subscriber when an event happens | Payment, order and form notifications | Retries, duplicate delivery and signature checks |
| WebSockets and server-sent events | A long-lived connection pushes updates to the client | Chat, live dashboards, notifications | Needs a server built for many open connections |
| Message brokers (MQTT, AMQP, Kafka) | Publishers and subscribers exchange messages through a broker | IoT, background jobs, event streams between services | You run and monitor the broker |
| JSON-RPC | A method name and parameters in a small JSON message | Simple internal tools, some blockchain and editor protocols | Less 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.
GET /v1/orders/123 HTTP/1.1
Host: api.example.com
Authorization: Bearer <access-token>
Accept: application/jsonGraphQL 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
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
- Start with REST and OpenAPI.It is the most widely understood choice, works with every language and tool, and caches well.
- Add GraphQLwhen several different front ends keep asking for new combinations of the same data.
- Use gRPCfor high-volume calls between services you control.
- Add webhookswhen partners need to know about events without polling you.
- Add real-time channels or a brokeronly 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.
- 512 MB RAM per app
- 1 vCPU
- 5 GB NVMe SSD
- PostgreSQL Database
- 1 vCPU
- 2 GB DDR4 RAM
- 64 GB NVMe SSD Storage
- 2 TB Monthly Bandwidth
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.
Deploy API services from Git, or choose a self-managed VPS when you need full control.
See the App Platform