-
Notifications
You must be signed in to change notification settings - Fork 0
Versioning
API Dock supports versioning for both remote APIs and databases through subdirectory-based configuration.
Versioning allows you to:
- Maintain multiple API versions simultaneously
- Route requests to specific versions
- Auto-route to latest version
- Version database schemas independently
Instead of a single remote.yaml file, create a directory with version files:
config/remotes/
├── my_api/
│ ├── 0.1.yaml
│ ├── 0.2.yaml
│ └── 1.0.yaml
└── another_api.yaml # Unversioned (single file)
config/databases/
├── user_db/
│ ├── 0.1.yaml
│ ├── 0.2.yaml
│ └── 1.0.yaml
└── simple_db.yaml # Unversioned
Remotes:
/{remote_name}/{version}/{path}
Databases:
/{database_name}/{version}/{route}
# Specific version
curl http://localhost:8000/my_api/0.1/users
curl http://localhost:8000/user_db/0.2/users/123
# Latest version (auto-selected)
curl http://localhost:8000/my_api/latest/users
curl http://localhost:8000/user_db/latest/users/123
# Unversioned (backward compatible)
curl http://localhost:8000/another_api/users
curl http://localhost:8000/simple_db/usersAPI Dock automatically determines the "latest" version using smart sorting with a float-first strategy:
- Try float parsing first: Attempt to parse all versions as floats
- If all parse successfully: Sort numerically (highest first)
- If any fail to parse: Fall back to string sorting (reverse alphabetical)
Versions: [0.1, 0.2, 1.0, 1.2, 2.0]
Latest: 2.0 # Correct numerical ordering
Float parsing ensures 1.2 > 1.0 > 0.2 > 0.1.
Versions: [v1, v2, v10, v11]
Latest: v2 # String sort (reverse alphabetical)
Note: String sorting can have unexpected results (v2 > v11 alphabetically).
Versions: [0.1, 0.2, v1, v2]
Latest: v2 # Can't parse "v1" as float, use string sort
When versions can't all be parsed as floats, the entire set uses string sorting.
name: my_api
description: My API - Version 0.1
url: http://localhost:5000
routes:
- users
- users/{{user_id}}name: my_api
description: My API - Version 1.0
url: http://localhost:5001 # Different backend
routes:
- users
- users/{{user_id}}
- users/{{user_id}}/profile # New in 1.0
- posts
- posts/{{post_id}}name: user_db
description: User Database - Version 0.1
tables:
users: s3://data/v01/users.parquet
routes:
- route: users
sql: SELECT * FROM [[users]]name: user_db
description: User Database - Version 1.0
tables:
users: s3://data/v10/users.parquet
permissions: s3://data/v10/permissions.parquet # New table
routes:
- route: users
sql: SELECT * FROM [[users]]
- route: users/{{user_id}}/permissions # New route
sql: |
SELECT p.*
FROM [[permissions]] p
WHERE p.user_id = {{user_id}}Access version information without a route:
# List available versions
curl http://localhost:8000/my_api
# Returns: {"remote": "my_api", "versions": ["1.0", "0.2", "0.1"], "latest": "1.0"}
# Get version config
curl http://localhost:8000/my_api/1.0
# Returns: {"name": "my_api", "description": "...", "url": "...", "routes": [...]}Keep old and new versions running simultaneously:
# 0.1.yaml - Old schema
tables:
users: s3://data/users_old.parquet
# 1.0.yaml - New schema
tables:
users: s3://data/users_new.parquetClients can migrate at their own pace:
# Old clients
curl http://localhost:8000/user_db/0.1/users
# New clients
curl http://localhost:8000/user_db/1.0/usersUse versions for breaking API changes:
# 0.1.yaml - Original response format
routes:
- route: users/{{user_id}}
sql: SELECT user_id, name FROM [[users]] WHERE user_id = {{user_id}}
# 1.0.yaml - New response format with additional fields
routes:
- route: users/{{user_id}}
sql: |
SELECT u.*, p.permissions
FROM [[users]] u
LEFT JOIN [[permissions]] p ON u.user_id = p.user_id
WHERE u.user_id = {{user_id}}Deprecate old versions by documentation:
# 0.1.yaml
name: my_api
description: "DEPRECATED: Use version 1.0. This version will be removed on 2025-12-31."
url: http://localhost:5000- Semantic Versioning - Use meaningful version numbers (0.1, 1.0, 2.0)
- Document Changes - Update description in each version file
- Keep Old Versions - Don't remove old versions immediately
- Test All Versions - Ensure each version works independently
-
Default to Latest - Use
/latest/for most recent features
Each version can have different route restrictions:
# 0.1.yaml - More restrictive
routes:
- users
- users/{{user_id}}
# 1.0.yaml - More permissive
routes:
- users
- users/{{user_id}}
- users/{{user_id}}/permissions
- users/{{user_id}}/settings
- admin/dashboard# Test all versions
curl http://localhost:8000/my_api/0.1/users
curl http://localhost:8000/my_api/0.2/users
curl http://localhost:8000/my_api/1.0/users
# Verify latest points to correct version
curl http://localhost:8000/my_api/latest/users
curl http://localhost:8000/my_api # Check version list- Unversioned configs work - Backward compatible with single-file configs
- Mixed setup supported - Some remotes versioned, others not
- No code changes needed - Versioning is purely configuration-based
- Routing and Restrictions - Route configuration
- SQL Database Support - Database queries
- Configuration - Main configuration structure
- Main README - Quick start guide