How to design APIs for mobile clients

· Category: API & REST

Short answer

Mobile APIs must account for unreliable networks, limited bandwidth, and battery constraints by minimizing payload size and request count.

Steps

  1. Implement field selection so mobile clients request only necessary data.
  2. Compress responses with gzip or brotli to reduce transfer size.
  3. Design coarse-grained endpoints that return aggregated data in fewer calls.
  4. Support pagination and caching to handle large datasets gracefully.
  5. Version APIs to allow mobile app updates to align with backend changes.

Tips

  • Use binary serialization formats like Protocol Buffers for extreme efficiency.
  • Implement request coalescing to batch multiple client needs.
  • Handle offline scenarios with retry queues and sync endpoints.
  • Optimize image and media delivery through CDNs with adaptive compression.

Common issues

  • Chatty APIs causing battery drain from frequent radio activation.
  • Large JSON payloads leading to slow rendering and high memory use.
  • Breaking changes forcing users to update apps immediately.
  • Lack of retry-friendly idempotency causing duplicate actions on poor networks.

Example

curl -X GET https://api.example.com/users   -H "Accept: application/json"   -H "Authorization: Bearer $TOKEN"

This curl command demonstrates a standard GET request with headers for content negotiation and bearer token authentication.