What is a base URL and how should it be structured?
Answer
The base URL is the common prefix shared by all endpoints in an API. A well-structured base URL looks like: https://api.example.com/v1. Best practices include using a dedicated subdomain (api.example.com instead of example.com/api) to allow independent scaling and routing. Include the API version in the base URL (/v1) so clients can target a specific version. Use HTTPS always — never expose APIs on plain HTTP in production. The base URL should be stable and not change — all versioning is handled through the version segment. For SDKs, configure the base URL as an environment variable so clients can point to dev/staging/production without code changes.
Previous
What is the Accept-Language header and how is it used?
Next
What is the difference between a collection resource and a singleton resource?
More REST API Design Questions
View all →- Beginner What is REST and what are its six architectural constraints?
- Beginner What are the main HTTP methods used in REST APIs and what do they do?
- Beginner What is idempotency and which HTTP methods are idempotent?
- Beginner What are the most important HTTP status codes in REST APIs?
- Beginner What are REST resource naming conventions?