Skip to main content

HTTP API

The frontend talks to the backend over a JSON API under /api. There is no separate API documentation site yet; this page lists the main groups and the conventions.

caution

The API is the one the bundled frontend uses. It is not yet a versioned, stable public API: endpoints and parameters can change between minor releases. Tell us on the forum or in a GitHub issue if you need a stable integration.

Conventions​

  • Requests and responses are JSON. An upload uses multipart/form-data.
  • A response has the shape {"status": "ok", "msg": "", "data": ...}. Errors use "status": "error" and a message in msg; check status, not only the HTTP code.
  • Authentication is a session cookie named casnode_session_id. Call /api/signin, /api/login or the auth flow first and send the cookie with later requests.
  • Reads are open where the forum is public; writes require a signed-in member, and admin endpoints require an administrator. A forum with login_required on refuses reads to anonymous visitors too.

Main endpoints​

Site and accounts​

MethodPathPurpose
GET/api/get-sitePublic site settings, categories and the current user.
POST/api/signupCreate a local account.
POST/api/loginLog in with a user name or email and a password.
POST/api/signinLog in through Casdoor (the old /api/signin flow).
POST/api/signoutEnd the session.
POST/api/forgot-password, /api/reset-password, /api/change-passwordPassword reset and change.
GET/api/auth/startStart a single sign-on flow (provider parameter).
GET/api/auth/callback/:providerThe callback registered at the provider.
GET/api/get-accountThe signed-in account.

Topics and posts​

MethodPathPurpose
GET/api/get-topicsTopic lists (latest, new, unread, hot, top, category, tag).
GET/api/get-topicOne topic with its posts.
GET/api/get-postsPosts of a topic, in pages.
POST/api/add-topic, /api/update-topic, /api/set-topic-status, /api/delete-topic, /api/recover-topicCreate, edit, close/pin/archive, delete and recover.
POST/api/add-post, /api/update-post, /api/delete-post, /api/recover-postReplies and edits.
POST/api/like-post, /api/bookmark-post, /api/flag-postReactions.
POST/api/previewRender Markdown for the composer preview.

People, groups and content​

MethodPathPurpose
GET/api/get-user, /api/get-user-activity, /api/get-directory, /api/search-usersProfiles and the member directory.
GET/api/get-notifications, POST /api/read-notificationNotifications.
GET/api/searchSearch topics and posts.
GET/api/get-categories, /api/get-tagsCategories and tags.
GET/api/get-groups, /api/get-group, /api/get-group-members, /api/get-group-messagesGroups.
GET/api/get-badges, /api/get-user-badgesBadges.
GET/api/get-chat-channels, /api/get-chat-messagesChat.
GET/api/message-bus-pollLong poll for live updates (up to 25 seconds).
POST/api/uploadUpload a file (multipart/form-data).

Administration​

MethodPathPurpose
GET, POST/api/get-site-settings, /api/update-site-settingSite settings.
GET, POST/api/get-admin-users, /api/update-admin-userMembers, admins, suspensions.
GET/api/get-dashboardAdmin dashboard numbers.
GET, POST/api/get-auth-providers, /api/save-auth-provider, /api/delete-auth-providerSingle sign-on providers.
POST/api/send-test-emailThe test button on /admin/email.
GET, POST/api/get-reviewables, /api/perform-reviewableThe review queue.
POST/api/move-postsMove or merge posts.

Other paths​

  • /uploads/<path> serves uploaded files.
  • /sitemap.xml, /sitemap_<n>.xml, /robots.txt are generated by the backend.
  • /latest.rss, /top.rss, /t/<slug>/<id>.rss and category/tag feeds are RSS.

Read Architecture for how requests reach the frontend, and Development for the code layout.