iTing API Documentation

Complete API documentation for the iTing backend service.

System APIs

Health Check

GET /api/health

curl -X GET http://localhost:3000/api/health

Metrics

GET /metrics

curl -X GET http://localhost:3000/metrics

Authentication APIs

Register

POST /api/users/register

curl -X POST http://localhost:3000/api/users/register \
    -H "Content-Type: application/json" \
    -d '{
        "userIdentifier": "apple_user_id",
        "email": "user@example.com",
        "fullName": "John Doe",
        "deviceToken": "device_token_here"
    }'

Login

POST /api/users/login

curl -X POST http://localhost:3000/api/users/login \
    -H "Content-Type: application/json" \
    -d '{
        "email": "user@example.com",
        "password": "password"
    }'

Apple Authentication

POST /api/users/apple

curl -X POST http://localhost:3000/api/users/apple \
    -H "Content-Type: application/json" \
    -d '{
        "identityToken": "apple_identity_token",
        "authorizationCode": "apple_auth_code"
    }'

User Profile APIs

Get Profile

GET /api/users/:userId/profile

curl -X GET http://localhost:3000/api/users/user_id_here/profile \
    -H "Authorization: Bearer your-jwt-token"

Update Profile

PUT /api/users/:userId/profile

curl -X PUT http://localhost:3000/api/users/user_id_here/profile \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
        "name": "John Doe",
        "avatarUrl": "https://example.com/avatar.jpg"
    }'

Device Management APIs

Register Device

POST /api/devices/device-info

curl -X POST http://localhost:3000/api/devices/device-info \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
        "deviceToken": "device_token_here",
        "deviceName": "iPhone 12",
        "systemVersion": "15.0",
        "userIdentifier": "user_id_here",
        "timestamp": "2025-01-05T12:00:00Z"
    }'

Update Device Token

PUT /api/devices/token

curl -X PUT http://localhost:3000/api/devices/token \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
        "deviceToken": "new_device_token_here"
    }'

Remove Device

DELETE /api/users/:userId/devices/:deviceToken

curl -X DELETE http://localhost:3000/api/users/user_id_here/devices/device_token_here \
    -H "Authorization: Bearer your-jwt-token"

Topics APIs

Get All Topics

GET /api/topics

curl -X GET http://localhost:3000/api/topics \
    -H "Authorization: Bearer your-jwt-token"

Subscribe to Topic

POST /api/topics/subscribe

curl -X POST http://localhost:3000/api/topics/subscribe \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
        "user_id": "user_id_here",
        "topic_id": "topic_id_here",
        "sound_name": "default"
    }'

Unsubscribe from Topic

DELETE /api/topics/unsubscribe

curl -X DELETE http://localhost:3000/api/topics/unsubscribe \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
        "user_id": "user_id_here",
        "topic_id": "topic_id_here"
    }'

Get User Subscriptions

GET /api/topics/user/:userId

curl -X GET http://localhost:3000/api/topics/user/user_id_here \
    -H "Authorization: Bearer your-jwt-token"

Messages APIs

Send Message

POST /api/messages

curl -X POST http://localhost:3000/api/messages \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
        "content": "Hello, World!",
        "recipient_id": "recipient_id_here"
    }'

Get Message History

GET /api/messages/history/:userId

curl -X GET http://localhost:3000/api/messages/history/user_id_here \
    -H "Authorization: Bearer your-jwt-token"

Delete Message

DELETE /api/messages/:messageId

curl -X DELETE http://localhost:3000/api/messages/message_id_here \
    -H "Authorization: Bearer your-jwt-token"

Preferences APIs

Get User Preferences

GET /api/preferences/:userId

curl -X GET http://localhost:3000/api/preferences/user_id_here \
    -H "Authorization: Bearer your-jwt-token"

Update User Preferences

PUT /api/preferences/:userId

curl -X PUT http://localhost:3000/api/preferences/user_id_here \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
        "notification_sound": "default",
        "language": "en",
        "theme": "light"
    }'

Notifications APIs

Get Notification Settings

GET /api/notifications/settings/:userId

curl -X GET http://localhost:3000/api/notifications/settings/user_id_here \
    -H "Authorization: Bearer your-jwt-token"

Update Notification Settings

PUT /api/notifications/settings/:userId

curl -X PUT http://localhost:3000/api/notifications/settings/user_id_here \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
        "enabled": true,
        "sound_enabled": true,
        "vibration_enabled": true
    }'

Send Test Notification

POST /api/notifications/test

curl -X POST http://localhost:3000/api/notifications/test \
    -H "Authorization: Bearer your-jwt-token" \
    -H "Content-Type: application/json" \
    -d '{
        "device_token": "device_token_here"
    }'