Also your REST API can benefit from being accessible and inclusive !

15/10/2024

We exclusively think about front-ends when we talk about accessibility and working on inclusive websites, but you might also follow several guidelines to go the extra mile and also design your api with accessibility in mind. Here are 10 tips I'd like to share:

1. Clear, consistent, and intuitive API Design

  • Ensure the API design follows REST principles and is predictable.
  • Use consistent naming conventions for endpoints, parameters, and resources. Stick to widely adopted conventions (e.g., plural nouns for resource names).
  • Offer a clear structure that is easy to understand and use, reducing cognitive load for users who may have cognitive disabilities.

2. Comprehensive Documentation

  • Provide thorough, clear, and accessible API documentation in multiple formats (e.g., HTML, Markdown, PDF).
  • Include examples of requests and responses, including edge cases.
  • Ensure the documentation website is WCAG 2.1 compliant, with features like keyboard navigability, screen reader support, and clear headings.
  • Consider providing an audio version or interactive tutorials to make the documentation more accessible to individuals with visual or learning impairments.

3. Descriptive and Actionable Error Messages

  • Make error messages clear, descriptive, and actionable. Avoid cryptic codes or messages that require additional context.
  • Provide clear information on how to resolve issues, ensuring developers understand what went wrong and how to fix it.
  • Use standard HTTP status codes (e.g., 400 Bad Request, 404 Not Found) along with detailed descriptions.

4. Localization and Internationalization

  • Design the API to be easily localizable and adaptable to different languages, cultures, and regions.
  • Support multiple languages for error messages and documentation, and allow date, number, and currency formats that conform to various locales.
  • Consider supporting right-to-left (RTL) languages when appropriate.

5. Support for Assistive Technologies

  • Ensure your API is compatible with assistive technologies such as screen readers, which some developers with visual impairments might use to navigate the API documentation or output.
  • API responses should be structured in a way that can be easily parsed and read aloud by screen readers. Consistent and clear formatting of JSON/XML responses is key here.

6. Rate Limiting and Resource Usage Transparency

  • Implement fair rate limiting and quota policies to ensure that users with slower systems or networks (common in low-income regions or rural areas) are not disadvantaged.
  • Provide clear feedback when limits are hit, along with suggestions for how users can optimize requests or retry after a certain period.

7. Customizable Response Formats

  • Offer APIs that return data in multiple formats (e.g., JSON, XML, CSV) so that users with different needs or assistive technologies can choose the format that works best for them.
  • Support query parameters or headers to specify response format.

8. Minimal Cognitive Load for API Interactions

  • Reduce the number of steps or fields required to make a valid API request. Avoid overly complex query parameters or deeply nested JSON objects.
  • Make responses concise and structured so that users with cognitive impairments can easily process the data.
  • Provide clear instructions in the documentation about mandatory and optional parameters.

9. Versioning and Backward Compatibility

  • Use proper versioning (v1, v2, etc.) to ensure that users relying on older versions of the API aren't suddenly locked out or forced to upgrade, which can be disruptive, especially for users with fewer resources to adjust to changes quickly.
  • Clearly document breaking changes and give advance notice before deprecating old versions.

10. Secure Authentication Methods

  • Use secure, standard, and widely accepted authentication methods (OAuth2, OpenID Connect, etc.) and ensure they are easy to implement.
  • Avoid overly complex authentication workflows that may exclude users who rely on assistive technologies.
  • Consider including support for multi-factor authentication (MFA), which adds security but should be implemented with accessibility in mind (e.g., allowing MFA via SMS for users who might not have access to other devices).
  • Provide clear and simple guidance on how to handle authentication and token renewal.

Bonus: Inclusive Language in API Documentation and Responses

  • Ensure that your API's documentation and error messages use inclusive language. Avoid terms that could be perceived as biased, gendered, or offensive.
  • Avoid assumptions about the user's background, abilities, or cultural context in both the API design and the language used in the documentation.


Let's go the extra mile and reach out to the 20% of our population who deserve an accessible world.