Knowledge Hub
Technology

API Design for B2B Platforms

Why API Design Matters More Than You Think

For B2B platforms, your API is your product. Not a feature, not an add-on: the product itself. Your customers' developers will spend more time with your API documentation than with your marketing website. A well-designed API reduces integration time from weeks to days. A poorly designed one becomes the reason customers choose your competitor.

The best B2B APIs share three qualities: they are predictable (developers can guess how an endpoint works before reading the docs), they are forgiving (reasonable defaults, helpful error messages, graceful handling of edge cases), and they are stable (changes do not break existing integrations).

REST Conventions That Reduce Support Tickets

Follow these conventions and your support team will thank you:

  • Nouns for resources, not verbs. /users, not /getUsers. /invoices/{id}, not /fetchInvoice. The HTTP method (GET, POST, PUT, DELETE) provides the verb.
  • Consistent naming. Pick snake_case or camelCase and stick with it everywhere. Mixing conventions is the fastest way to frustrate developers.
  • Pagination on all list endpoints. Never return unbounded lists. Default to 20-50 items per page with cursor-based pagination for large datasets.
  • Meaningful HTTP status codes. 200 for success, 201 for created, 400 for bad request, 401 for unauthenticated, 403 for unauthorized, 404 for not found, 422 for validation errors, 429 for rate limited, 500 for server errors. Do not return 200 with an error message in the body.
  • Structured error responses. Include an error code, a human-readable message, and a link to the relevant documentation page. "Something went wrong" is not an error message.

Authentication and Versioning

Authentication: Use API keys for server-to-server integrations and OAuth 2.0 for user-context integrations. API keys should be passed in the Authorization header, not as query parameters (query params end up in server logs). Provide separate keys for test and production environments.

Versioning: Version your API from day one. The two common approaches are URL versioning (/v1/users) and header versioning (Accept: application/vnd.api+json;version=1). URL versioning is simpler and what most developers expect.

When you release a breaking change, maintain the old version for at least 12 months. Send deprecation notices via email and API response headers (Deprecation: true). Breaking changes with no warning will cost you customers.

Documentation That Developers Actually Use

Your API documentation needs four things:

  1. Quick start guide. A developer should be able to make their first successful API call within 10 minutes of reading your docs. Show the exact curl command, the expected response, and where to get an API key.
  2. Complete reference. Every endpoint, every parameter, every response field. Use OpenAPI/Swagger to auto-generate this from your code so it stays current.
  3. Code examples. In at least Python, JavaScript, and the primary language of your target audience. Copy-paste-ready examples, not pseudocode.
  4. Changelog. What changed, when, and what developers need to do about it. Update this with every release.

Host your docs on a fast, searchable site. Stripe's documentation is the gold standard: clean, searchable, with working code examples in multiple languages. You do not need to build something that elaborate, but study it for inspiration.

Domande Frequenti

Should I use REST or GraphQL for a B2B API? +

REST for most B2B use cases. It is simpler, more widely understood, and easier to cache. GraphQL works well when clients need to fetch deeply nested data in a single request, like mobile apps. If in doubt, start with REST.

How do you handle API rate limiting? +

Set limits per API key, not per IP. Return 429 status codes with a Retry-After header. Start with generous limits (1,000 requests/minute) and tighten based on actual usage. Provide higher limits for paying customers.

How often should you version your API? +

As rarely as possible. Non-breaking changes (adding fields, adding endpoints) do not need a new version. New versions only for breaking changes. Most well-designed APIs release a new major version every 2-3 years.

Casi Concreti

Letture Correlate

Vuoi parlare di software development?

Lavoriamo con aziende in tutta Europa su progetti di software development projects. Raccontaci a cosa stai lavorando.

Contattaci