-
Notifications
You must be signed in to change notification settings - Fork 4
REST API URI naming rules
REST API URI naming plays a crucial role in providing a clear and consistent representation of resources and operations. Here are some essential rules for naming REST API URIs:
-
Nouns for resources
: URIs should use nouns to represent resources, rather than verbs. This aligns with the RESTful principle of treating resources as nouns and actions as verbs. For example, instead of/get-users
, use/users
for retrieving a list of users. -
Plural for resources
: Use plural nouns for resources, unless the resource is inherently singular. For instance, instead of/user/123
, use/users/123
for accessing a specific user's details. -
Hyphens for separation
: Separate words in URIs using hyphens-
rather than underscores_
, which are typically reserved for file extensions. This makes URIs more readable and easier to understand for both humans and machines. -
Lowercase for consistency
: Keep all URI components in lowercase to maintain consistency and avoid ambiguity. This makes the API more predictable and easier to remember for developers. -
Avoid special characters
: Avoid using special characters like semicolons, question marks, parentheses, and brackets in URIs. These characters can cause issues with parsing and routing. -
Path parameters for dynamic data
: Use path parameters to represent dynamic data, such as user IDs or product IDs. This makes the API more flexible and easier to consume. -
Clear and descriptive names
: Choose clear and descriptive names for resources and operations to enhance understanding and usability. Avoid vague or ambiguous names that could lead to confusion. -
Consistency with HTTP methods
: Use consistent naming for resources and their corresponding HTTP methods. For instance, if you use/users
for retrieving users, use/users
for creating, updating, and deleting users as well. -
Use consistent prefix for API endpoints
: Consider using a consistent prefix for all API endpoints, such as/api/v1
or/api
, to distinguish between different API versions or environments. -
Document URI naming conventions
: Clearly document your API's URI naming conventions in the API documentation to ensure consistency and clarity for developers.
By adhering to these REST API URI naming rules, you can create a consistent, readable, and easy-to-use API that aligns with RESTful principles and enhances developer experience.
- Introduction
- Variables
- Data Types
- Numbers
- Casting
- Strings
- Booleans
- Operators
- Lists
- Tuple
- Sets
- Dictionaries
- Conditionals
- Loops
- Functions
- Lambda
- Classes
- Inheritance
- Iterators
- Multi‐Processing
- Multi‐Threading
- I/O Operations
- How can I check all the installed Python versions on Windows?
- Hello, world!
- Python literals
- Arithmetic operators and the hierarchy of priorities
- Variables
- Comments
- The input() function and string operators
Boolean values, conditional execution, loops, lists and list processing, logical and bitwise operations
- Comparison operators and conditional execution
- Loops
- [Logic and bit operations in Python]
- [Lists]
- [Sorting simple lists]
- [List processing]
- [Multidimensional arrays]
- Introduction
- Sorting Algorithms
- Search Algorithms
- Pattern-matching Algorithm
- Graph Algorithms
- Machine Learning Algorithms
- Encryption Algorithms
- Compression Algorithms
- Start a New Django Project
- Migration
- Start Server
- Requirements
- Other Commands
- Project Config
- Create Data Model
- Admin Panel
- Routing
- Views (Function Based)
- Views (Class Based)
- Django Template
- Model Managers and Querysets
- Form
- User model
- Authentification
- Send Email
- Flash messages
- Seed
- Organize Logic
- Django's Business Logic Services and Managers
- TestCase
- ASGI and WSGI
- Celery Framework
- Redis and Django
- Django Local Network Access
- Introduction
- API development
- API architecture
- lifecycle of APIs
- API Designing
- Implementing APIs
- Defining the API specification
- API Testing Tools
- API documentation
- API version
- REST APIs
- REST API URI naming rules
- Automated vs. Manual Testing
- Unit Tests vs. Integration Tests
- Choosing a Test Runner
- Writing Your First Test
- Executing Your First Test
- Testing for Django
- More Advanced Testing Scenarios
- Automating the Execution of Your Tests
- End-to-end
- Scenario
- Python Syntax
- Python OOP
- Python Developer position
- Python backend developer
- Clean Code
- Data Structures
- Algorithms
- Database
- PostgreSQL
- Redis
- Celery
- RabbitMQ
- Unit testing
- Web API
- REST API
- API documentation
- Django
- Django Advance
- Django ORM
- Django Models
- Django Views
- Django Rest Framework
- Django Rest Framework serializers
- Django Rest Framework views
- Django Rest Framework viewsets