mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 17:31:09 -05:00
- Add complete backend/ directory with full Django application - Add frontend/ directory with Vite + TypeScript setup ready for Next.js - Add comprehensive shared/ directory with: - Complete documentation and memory-bank archives - Media files and avatars (letters, park/ride images) - Deployment scripts and automation tools - Shared types and utilities - Add architecture/ directory with migration guides - Configure pnpm workspace for monorepo development - Update .gitignore to exclude .django_tailwind_cli/ build artifacts - Preserve all historical documentation in shared/docs/memory-bank/ - Set up proper structure for full-stack development with shared resources
7.8 KiB
7.8 KiB
API Documentation
API Overview
Base Configuration
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
],
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_PAGINATION_CLASS':
'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 20,
'DEFAULT_VERSIONING_CLASS':
'rest_framework.versioning.AcceptHeaderVersioning',
'DEFAULT_VERSION': 'v1'
}
Authentication
JWT Authentication
POST /api/token/
Content-Type: application/json
{
"username": "user@example.com",
"[PASSWORD-REMOVED]"
}
Response:
{
"access": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}
Token Refresh
POST /api/token/refresh/
Content-Type: application/json
{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}
Response:
{
"access": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}
Endpoints
Parks API
List Parks
GET /api/v1/parks/
Authorization: Bearer <token>
Response:
{
"count": 100,
"next": "http://api.thrillwiki.com/parks/?page=2",
"previous": null,
"results": [
{
"id": 1,
"name": "Adventure Park",
"slug": "adventure-park",
"status": "OPERATING",
"description": "...",
"location": {
"city": "Orlando",
"state": "FL",
"country": "USA"
},
"ride_count": 25,
"average_rating": 4.5
}
]
}
Get Park Detail
GET /api/v1/parks/{slug}/
Authorization: Bearer <token>
Response:
{
"id": 1,
"name": "Adventure Park",
"slug": "adventure-park",
"status": "OPERATING",
"description": "...",
"location": {
"address": "123 Theme Park Way",
"city": "Orlando",
"state": "FL",
"country": "USA",
"postal_code": "32819",
"coordinates": {
"latitude": 28.538336,
"longitude": -81.379234
}
},
"owner": {
"id": 1,
"name": "Theme Park Corp",
"verified": true
},
"stats": {
"ride_count": 25,
"coaster_count": 5,
"average_rating": 4.5
},
"rides": [
{
"id": 1,
"name": "Thrill Coaster",
"type": "ROLLER_COASTER",
"status": "OPERATING"
}
]
}
Rides API
List Rides
GET /api/v1/parks/{park_slug}/rides/
Authorization: Bearer <token>
Response:
{
"count": 25,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"name": "Thrill Coaster",
"slug": "thrill-coaster",
"type": "ROLLER_COASTER",
"status": "OPERATING",
"height_requirement": 48,
"thrill_rating": 5,
"manufacturer": {
"id": 1,
"name": "Coaster Corp"
}
}
]
}
Get Ride Detail
GET /api/v1/rides/{ride_slug}/
Authorization: Bearer <token>
Response:
{
"id": 1,
"name": "Thrill Coaster",
"slug": "thrill-coaster",
"type": "ROLLER_COASTER",
"status": "OPERATING",
"description": "...",
"specifications": {
"height_requirement": 48,
"thrill_rating": 5,
"capacity_per_hour": 1200,
"track_length": 3000
},
"manufacturer": {
"id": 1,
"name": "Coaster Corp"
},
"designer": {
"id": 1,
"name": "John Designer"
},
"opening_date": "2020-06-15",
"stats": {
"average_rating": 4.8,
"review_count": 150
}
}
Reviews API
Create Review
POST /api/v1/reviews/
Authorization: Bearer <token>
Content-Type: application/json
{
"content_type": "ride",
"object_id": 1,
"rating": 5,
"content": "Amazing experience!",
"media": [
{
"type": "image",
"file": "base64encoded..."
}
]
}
Response:
{
"id": 1,
"author": {
"id": 1,
"username": "reviewer"
},
"rating": 5,
"content": "Amazing experience!",
"status": "PENDING",
"created_at": "2024-02-18T14:30:00Z"
}
List Reviews
GET /api/v1/rides/{ride_id}/reviews/
Authorization: Bearer <token>
Response:
{
"count": 150,
"next": "http://api.thrillwiki.com/rides/1/reviews/?page=2",
"previous": null,
"results": [
{
"id": 1,
"author": {
"id": 1,
"username": "reviewer"
},
"rating": 5,
"content": "Amazing experience!",
"created_at": "2024-02-18T14:30:00Z",
"media": [
{
"type": "image",
"url": "https://media.thrillwiki.com/reviews/1/image.jpg"
}
]
}
]
}
Integrations
Email Service Integration
POST /api/v1/email/send/
Authorization: Bearer <token>
Content-Type: application/json
{
"template": "review_notification",
"recipient": "user@example.com",
"context": {
"review_id": 1,
"content": "Amazing experience!"
}
}
Response:
{
"status": "sent",
"message_id": "123abc",
"sent_at": "2024-02-18T14:30:00Z"
}
Media Processing
POST /api/v1/media/process/
Authorization: Bearer <token>
Content-Type: multipart/form-data
file: [binary data]
Response:
{
"id": 1,
"original_url": "https://media.thrillwiki.com/original/image.jpg",
"processed_url": "https://media.thrillwiki.com/processed/image.jpg",
"thumbnail_url": "https://media.thrillwiki.com/thumbnails/image.jpg",
"metadata": {
"width": 1920,
"height": 1080,
"format": "jpeg",
"size": 1024576
}
}
API Versioning
Version Header
Accept: application/json; version=1.0
Version Routes
# urls.py
urlpatterns = [
path('v1/', include('api.v1.urls')),
path('v2/', include('api.v2.urls')),
]
Error Handling
Error Response Format
{
"error": {
"code": "validation_error",
"message": "Invalid input data",
"details": [
{
"field": "rating",
"message": "Rating must be between 1 and 5"
}
]
}
}
Common Error Codes
authentication_error: Invalid or missing authenticationpermission_denied: Insufficient permissionsvalidation_error: Invalid input datanot_found: Resource not foundrate_limit_exceeded: Too many requests
Rate Limiting
Rate Limit Configuration
REST_FRAMEWORK = {
'DEFAULT_THROTTLE_CLASSES': [
'rest_framework.throttling.AnonRateThrottle',
'rest_framework.throttling.UserRateThrottle'
],
'DEFAULT_THROTTLE_RATES': {
'anon': '100/day',
'user': '1000/day',
'burst': '20/minute'
}
}
Rate Limit Headers
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1613664000
API Documentation
Swagger/OpenAPI
openapi: 3.0.0
info:
title: ThrillWiki API
version: 1.0.0
paths:
/parks:
get:
summary: List parks
parameters:
- name: page
in: query
schema:
type: integer
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/ParkList'
API Documentation URLs
urlpatterns = [
path('docs/', include_docs_urls(title='ThrillWiki API')),
path('schema/', schema_view),
]