10 Tweets Apr 13, 2023
Tips when building a REST API.
A Thread πŸ§΅πŸ‘‡
πŸ“Œ Name resources consistently
Inconsistent naming makes your API more challenging to use. Users should be able to assume names for your resources.
For example, β€˜id_user’ and β€˜user_name’ is inconsistent. Using a consistent format would be β€˜user_id’ and β€˜user_name.’
πŸ“Œ Use JSON response formats
JSON is the most widely used data exchange format. There are various JSON response formats used today.
For guidance, read the official JSON specification: JSON data exchange standard (json.org), and use a response format specified by your organization or one made specifically for API responses (e.g., jsonapi.org)
πŸ“Œ Consider authorization control
Consider both user-level authorization and application-level authorization.
User-level authorization is for access control and auditing. It controls who can access your API, which is vital if your API deals with sensitive data.
Application-level authorization means controlling which applications can access your API without limiting who can access them. This may be less suitable for APIs using sensitive data.
πŸ“Œ Documentation
Generating documentation alongside the design and building process is a good idea.
Always include a getting started section, a description of what your API does, task-based guidance, code snippet examples, and a common errors section.
πŸ“Œ Use the UTF-8 Standard
Unicode is the world standard for consistently encoding and handling texts in global writing systems. Using the UTF-8 Standard for character sets ensures texts will remain stable when stored and exchanged.
πŸ“Œ Apply rate-limiting
Rate-limiting controls the requests your API receives in a given period.
Limiting traffic to your API can prevent potential attackers from launching a DDoS attack and other unexpected request influxes. It also improves scalability.
Thanks for reading! πŸ™
Follow @Rapid_API for more exclusive content.

Loading suggestions...