9 Tweets Apr 13, 2023
API endpoint naming best practices.
Thread πŸ§΅πŸ‘‡
1️⃣ Use forward slash
Use forward slashes for resource hierarchy and to separate URI resources.
Example: https:// example .com/articles/authors
2️⃣ Use nouns, not verbs
When naming the URIs, you should use nouns to describe what the resource is and not what it does. For example:
❌ https:// example .com/api/getProfiles
βœ… http:// example .com/api/profiles
3️⃣ Use plural nouns
This makes it clear that there is more than one resource within a collection. Using singular nouns can be confusing. For example:
❌ https:// example .com/api/profile/21
βœ… http:// example .com/api/profiles/21
4️⃣ Lower case letters
As a standard, URLs are typed in lowercase. The same applies to API URIs.
5️⃣ Use hyphens to separate words
When chaining words together, hyphens are the most user-friendly way and are a better choice than underscores. For example:
https:// example .com/api/profiles/227/first-name
6️⃣ Never use file extensions
There is no purpose in using file extensions in URIs. They are unnecessary and only make it harder to read clearly.
❌ https:// example .com/api/profiles.xml
7️⃣ Include versioning
Make sure you create a new version of your API if you're making major changes that could break it.
This is usually indicated in endpoints by adding the version at the start of the endpoint. For example:
https://example .com/api/v2/articles
That’s all for now!
Follow @Rapid_API for more exclusive content. πŸ™

Loading suggestions...