API Academy
🌐 English
  • 🌐 English
  • 🌐 繁體中文
HomePetstore APIExplore more APIs
HomePetstore APIExplore more APIs
🌐 English
  • 🌐 English
  • 🌐 繁體中文
🌐 English
  • 🌐 English
  • 🌐 繁體中文
  1. Designing APIs
  • Introduction
  • Table of Contents
  • API Academy
    • Get Started
      • What is an API?
      • How Does an API Work?
      • How to Call an API?
      • How to Read an API Documentation?
      • Chapter Summary
      • Get realtime weather
    • API Fundamentals
      • API Funtamentals: Overview
      • Method & Path
      • Parameters
      • Request Body
      • Responses
      • API Specification & OAS
      • Chapter Summary
    • Working with APIs
      • Working with APIs: Overview
      • Making Requests from Spec
      • Environments and Variables
      • Chaining Multiple Endpoints
      • Handling Authentication
      • Handling API Signatures
      • Introduction to Scripts
      • Chapter Summary
    • Mocking APIs
      • Mocking APIs: Overview
      • Smart Mock
      • Mock Expectations
      • Cloud Mock
      • Mock Scripts
      • Chapter Summary
    • Designing APIs
      • Designing APIs: Overview
      • Introduction to API Design
      • Creating Your First API Project
      • Analyzing Requirements and Planning Your API
      • Designing Data Models
      • Designing Endpoints
      • Using Components and Reusability
      • Setting Up Authentication
      • API Design Guidelines
      • Chapter Summary
    • Developing APIs
      • Developing APIs: Overview
      • Setup: Install Your AI Coding Assistant
      • Quick Start: From Spec to Running API in 30 Minutes
      • Understanding the Generated Code
      • Testing Your API with Apidog
      • Deployment: Put Your API Online
      • Chapter Summary
    • Testing APIs
      • Testing APIs: Overview
      • Getting Started: Your First Test Scenario
      • Integration Testing and Data Passing
      • Dynamic Values
      • Assertions and Validations
      • Flow Control: If, For, ForEach
      • Data-Driven Testing
      • Performance Testing
      • Test Reports and Analysis
      • CI/CD Integration
      • Scheduled Tasks and Automation
      • Advanced Testing Strategies
      • Chapter Summary
    • API Documentations
      • API Documentations: Overview
      • Publishing Your First API Doc
      • Customizing Documentation Appearance
      • Interactive Features for Consumers
      • Advanced Publishing Settings
      • Managing API Versions
      • Chapter Summary
    • Advanced API Technologies
      • API Technologies: Overview
      • GraphQL
      • gRPC
      • WebSocket
      • Socket.IO
      • Server-Sent Events (SSE)
      • SOAP
      • Chapter Summary
    • API Lifecycle
      • API Lifecycle: Overview
      • Stages of the API Lifecycle
      • API Governance
      • API Security Best Practices
      • Monitoring and Analytics
      • API Versioning Strategies
      • The Future of APIs
      • Chapter Summary
    • API Security
      • API Security: Overview
      • API Security Fundamentals
      • Authentication vs Authorization
      • Understanding OAuth 2.0 and OpenID Connect
      • JSON Web Tokens (JWT)
      • OWASP API Security Top 10
      • Encryption and HTTPS
      • Chapter Summary
    • API Tools
      • API Tools: Overview
      • The Evolution of API Tools
      • API Clients
      • Command Line Tools (cURL, HTTPie)
      • API Design and Documentation Tools
      • API Mocking Tools
      • API Testing Tools
      • All-in-One API Platforms
      • Chapter Summary
    • API Gateway
      • API Gateway: Overview
      • What is an API Gateway?
      • Key Features of API Gateways
      • API Gateway vs Load Balancer vs Service Mesh
      • Popular API Gateway Solutions
      • The BFF (Backend for Frontend) Pattern
      • Chapter Summary
  • Modern Pet Store
    • Pet
      • Get Pet
      • Update Pet
      • Delete Pet
      • Create Pet
      • List Pets
      • Upload Pet Image
    • User
      • Update User
      • Get User
      • Delete User
      • Login
      • Logout
      • Create User
    • Store
      • List Inventory
      • Create Order
      • Get Order
      • Delete Order
      • Callback Example
      • Pay for an Order
    • Payments
      • Pay Order
    • Chat
      • Create Chat Completion
    • Webhooks
      • Pet Adopted Event
      • New Pet Available Event
  • Schemas
    • Pet
    • Category
    • User
    • ApiResponse
    • OrderPayment
    • Tag
    • Order
    • Links-Order
    • PetCollection
    • Bank Card
    • Bank Account
    • Links
    • Error
HomePetstore APIExplore more APIs
HomePetstore APIExplore more APIs
🌐 English
  • 🌐 English
  • 🌐 繁體中文
🌐 English
  • 🌐 English
  • 🌐 繁體中文
  1. Designing APIs

API Design Guidelines

You've now designed a complete User module with schemas, endpoints, components, and authentication. But as your API grows and more team members contribute, maintaining consistency becomes challenging. How do you ensure everyone follows the same naming conventions, path structures, and error handling patterns?
This is where API Design Guidelines come in. Design guidelines are a set of standards and best practices that ensure your API is consistent, professional, and easy to use.
In this article, we'll learn how to create and use API design guidelines in Apidog, and leverage AI features to check compliance and improve naming.

1. Why Do You Need Design Guidelines?#

API Design Guidelines are a documented set of rules and conventions for designing APIs. They define how your team should name fields, structure paths, handle errors, and more.

Without Design Guidelines#

Inconsistency β€” Different naming styles (camelCase vs snake_case)
Confusion β€” Unclear path structures (/user vs /users)
Poor Developer Experience β€” Unpredictable API behavior
Hard to Maintain β€” No standard to follow when making changes
Team Conflicts β€” Different developers follow different patterns

With Design Guidelines#

Consistency β€” All endpoints follow the same patterns
Better Collaboration β€” Team aligns on standards
Professional Quality β€” API follows industry best practices
Easier Onboarding β€” New team members have clear guidelines
OpenAPI Compliance β€” API specifications are standardized

2. Creating API Design Guidelines in Apidog#

Apidog makes it easy to create design guidelines for your project.

Step 1: Create a New Design Guideline#

1.
In your Apidog project, click the "+" button above the folder tree
2.
Select "New API design guidelines"

Step 2: Choose a Template#

You'll be presented with two options:
Option 1: Example Template (Recommended)
What it is: A complete, ready-to-use design guideline template
Based on: OpenAPI Specification and Microsoft API Design Best Practices
Includes: Comprehensive rules for naming, paths, status codes, errors, and more
Best for: Most teams, especially those starting fresh
Option 2: Blank Template
What it is: A basic structure with minimal content
Best for: Teams with existing design standards who want to customize from scratch
For the User module, choose the "Example Template" to start with industry best practices.

Step 3: Preview and Confirm#

1.
Preview the template content
2.
Click "Confirm" to create the guideline
The API design guideline will appear at the top of your folder tree, making it visible to all team members.

3. Understanding the Design Guideline Structure#

Apidog's example template covers these key areas:

1. Naming Conventions#

Field Naming:
Use camelCase for JSON field names (e.g., firstName, createdAt)
Use descriptive names that clearly indicate the field's purpose
Avoid abbreviations unless widely recognized
Endpoint Naming:
Use lowercase and hyphens for multi-word paths (e.g., /user-preferences)
Or use lowercase with no separators (e.g., /userpreferences)
Be consistent across the API

2. Path Design#

RESTful Resource Paths:
Use plural nouns for collections (e.g., /users, not /user)
Use resource hierarchy to show relationships (e.g., /users/{id}/orders)
Keep paths simple and intuitive
Path Parameters:
Use {id} for resource identifiers
Use descriptive names for non-ID parameters (e.g., /users/{userId}/posts/{postId})

3. HTTP Status Codes#

Common Status Codes:
200 OK β€” Successful GET, PUT, PATCH
201 Created β€” Successful POST (resource created)
204 No Content β€” Successful DELETE or action with no response body
400 Bad Request β€” Invalid request parameters
401 Unauthorized β€” Authentication required or failed
403 Forbidden β€” Authenticated but not authorized
404 Not Found β€” Resource doesn't exist
422 Unprocessable Entity β€” Validation errors
500 Internal Server Error β€” Server-side error

4. Error Handling#

Standard Error Response:
Use consistent error response structure (e.g., RFC 9457 Problem Details)
Include error type, title, status, detail, and instance
Provide helpful error messages for developers

5. Versioning#

API Versioning:
Use URL versioning (e.g., /v1/users) or header versioning
Clearly document breaking changes
Support previous versions during deprecation period

4. Why OpenAPI Specification Compliance Matters#

The OpenAPI Specification (OAS) is an industry standard for describing RESTful APIs. Following it ensures:

Benefits of OpenAPI Compliance#

1.
Interoperability β€” Your API works with OpenAPI tools (Swagger UI, Postman, etc.)
2.
Documentation β€” Automatically generate interactive API documentation
3.
Code Generation β€” Generate client SDKs in multiple languages
4.
Validation β€” Validate API requests and responses against the spec
5.
Industry Standard β€” Widely adopted by companies like Microsoft, Google, IBM

Common Compliance Issues#

Missing descriptions β€” Endpoints or parameters without descriptions
Inconsistent naming β€” Mixed camelCase and snake_case
Missing examples β€” No request or response examples
Invalid status codes β€” Using non-standard HTTP status codes
Missing schemas β€” Inline definitions instead of reusable schemas

5. Customizing Design Guidelines for Your Team#

After creating the guideline, you can customize it:
1.
Click on the API Design Guidelines at the top of the folder tree
2.
Edit the content using Apidog's markdown editor
3.
Add or modify sections based on your team's needs
Common customizations:
Add company-specific naming conventions
Define custom error codes
Add security requirements
Include team-specific examples

6. Using AI Features to Improve Your API Design#

Apidog offers AI-powered features to help you follow design guidelines automatically.

AI Naming#

What it does: Generates standardized field names based on your design guidelines
How to use:
1.
In any endpoint or schema, hover over a field name
2.
Click the AI naming icon (✨)
3.
Enter a description of what the field represents (or use the existing description)
4.
Click "Send"
The AI will generate multiple field name suggestions based on:
Your API design guidelines
Current document context
The field description
Example:
Description: "When the user account was created"
AI suggestions: createdAt, accountCreatedAt, registrationDate
Each suggestion includes an explanation and rating
Select the best option and click "Adopt" to apply it.

Endpoint Compliance Check#

What it does: Analyzes your endpoint against design guidelines and provides a compliance score
How to use:
1.
Open any endpoint in your API
2.
Click the "Endpoint compliance check" button in the upper-right corner
3.
The AI will analyze the endpoint and generate a report
The report includes:
Compliance score for different aspects (naming, structure, documentation, etc.)
Detailed explanations of what's wrong
Suggestions for improvement
Example issues detected:
Field name doesn't follow camelCase convention
Missing response examples
HTTP status code not standard
Missing endpoint description

7. Applying Guidelines to the User Module#

Let's review the User module against design guidelines.

Check Naming Conventions#

Review field names:
βœ… firstName, lastName, createdAt β€” Good camelCase
βœ… email, phone, preferences β€” Clear and descriptive
⚠️ Check if all fields are consistently named
Review endpoint names:
βœ… /users β€” Plural noun for collection
βœ… /users/{id} β€” Clear resource identifier
βœ… /user/login, /user/logout β€” Consistent naming

Check Path Design#

Resource paths:
βœ… /users for collection
βœ… /users/{id} for individual resource
βœ… Simple and intuitive hierarchy

Check Status Codes#

Verify correct status codes:
βœ… POST /users returns 201 Created
βœ… GET /users/{id} returns 200 OK
βœ… PUT /users/{id} returns 200 OK
βœ… DELETE /users/{id} returns 204 No Content
βœ… Error responses use 400, 404, 422 appropriately

Check Error Handling#

Verify error responses:
βœ… Using Error schema component
βœ… Following RFC 9457 structure
βœ… Consistent error format across endpoints

8. Using AI to Check User Module Compliance#

Let's use AI to check one of our User module endpoints:

Step 1: Open an Endpoint#

Open POST /users (Create User) endpoint

Step 2: Run Compliance Check#

1.
Click "Endpoint compliance check" in the upper-right corner
2.
Wait for AI to analyze the endpoint

Step 3: Review the Report#

The AI will provide scores and feedback on:
Naming Compliance β€” Are field names following guidelines?
Documentation Quality β€” Are descriptions clear and complete?
Response Structure β€” Are responses properly defined?
Error Handling β€” Are error responses standardized?
Examples β€” Are request/response examples provided?

Step 4: Make Improvements#

Based on the AI feedback:
Update field names if needed
Add missing descriptions
Ensure all responses have examples
Fix any compliance issues

9. Best Practices for Design Guidelines#

1. Start Early#

Create design guidelines before building many endpoints. It's easier to follow guidelines from the start than to refactor later.

2. Keep Guidelines Accessible#

Place the design guideline document prominently in your project so all team members can easily reference it.

3. Review Regularly#

As your API evolves, update the design guidelines to reflect new patterns and lessons learned.

4. Use AI Features#

Leverage AI naming and compliance checks to automate guideline enforcement.

5. Educate Your Team#

Ensure all team members understand the guidelines and why they matter.

10. Key Takeaways#

API Design Guidelines help you create consistent, professional APIs:
1.
Create Guidelines Early β€” Use Apidog's example template to start
2.
Follow OpenAPI Specification β€” Ensures compatibility and interoperability
3.
Cover Key Areas β€” Naming, paths, status codes, errors, versioning
4.
Customize for Your Team β€” Add company-specific standards
5.
Use AI Features β€” AI naming and compliance checks automate enforcement
6.
Check Compliance Regularly β€” Review endpoints against guidelines
Benefits:
Consistency β€” All endpoints follow the same patterns
Quality β€” Professional, standards-compliant APIs
Efficiency β€” Team works faster with clear guidelines
Maintainability β€” Easier to update and extend the API

What's Next?#

Now that your User module has design guidelines and authentication, you've completed the design phase!
Let's review the key concepts in the Chapter Summary before moving on to development.
Modified atΒ 2025-12-26 04:34:26
Previous
Setting Up Authentication
Next
Chapter Summary
Built with