Advanced URL Anatomy in API Documentation

Master the advanced components of URL structure in API documentation - endpoints, resources, HTTP methods, status codes, and authentication. Learn how each element enhances API functionality and why understanding these advanced URL concepts is essential for effective API integration and documentation.

Table of Contents

You now know about the components of a URL: protocol, domain, path, query parameters, and fragment identifiers. But that’s not all! URLs also have endpoints and resources. In this chapter, you’ll learn about endpoints and resources and how they differ from paths.

The Power of API Endpoints
The world's largest cloud providers handle billions of API endpoint calls daily. A well-designed endpoint structure can significantly impact API performance, security, and developer adoption rate.

Let’s start with an example URL: https://api.example.com/users/12345?name=John Doe

The above URL has following components, and we document all of them if present:

  • Endpoint: https://api.example.com/users/12345?name=John Doe
  • Resource: /12345?name=John Doe

Let’s see everything in detail. Select the appropriate tabs for more information. For example, if you want all the relevant information on domain name, select the Endpoint tab.

Endpoint

An endpoint is a complete URL that can be used to access a resource. It includes the protocol (for example, HTTP or HTTPS), domain name, path, and query parameters (if any). The HTTP method is also typically included in the endpoint.

In our URL, the endpoint is: https://api.example.com/users/12345?name=John Doe.

This endpoint can be used to retrieve the user with the ID 12345 from the API exposed by api.example.com.

How to Identify an Endpoint?

To identify an endpoint, look for the following components in the URL:

  • Protocol (for example, HTTP or HTTPS)
  • Domain name
  • Path
  • Query parameter (if any)

For example, in the following URL, the endpoint is: https://api.example.com/users/12345:

HTTP GET /users/12345
Questions to ask yourself about endpoints:
  • What is the purpose of the endpoint in this API?
  • What is the full URL of the endpoint, including the protocol, domain, path, and query parameters?
  • What HTTP methods can be used with this endpoint (for example, GET, POST, PUT, DELETE)?
  • What type of data does this endpoint return (for example, JSON, XML)?
  • Are there any specific security considerations for this endpoint (for example, authentication or authorization requirements)?
  • Is the endpoint documented, and if so, where can you find the documentation?

Resource

A resource is a data object or entity that is exposed by an API. It can be anything from a single user to a complex product catalog. Resources are typically represented as JSON or XML objects in API responses.

For example, the following JSON object could represent a user resource:


{
  "id": 12345,
  "name": "John Doe",
  "email": "john.doe@example.com"
}

Resources can be accessed through endpoints. For example, the following endpoint could be used to retrieve the user with the ID 12345:

HTTP GET /users/12345

Resources can also be created, updated, and deleted through endpoints. For example, the following endpoint could be used to create a new user:

HTTP POST /users

How to Identify a Resource?

To identify a resource, look for the following in the URL:

  • Path
  • Query parameters (if any)

For example, in the following URL, the resource is the user with ID 12345:

https://api.example.com/users/12345
Questions to ask yourself about resources:
  • What is the purpose of this resource in the context of the API?
  • What data does this resource represent (for example, user, product, order)?
  • What is the structure and schema of this resource's data (for example, fields, attributes)?
  • How can you uniquely identify this resource (for example, ID, URL, or other key)?
  • What operations can you perform on this resource (for example, read, create, update, delete)?
  • Are there any relationships between this resource and other resources in the API?
  • What are the common use cases for accessing or modifying this resource?
  • Are there any specific access control or permissions associated with this resource?
  • How is this resource represented in API responses (for example, JSON, XML)?

Advanced URL Concepts for API Documentation

Now that we’ve covered the basics of endpoints and resources, let’s explore some advanced URL concepts that are crucial for creating effective, secure, and user-friendly API documentation.

URL Encoding: Making Special Characters Safe

Have you ever noticed that spaces in URLs are replaced with %20 or +? That’s URL encoding in action!

URL encoding (also called percent-encoding) converts characters that aren’t allowed in URLs into a format that is. This is especially important for APIs that handle user input or special characters.

For example, the URL https://api.example.com/search?q=John Doe should actually be encoded as https://api.example.com/search?q=John%20Doe.

Here are some common URL encoding situations:

  • Spaces become %20 or +
  • Special characters like &, =, ?, and / become %26, %3D, %3F, and %2F
  • Non-ASCII characters (like ñ, é, or emoji) are encoded into their UTF-8 byte values

When documenting APIs, you should:

  • Show both the readable and encoded versions of URLs when they contain special characters
  • Remind developers to encode values when building URL strings programmatically
  • Mention which characters need special handling in your API
Questions to ask yourself about URL encoding:
  • Which special characters need to be encoded in this URL?
  • How are spaces represented in URL-encoded form?
  • What happens if you don't properly encode special characters in URLs?
  • Are there differences in how different programming languages handle URL encoding?
  • How do you decode URL-encoded strings?
  • Which characters have special meanings in URLs and need to be encoded?

Relative vs. Absolute URLs in API Documentation

When writing API documentation, you’ll need to decide whether to use absolute URLs (full URLs including the domain) or relative URLs (partial URLs that depend on a base URL).

Absolute URLs:

  • Example: https://api.example.com/v1/users/12345
  • Benefits: Self-contained, no ambiguity, works anywhere
  • Best for: API reference documentation, examples that need to be copy-pasted

Relative URLs:

  • Example: /v1/users/12345 (relative to the API’s base URL)
  • Benefits: Shorter, environment-agnostic, easier to maintain when base URL changes
  • Best for: Documentation that establishes a base URL upfront, internal references

URL Types Comparison

Feature Absolute URLs Relative URLs
Includes full domain
Works without context
Environment-agnostic
Shorter in documentation
Easier maintenance when domain changes

Documenting Best Practices for URL Design

As technical writers, you need to clearly explain the URL design patterns adopted by your API developers. Focus on these documentation aspects:

  1. Document Resource Naming Conventions
    • Explain if your API uses nouns for resources (e.g., /users/123)
    • Clarify if plural nouns are used for collections (e.g., /products)
    • Example: “Our API uses plural nouns to represent resource collections. Individual resources are accessed using their unique IDs.”
  2. Explain Hierarchical Relationships
    • Document how nested resources are represented (e.g., /users/123/orders)
    • Example: “Child resources are accessed through their parent resources as shown in this pattern: /parent/{parentId}/child/{childId}
  3. Clarify Naming Conventions
    • Document whether hyphenation, camelCase, or underscore_notation is used
    • Example: “All resource names use hyphenated-lowercase format for multi-word resources (e.g., /shipping-addresses)”
  4. Create Consistency Guides
    • Create a style guide section specifically for URL patterns
    • Document exceptions to standard patterns with clear examples

Remember, your job is not to design these patterns but to explain them clearly so developers can correctly implement your API.

Documenting Security Considerations for API URLs

Technical writers play a crucial role in communicating security practices through documentation. Here’s how to effectively document security aspects of URLs:

  1. Clearly Document Security Warning Notices
    • Prominently display warnings about sensitive data: “⚠️ Never include authentication credentials in URL parameters”
    • Use highlighted callout boxes for critical security information
  2. Document Protocol Requirements
    • Clearly state if HTTPS is required: “All API requests must use HTTPS. HTTP requests will be rejected.”
    • Explain consequences of using incorrect protocols
  3. Document Authentication Parameter Placement
    • Explain where authentication belongs (typically headers, not URLs)
    • Provide contrasting examples of correct vs. incorrect approaches:
      • ✅ CORRECT: Authorization: Bearer {token} in headers
      • ❌ INCORRECT: /api/data?token=1234abc in URL
  4. Document ID Exposure Guidelines
    • Explain your API’s approach to resource identifiers
    • Example: “This API uses non-sequential UUIDs to prevent resource enumeration”
  5. Document Validation Requirements
    • Explain any input validation implemented for URL parameters
    • Provide examples of valid vs. invalid parameters

The technical writer’s role is to communicate these security measures clearly, helping developers use the API securely rather than implementing security themselves.

Documenting Common URL Issues for End Users

How to Document URL Troubleshooting for API Users

📝

Documentation Challenge: Explaining Deeply Nested URLs

What to document: Provide a visual hierarchy diagram for complex URLs like /organizations/123/departments/456/teams/789/members/101112

Documentation approach: Create a table showing each path segment and its purpose, with examples of alternatives:

  • Standard approach: /organizations/{orgId}/departments/{deptId}/teams/{teamId}/members/{memberId}
  • Alternative approach: /members/{memberId}?team={teamId}
📝

Documentation Challenge: Clarifying Inconsistent Resource Names

What to document: When your API uses varying terms like /users, /staff, and /customers for similar concepts

Documentation approach: Create a resource glossary that maps business concepts to API endpoints:

Business Concept API Endpoint When to Use
System users /users For managing login accounts
Staff members /staff For employee-specific operations
📝

Documentation Challenge: Explaining Action-Based URLs

What to document: How to properly use verb-based endpoints if your API includes them (like /getUsers or /createOrder)

Documentation approach: Create a "URL Patterns" section that explains your API's approach to actions:

This API uses two types of URL patterns:

  • Resource-based endpoints: GET /users, POST /orders
  • Action-based endpoints: /convertCurrency, /validateAddress

Use resource-based endpoints when working with data objects, and action-based endpoints for stateless operations.

📝

Documentation Challenge: Documenting Complex Query Parameters

What to document: How to use endpoints with many parameters like /search?param1=value1&param2=value2&param3=value3...

Documentation approach: Create parameter tables with example combinations:

  • Use expandable sections for different use cases
  • Provide code samples showing the most common parameter combinations
  • Create a decision tree to help users determine which parameters they need

Example: "For basic searches, only the query parameter is required. Add filter parameters to narrow results."

Documentation Best Practices for API URLs

As technical writers, your goal is not just to understand URL components but to document them effectively for your audience. Here are specific documentation best practices for API URLs:

1. Create Clear Visual Hierarchies

Document URL components using visual aids:

https://api.example.com/v2/users/12345?fields=name,email
└─┬─┘ └───┬───┘ └┬┘└─┬─┘└┬┘ └────┬────┘
  │       │      │   │   │       └─ Query Parameters
  │       │      │   │   └─ Resource ID
  │       │      │   └─ Collection
  │       │      └─ Version
  │       └─ Domain
  └─ Protocol

2. Use Consistent Formatting

Establish and follow formatting standards in your documentation:

  • Use code formatting for all URL components
  • Bold or color-code variable parts that users must replace
  • Include parameters tables that explain each variable component

3. Include Clear Examples

Provide multiple examples for different use cases:

  • Basic example (minimal required parameters)
  • Complete example (all possible parameters)
  • Error examples (showing common mistakes)

4. Document URL Parameters Thoroughly

When documenting URL parameters, create comprehensive parameter tables that answer all possible developer questions. Here’s a model parameter documentation table structure:

World-Class URL Parameter Documentation

Property Documentation Guidance Example
Name
Required
  • Use exact casing as expected by API
  • Use code formatting
  • Indicate if case-sensitive

productId (case-sensitive)

Description
  • Write 1-2 clear sentences
  • Start with a verb
  • Include business context

Specifies the unique identifier of the product to retrieve. This ID is generated when a product is created and remains constant across all environments.

Location
  • Specify exactly where parameter appears
  • Use consistent terminology

Path parameter (in URL path)

Other examples: Query parameter, Path parameter, Header

Data Type
  • Use language-neutral terms
  • Include format for complex types
  • Link to schemas for objects

string (UUID format)

Other examples: integer, boolean, array of strings, object (see schema)

Required?
  • Be explicit about requirement
  • Explain any conditional requirements
  • Use visual indicators

Required

Or: Optional, Required if type=detailed

Default
  • Always document if there is a default
  • Use exact value format
  • Explain if not applicable

None (must be specified)

Other examples: 10, "latest", false, 3 days ago

Constraints
  • List all validation rules
  • Include min/max values
  • Document character limitations
  • Must be a valid UUID v4 format
  • 32 characters plus hyphens
  • Case-insensitive

Other examples: 1-100 characters, Values: ASC or DESC, Must match pattern: [A-Z0-9]{8}

Examples
  • Provide multiple realistic examples
  • Show both valid and invalid examples
  • Include full context

Valid:

GET /products/3fa85f64-5717-4562-b3fc-2c963f66afa6

Invalid:

GET /products/123 // Error: Invalid UUID format
Notes
  • Include edge cases
  • Document common errors
  • Add related parameters

ℹ️ The productId for sandbox environments uses a different format prefix than production. Sandbox products always start with TEST-.

⚠️ This parameter cannot be used with the productSku parameter.

This comprehensive parameter table structure includes all essential information developers need, presented in a visually clear format. Using this consistent structure for all parameters ensures your documentation is thorough and accessible. Each row provides both guidance for technical writers and real-world examples.

5. Address Common Documentation Challenges

When documenting APIs, be prepared to handle:

  • Environment differences: Document how URLs change between development, staging, and production
  • Authentication details: Clearly mark where authentication tokens belong in the URL or headers
  • Encoding requirements: Explain which parameters need special encoding and why
  • Rate limits: Document any URL-based rate limiting (e.g., per endpoint)

Remember that good API documentation helps developers implement your API correctly the first time, reducing support burden and improving adoption.

You’ve now learned advanced concepts of URL anatomy for API documentation. In the next chapter, we’ll explore data formats used in API communication, which will build upon the URL concepts we’ve mastered here.

Test Your Knowledge: URL Anatomy

Look at this URL: https://api.example.com/v2/products/electronics?brand=apple&sort=price#details

Can you identify:

  1. The endpoint
  2. The resource path
  3. The query parameters
  4. The fragment identifier

Frequently Asked Questions

URL Basics & Structure

URL Implementation & Best Practices

URL Security & Performance

Advanced URL Concepts

Key Takeaways

  • Endpoints are complete URLs used to access API resources, including protocol, domain, path, and query parameters
  • Resources are data objects or entities exposed by an API, typically represented as JSON or XML
  • URL encoding is essential for handling special characters in URLs, converting them to a web-safe format
  • Use absolute URLs for standalone examples and relative URLs for environment-agnostic documentation
  • Follow RESTful URL design best practices: use nouns, maintain hierarchies, and be consistent
  • Prioritize security in URL design by using HTTPS, avoiding sensitive data in URLs, and implementing proper authentication

Test Your Knowledge

Check your understanding of advanced URL concepts with this quiz.
Question 1 of
Technical Writing Expert

Was this guide helpful?

If you found this advanced URL anatomy guide valuable, please share it with your colleagues or on social media. Your feedback helps us improve our content!

Advanced URL Resources

Expand your understanding of URL structure with these carefully selected resources.