API endpoint naming best practices.
Thread π§΅π
Thread π§΅π
1οΈβ£ Use forward slash
Use forward slashes for resource hierarchy and to separate URI resources.
Example: https:// example .com/articles/authors
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
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
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.
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
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
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
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. π
Follow @Rapid_API for more exclusive content. π
Loading suggestions...