curl -X POST https://fastapi-starter-sable.vercel.app/token \
-d "username=testuser&password=testpass" \
-H "Content-Type: application/x-www-form-urlencoded"
This will return a response like:
{
"access_token": "user_testuser_1234567890",
"expires_at": "2024-03-21T10:30:00"
}
curl -H "Authorization: Bearer user_testuser_1234567890" https://fastapi-starter-sable.vercel.app/items
The API comes pre-populated with sample items:
Test User Credentials:
These endpoints are accessible without authentication
List public items (No auth required)
Parameters:
curl "https://fastapi-starter-sable.vercel.app/public/items?skip=0&limit=2"
Get specific public item by ID
curl https://fastapi-starter-sable.vercel.app/public/items/1
These endpoints require authentication
/token
Get authentication token (valid for 24 hours)
curl -X POST https://fastapi-starter-sable.vercel.app/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=testuser&password=testpass"
/token/revoke
Revoke current token
curl -X POST https://fastapi-starter-sable.vercel.app/token/revoke \
-H "Authorization: Bearer user_testuser_1234567890"
List items with pagination (Auth required)
Parameters:
curl -H "Authorization: Bearer user_testuser_1234567890" "https://fastapi-starter-sable.vercel.app/items?skip=0&limit=2"
Get specific item by ID (Auth required)
curl -H "Authorization: Bearer user_testuser_1234567890" https://fastapi-starter-sable.vercel.app/items/1
/items
Create new item (Auth required)
curl -X POST https://fastapi-starter-sable.vercel.app/items \
-H "Authorization: Bearer user_testuser_1234567890" \
-H "Content-Type: application/json" \
-d '{
"name": "New Item",
"description": "A brand new item",
"price": 49.99,
"tags": ["new", "sample"],
"is_offer": false
}'
/items/1
Update entire item (Auth required)
curl -X PUT https://fastapi-starter-sable.vercel.app/items/1 \
-H "Authorization: Bearer user_testuser_1234567890" \
-H "Content-Type: application/json" \
-d '{
"name": "Updated Laptop",
"description": "Updated high-performance laptop",
"price": 1099.99,
"tags": ["electronics", "computers", "updated"],
"is_offer": true
}'
/items/1
Partially update item (Auth required)
curl -X PATCH https://fastapi-starter-sable.vercel.app/items/1 \
-H "Authorization: Bearer user_testuser_1234567890" \
-H "Content-Type: application/json" \
-d '{
"price": 899.99,
"is_offer": true
}'
/items/1
Delete item (Auth required)
curl -X DELETE -H "Authorization: Bearer user_testuser_1234567890" https://fastapi-starter-sable.vercel.app/items/1
Token Management:
user_username_timestamp
Authorization: Bearer user_testuser_1234567890
FastAPI provides automatic interactive API documentation:
user_testuser_1234567890
) with your actual token