{
    "version": "1.0.0",
    "base_url": "https://api.militant.revlibertaire.com/api/v1",
    "documentation": "https://api.militant.revlibertaire.com/api/README.md",
    "authentication": {
        "type": "Bearer Token",
        "header": "Authorization: Bearer {token}",
        "token_lifetime": "30 days"
    },
    "rate_limits": {
        "auth": "50 requests/hour",
        "posts": "100 requests/hour",
        "comments": "150 requests/hour",
        "comment_reactions": "200 requests/hour",
        "messages": "20000 requests/hour",
        "message_groups": "20000 requests/hour",
        "likes": "200 requests/hour",
        "reactions": "200 requests/hour",
        "group_reactions": "200 requests/hour",
        "follows": "100 requests/hour",
        "friends": "100 requests/hour",
        "notifications": "100 requests/hour",
        "search": "100 requests/hour",
        "stories": "100 requests/hour",
        "groups": "100 requests/hour",
        "pages": "100 requests/hour",
        "bookmarks": "100 requests/hour",
        "shares": "100 requests/hour",
        "events": "100 requests/hour",
        "albums": "100 requests/hour",
        "lives": "200 requests/hour",
        "reports": "100 requests/hour",
        "moderators": "100 requests/hour",
        "sanctions": "50 requests/hour",
        "discover": "200 requests/hour",
        "feature_suggestions": "150 requests/hour",
        "upload": "50 requests/hour",
        "export": "5 requests/hour",
        "calls": "100 requests/hour"
    },
    "endpoints": {
        "auth": {
            "POST /auth.php": "Login and get access token",
            "POST /auth.php?action=register": "Create an account",
            "POST /auth.php?action=forgot_password": "Request a password reset email",
            "POST /auth.php?action=reset_password": "Set a new password with an email reset token",
            "POST /auth.php?action=refresh": "Refresh access token",
            "POST /auth.php?action=revoke": "Revoke access token"
        },
        "two_factor": {
            "GET /two_factor.php": "Get 2FA status and setup secret",
            "POST /two_factor.php?action=enable": "Enable 2FA with verification code",
            "DELETE /two_factor.php": "Disable 2FA"
        },
        "users": {
            "GET /users.php?id={id}": "Get user profile (own profile adds is_militant_technician for LiveKit/app technician UI)",
            "PUT /users.php": "Update own profile",
            "POST /delete_account.php": "Request account and data deletion"
        },
        "user_preferences": {
            "GET /user_preferences.php": "Get user settings (language, push, privacy)",
            "PUT /user_preferences.php": "Update user settings"
        },
        "posts": {
            "GET /posts.php": "Get timeline posts",
            "GET /posts.php?user_id={id}": "Get user posts",
            "POST /posts.php": "Create post",
            "PUT /posts.php?id={id}": "Update post",
            "DELETE /posts.php?id={id}": "Delete post"
        },
        "comments": {
            "GET /comments.php?post_id={id}": "Get post comments",
            "POST /comments.php": "Create comment",
            "PUT /comments.php?id={id}": "Update comment",
            "DELETE /comments.php?id={id}": "Delete comment"
        },
        "comment_reactions": {
            "GET /comment_reactions.php?comment_id={id}&comment_type={type}": "Get comment reactions",
            "POST /comment_reactions.php": "Add reaction to comment (like, love, haha, wow, sad, angry)",
            "DELETE /comment_reactions.php?comment_id={id}&comment_type={type}": "Remove comment reaction"
        },
        "reactions": {
            "GET /reactions.php?post_id={id}": "Get post reactions",
            "POST /reactions.php": "Add reaction (like, love, haha, wow, sad, angry)",
            "DELETE /reactions.php?post_id={id}": "Remove reaction"
        },
        "follows": {
            "GET /follows.php?user_id={id}&type=followers": "Get followers",
            "GET /follows.php?user_id={id}&type=following": "Get following",
            "POST /follows.php": "Follow user",
            "DELETE /follows.php?user_id={id}": "Unfollow user"
        },
        "friends": {
            "GET /friends.php": "Get friends and pending requests",
            "GET /friends.php?type=friends": "Get friends list only",
            "GET /friends.php?type=pending": "Get received pending requests",
            "POST /friends.php": "Friend actions (action=send, action=accept, action=reject)",
            "DELETE /friends.php?user_id={id}": "Remove friend"
        },
        "messages": {
            "GET /messages.php": "Get conversations",
            "GET /messages.php?user_id={id}": "Get messages with user",
            "POST /messages.php": "Send message",
            "DELETE /messages.php?id={id}": "Delete message"
        },
        "message_groups": {
            "GET /message_groups.php": "Get message groups",
            "GET /message_groups.php?path={id}": "Get group details",
            "GET /message_groups.php?path={id}/messages": "Get group messages",
            "POST /message_groups.php": "Create message group",
            "POST /message_groups.php?path={id}/messages": "Send group message",
            "POST /message_groups.php?path={id}/members": "Add member to group",
            "DELETE /message_groups.php?path={id}": "Leave group"
        },
        "notifications": {
            "GET /notifications.php": "Get notifications",
            "PUT /notifications.php?id={id}": "Mark as read",
            "PUT /notifications.php?action=read_all": "Mark all as read",
            "POST /notifications.php?action=test": "Send a test push notification to yourself"
        },
        "search": {
            "GET /search.php?q={query}": "Search all",
            "GET /search.php?q={query}&type=users": "Search users",
            "GET /search.php?q={query}&type=posts": "Search posts"
        },
        "likes": {
            "POST /likes.php": "Like post",
            "DELETE /likes.php?post_id={id}": "Unlike post"
        },
        "discover": {
            "GET /discover.php": "Get suggestions (militants, groups, pages)",
            "GET /discover.php?type=users": "Get user suggestions",
            "GET /discover.php?type=groups": "Get group suggestions",
            "GET /discover.php?type=pages": "Get page suggestions"
        },
        "feature_suggestions": {
            "GET /feature_suggestions.php": "Get feature suggestions list",
            "GET /feature_suggestions.php?filter=popular|recent|planned|done": "Filter suggestions list",
            "GET /feature_suggestions.php?id={id}": "Get suggestion details and comments",
            "GET /feature_suggestions.php?action=stats": "Get suggestion stats by status",
            "POST /feature_suggestions.php": "Create a feature suggestion",
            "POST /feature_suggestions.php?action=vote": "Vote on a suggestion with vote=1 or vote=-1",
            "POST /feature_suggestions.php?action=comment": "Add a comment to a suggestion",
            "POST /feature_suggestions.php?action=update_status": "Moderator/admin updates status and admin response",
            "DELETE /feature_suggestions.php?id={id}": "Moderator/admin deletes a suggestion"
        },
        "stories": {
            "GET /stories.php": "Get active stories",
            "POST /stories.php": "Create story",
            "DELETE /stories.php?id={id}": "Delete story"
        },
        "groups": {
            "GET /groups.php": "Get user groups",
            "GET /groups.php?id={id}": "Get group details",
            "POST /groups.php": "Create group",
            "POST /groups.php?action=join": "Join group",
            "POST /groups.php?action=leave": "Leave group",
            "POST /groups.php?action=invite": "Invite user to group",
            "POST /groups.php?action=approve_request": "Approve join request",
            "POST /groups.php?action=reject_request": "Reject join request"
        },
        "group_posts": {
            "GET /group_posts.php?group_id={id}": "Get group posts",
            "POST /group_posts.php": "Create group post",
            "PUT /group_posts.php?id={id}": "Update group post",
            "DELETE /group_posts.php?id={id}": "Delete group post"
        },
        "group_comments": {
            "GET /group_comments.php?post_id={id}": "Get group post comments",
            "POST /group_comments.php": "Add comment to group post",
            "PUT /group_comments.php?id={id}": "Update group comment",
            "DELETE /group_comments.php?id={id}": "Delete group comment"
        },
        "group_reactions": {
            "POST /group_reactions.php": "Add reaction to group post",
            "DELETE /group_reactions.php?post_id={id}": "Remove group post reaction"
        },
        "pages": {
            "GET /pages.php": "Get pages",
            "GET /pages.php?id={id}": "Get page details",
            "POST /pages.php": "Create page",
            "POST /pages.php?path={id}/like": "Like page"
        },
        "bookmarks": {
            "GET /bookmarks.php": "Get bookmarks",
            "POST /bookmarks.php": "Add bookmark",
            "DELETE /bookmarks.php?post_id={id}": "Remove bookmark"
        },
        "shares": {
            "POST /shares.php": "Share post"
        },
        "events": {
            "GET /events.php": "Get events",
            "GET /events.php?id={id}": "Get event details",
            "POST /events.php": "Create event",
            "POST /events.php?path={id}/join": "Join event",
            "DELETE /events.php?id={id}": "Delete event"
        },
        "albums": {
            "GET /albums.php": "Get albums",
            "GET /albums.php?id={id}": "Get album details",
            "POST /albums.php": "Create album",
            "POST /albums.php?path={id}/photos": "Add photo to album",
            "DELETE /albums.php?id={id}": "Delete album"
        },
        "lives": {
            "GET /lives.php": "Get active lives",
            "GET /lives.php?path={id}": "Get live details",
            "GET /lives.php?path={id}/comments": "Get live comments",
            "GET /lives.php?path={id}/guests": "Get live guests",
            "POST /lives.php": "Start live",
            "POST /lives.php?path=token": "Issue LiveKit token for authenticated user",
            "POST /lives.php?path={id}/comments": "Post comment on live",
            "POST /lives.php?path={id}/join": "Join as viewer",
            "POST /lives.php?path={id}/request-guest": "Request guest access",
            "POST /lives.php?path={id}/report": "Report live",
            "PUT /lives.php?path={id}/background": "Update persisted live background image",
            "PUT /lives.php?path={id}/end": "End live"
        },
        "reports": {
            "GET /reports.php": "Get pending reports for voting",
            "POST /reports.php": "Create report or vote on report"
        },
        "moderators": {
            "GET /moderators.php": "Get moderators and candidates",
            "POST /moderators.php": "Submit candidacy or vote",
            "DELETE /moderators.php": "Withdraw candidacy"
        },
        "sanctions": {
            "GET /sanctions.php": "Get own warnings and bans"
        },
        "upload": {
            "POST /upload.php": "Upload file (image/video, max 100MB)"
        },
        "export": {
            "GET /export.php": "Export all user data (GDPR Article 20)"
        },
        "calls": {
            "Info": "Audio/Video calls via WebRTC (Flutter app only)",
            "Header": "X-Flutter-App: militant-flutter-v1 (required)",
            "POST /calls.php?action=initiate": "Initiate 1-to-1 or group call",
            "POST /calls.php?action=answer": "Answer incoming call",
            "POST /calls.php?action=join": "Join group call",
            "POST /calls.php?action=peer_offer": "Send WebRTC offer to peer (group)",
            "POST /calls.php?action=peer_answer": "Send WebRTC answer to peer (group)",
            "POST /calls.php?action=ice_candidate": "Exchange ICE candidates",
            "POST /calls.php?action=ice_restart": "Restart ICE (network change)",
            "POST /calls.php?action=reject": "Reject incoming call",
            "POST /calls.php?action=leave": "Leave group call",
            "POST /calls.php?action=end": "End active call",
            "GET /calls.php?action=poll": "Poll for call updates",
            "GET /calls.php?action=history": "Get call history"
        },
        "push": {
            "Info": "Mobile push notifications are delivered via OneSignal using External User IDs.",
            "Preferences": "Push settings are managed via /v1/user_preferences.php",
            "Registration": "Clients should set their OneSignal External User ID to their Militant user_id."
        },
        "fediverse": {
            "Info": "ActivityPub integration \u2014 users are discoverable from any Fediverse instance (Mastodon, etc.)",
            "GET /fediverse.php?action=profile": "Get own Fediverse profile (actor_id, handle, followers count, following count)",
            "GET /fediverse.php?action=profile&user_id={id}": "Get another user Fediverse profile",
            "GET /fediverse.php?action=followers": "List own remote Fediverse followers (paginated)",
            "GET /fediverse.php?action=followers&user_id={id}": "List another user Fediverse followers",
            "GET /fediverse.php?action=following": "List own remote Fediverse following (paginated)",
            "GET /fediverse.php?action=following&user_id={id}": "List another user remote Fediverse following",
            "GET /fediverse.php?action=feed": "Get the remote Fediverse feed for followed accounts",
            "GET /fediverse.php?action=feed&refresh=1": "Refresh followed remote actors outboxes, then return the feed",
            "GET /fediverse.php?action=search_remote&q={handle}": "Resolve or search remote Fediverse accounts (@user@instance)",
            "GET /fediverse.php?action=remote_profile&q={handle_or_actor_url}": "Resolve a single remote Fediverse profile and include recent posts",
            "POST /fediverse.php?action=follow_remote": "Follow a remote Fediverse account (actor_url, handle, acct or q in JSON body)",
            "DELETE /fediverse.php?action=unfollow_remote": "Unfollow a remote Fediverse account (actor_url, handle, acct or q)",
            "Note": "GET /users.php also includes fediverse_actor_id, fediverse_followers_count, fediverse_following_count, fediverse_handle, is_remote and account_type"
        },
        "translate": {
            "POST /translate.php": "Translate text using LibreTranslate servers (text, target_lang required in POST)"
        }
    },
    "sdks": {
        "python": "https://api.militant.revlibertaire.com/api/v1/../sdk/python/militant.py",
        "javascript": "https://api.militant.revlibertaire.com/api/v1/../sdk/javascript/militant.js",
        "python_installer": "https://api.militant.revlibertaire.com/api/v1/../sdk/install-python.sh",
        "javascript_installer": "https://api.militant.revlibertaire.com/api/v1/../sdk/install-javascript.sh",
        "python_install_example": "curl -fsSL https://api.militant.revlibertaire.com/api/v1/../sdk/install-python.sh | sh && python3 -m pip install requests",
        "javascript_install_example": "curl -fsSL https://api.militant.revlibertaire.com/api/v1/../sdk/install-javascript.sh | sh && npm install axios"
    },
    "admin": {
        "panel": "https://api.militant.revlibertaire.com/api/v1/../admin/tokens.php",
        "panel_note": "API token management: any logged-in Militant user may use this after admin login.",
        "login": "https://api.militant.revlibertaire.com/api/v1/../admin/login.php",
        "livekit_config": "https://api.militant.revlibertaire.com/api/v1/../admin/livekit.php",
        "livekit_config_note": "Technicians only: same as Militant web (users.is_admin=1, admin.php?tab=technicians); optional is_technician column or LIVEKIT_TECHNICIAN_USER_IDS env."
    }
}