Chapter 5: Phase 2 - API Interface

In this chapter: RESTful APIs for cultural event management, authentication and authorization, SDK development, rate limiting, caching strategies, and real-time collaboration features.

5.1 REST API Architecture

WIA-UNI-011 APIs follow REST principles with resource-oriented design, standard HTTP methods, and stateless authentication. All endpoints return JSON with consistent error handling and comprehensive documentation via OpenAPI 3.0.

Base URL Structure

https://api.cultural-exchange.org/v2/
β”œβ”€β”€ /events              # Cultural events
β”œβ”€β”€ /participants        # Participants and artists
β”œβ”€β”€ /heritage            # Heritage items
β”œβ”€β”€ /organizations       # Organizations
β”œβ”€β”€ /media               # Media assets
└── /analytics           # Analytics and reporting

5.2 Events API

Core Endpoints

MethodEndpointDescription
GET/eventsList all events with filtering and pagination
GET/events/{id}Get specific event details
POST/eventsCreate new event
PUT/events/{id}Update existing event
DELETE/events/{id}Delete event (soft delete)
GET/events/{id}/participantsList event participants
POST/events/{id}/participantsAdd participant to event
GET/events/{id}/mediaList event media assets

List Events with Filtering

GET /events?type=music&startDate=2025-01-01®ion=both&limit=50

Response:
{
  "data": [
    {
      "eventId": "UNI-011-MUSIC-2025-001",
      "eventType": "music",
      "title": { "ko": "남뢁 μŒμ•… μΆ•μ œ", "en": "Inter-Korean Music Festival" },
      "startDate": "2025-06-15T18:00:00+09:00",
      "location": { "name": { "en": "DMZ Peace Park" } }
    }
  ],
  "pagination": {
    "total": 127,
    "page": 1,
    "limit": 50,
    "pages": 3
  }
}

Query Parameters

5.3 Authentication & Authorization

API access requires OAuth 2.0 authentication with JWT tokens. Different user roles have different permissions ensuring security and compliance.

Authentication Flow

  1. Client requests token from auth server with credentials
  2. Auth server validates and issues JWT access token
  3. Client includes token in Authorization header for API requests
  4. API validates token signature and permissions
  5. API returns requested data or error

Role-Based Access Control

RolePermissionsUse Cases
PublicRead public events, heritageWebsite visitors, researchers
OrganizerCreate/edit own events, add participantsCultural institutions, NGOs
MinistryApprove events, access sensitive dataGovernment agencies
AdminFull access to all resourcesSystem administrators

Example API Request with Authentication

POST /events
Authorization: Bearer eyJhbGciOiJSUzI1NiIs...
Content-Type: application/json

{
  "eventType": "music",
  "title": { "ko": "μ„œμšΈ 평화 μ½˜μ„œνŠΈ", "en": "Seoul Peace Concert" },
  "startDate": "2025-08-01T19:00:00+09:00",
  "endDate": "2025-08-01T22:00:00+09:00",
  "location": {
    "name": { "en": "Seoul Olympic Stadium" },
    "coordinates": { "lat": 37.5151, "lng": 127.1223 }
  }
}

5.4 Heritage API

Heritage API enables documentation and discovery of Korean cultural heritage with rich metadata, regional variations, and UNESCO integration.

Heritage Endpoints

MethodEndpointDescription
GET/heritageSearch heritage items
GET/heritage/{id}Get heritage details
GET/heritage/{id}/variationsGet regional variations
GET/heritage/searchFull-text search
POST/heritageDocument new heritage item
PUT/heritage/{id}Update heritage information

Heritage Search with Semantic Matching

GET /heritage/search?q=traditional+music&category=music®ion=both

Response:
{
  "results": [
    {
      "heritageId": "HER-KR-MUSIC-001",
      "name": { "ko": "μ•„λ¦¬λž‘", "en": "Arirang" },
      "category": "music",
      "unescoStatus": "registered",
      "matchScore": 0.95,
      "regionalVariations": 12
    },
    {
      "heritageId": "HER-KR-MUSIC-002",
      "name": { "ko": "νŒμ†Œλ¦¬", "en": "Pansori" },
      "category": "music",
      "unescoStatus": "registered",
      "matchScore": 0.87,
      "regionalVariations": 5
    }
  ]
}

5.5 Media API

Media API manages photos, videos, audio recordings, and documents with proper rights management, versioning, and archival support.

Media Upload Flow

  1. Request upload URL with media metadata
  2. Upload file directly to storage (S3, etc.) using signed URL
  3. Confirm upload completion with checksum verification
  4. Media asset becomes available via API

Media Endpoints

POST /media/upload-url
{
  "filename": "peace-concert-2025.jpg",
  "type": "photo",
  "size": 2457600,
  "mimeType": "image/jpeg"
}

Response:
{
  "assetId": "MEDIA-2025-001",
  "uploadUrl": "https://storage.cultural-exchange.org/upload/...",
  "expiresIn": 3600
}

5.6 Analytics API

Analytics endpoints provide insights into cultural exchange trends, participation patterns, geographic distribution, and impact metrics.

Available Analytics

Example: Event Trend Analysis

GET /analytics/events/trends?period=2024-01-01:2025-12-31&granularity=month

Response:
{
  "period": { "start": "2024-01-01", "end": "2025-12-31" },
  "data": [
    { "month": "2024-01", "events": 12, "participants": 487 },
    { "month": "2024-02", "events": 15, "participants": 623 },
    ...
  ],
  "summary": {
    "totalEvents": 187,
    "totalParticipants": 8934,
    "averageParticipants": 47.8,
    "growthRate": 0.23
  }
}

5.7 Rate Limiting & Performance

Rate Limits

User TierRequests/HourBurst
Public10020
Organizer1,000100
Ministry10,000500
AdminUnlimited-

Response Headers

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 847
X-RateLimit-Reset: 1735110000

Caching Strategy

5.8 SDK Development

Official SDKs simplify API integration in multiple programming languages with type safety, error handling, and best practices built-in.

Supported Languages

Example: TypeScript SDK Usage

import { CulturalExchangeClient } from '@wia/cultural-exchange';

const client = new CulturalExchangeClient({
  apiKey: process.env.WIA_API_KEY
});

// List upcoming music events
const events = await client.events.list({
  type: 'music',
  startDate: new Date('2025-06-01'),
  limit: 20
});

// Create new event
const newEvent = await client.events.create({
  eventType: 'music',
  title: { ko: '평화 μ½˜μ„œνŠΈ', en: 'Peace Concert' },
  startDate: new Date('2025-08-01T19:00:00+09:00'),
  endDate: new Date('2025-08-01T22:00:00+09:00')
});

5.9 Error Handling

Consistent error responses enable robust client implementations with proper error handling and user feedback.

Standard Error Format

{
  "error": {
    "code": "INVALID_EVENT_TYPE",
    "message": "Event type 'concert' is not valid",
    "details": {
      "field": "eventType",
      "validValues": ["arts", "sports", "music", "festival", "heritage", "education"]
    },
    "timestamp": "2025-06-15T14:30:00Z",
    "requestId": "req-abc123"
  }
}

Chapter Summary

Key Takeaways: