import type { RuntimeTranslator } from '@/i18n/runtime'; import { type PolicySection } from './types'; import { CodeBlock } from '@/components/ui/code-block'; import { DocsTable, DocsTableBody, DocsTableCell, DocsTableHead, DocsTableHeader, DocsTableRow, } from '@/components/ui/docs-table'; export const DOCS_LAST_UPDATED = '2026-06-07'; /** * ------------------------------------------------------------------ * API 文档 * ------------------------------------------------------------------ */ export function createApiSections(rt: RuntimeTranslator): PolicySection[] { return [ { value: 'api-specs', title: rt('1_api_conventions_and_authentication_e6d4df61'), content: (

{rt( 'standard_api_request_conventions_and_developer_access_39eb956e', )}

{rt('1_1_standard_response_format_5cddae2f')}

{rt('all_api_endpoints_use_a_standard_json_87c92fb0')}

{rt('field_49ecd0e3')} {rt('type_ba40014f')} {rt('description_4262c45d')} error_msg string {rt('error_message_empty_on_success_contains_error_d89d457f')} data any {rt('the_response_payload_null_when_the_request_97b8b29c')}

{rt('successful_response_example_8917e853')}

{rt('failed_response_example_eae899e1')}

{rt('1_2_authentication_methods_3c5db38a')}

{rt( 'protected_endpoints_require_credentials_except_public_endpoints_1fa0a24c', )}

  • {rt('session_credentials_de72024d')}{' '} {rt('browser_clients_can_stay_signed_in_using_f316279b')}
  • {rt('access_tokens_8de23550')}{' '} {rt('for_backend_calls_and_third_party_integrations_dfd8bf0f')}

{rt('use_either_of_the_following_request_headers_1e03b04b')}

  • Authorization: Bearer at_xxx
  • X-Access-Token: at_xxx
), children: [ { value: '1-1-response-format', title: rt('1_1_standard_response_format_5cddae2f'), }, { value: '1-2-authentication', title: rt('1_2_authentication_methods_3c5db38a'), }, ], }, { value: 'auth-apis', title: rt('2_user_and_authentication_endpoints_4a89d429'), content: (

{rt('2_1_user_registration_4f332f85')}

{rt('endpoint_79a2369a')} POST{' '} /api/v1/user/register

{rt('description_3e633a20')}{' '} {rt('register_a_local_account_when_registration_is_938891dc')}

{rt('parameter_9634fb08')} {rt('required_11da9dc4')} {rt('type_ba40014f')} {rt('description_4262c45d')} username {rt('yes_b5141d3d')} string {rt('username_must_be_unique_and_contain_no_e81c1e5c')} password {rt('yes_b5141d3d')} string {rt('password_at_least_8_characters_37cdc807')} nickname {rt('no_0c70665b')} string {rt( 'nickname_defaults_to_the_username_when_omitted_676aae7e', )}

{rt('2_2_password_login_271483ba')}

{rt('endpoint_79a2369a')} POST{' '} /api/v1/user/login

{rt('description_3e633a20')}{' '} {rt( 'authenticate_with_a_username_and_password_establishing_a38ff252', )}

{rt('parameter_9634fb08')} {rt('required_11da9dc4')} {rt('type_ba40014f')} {rt('description_4262c45d')} username {rt('yes_b5141d3d')} string {rt('username_1a3f0617')} password {rt('yes_b5141d3d')} string {rt('password_a621ab60')}

{rt('2_3_sign_out_3252611d')}

{rt('endpoint_79a2369a')} GET{' '} /api/v1/user/logout

{rt('description_3e633a20')}{' '} {rt('delete_the_current_session_cookie_and_sign_c213ffd9')}

{rt('2_4_get_profile_7b96110a')}

{rt('endpoint_79a2369a')} GET{' '} /api/v1/user/self

{rt('description_3e633a20')}{' '} {rt('get_the_signed_in_account_s_basic_b0eb8cfa')}

), children: [ { value: '2-1-register', title: rt('2_1_user_registration_4f332f85') }, { value: '2-2-login', title: rt('2_2_password_login_271483ba') }, { value: '2-3-logout', title: rt('2_3_sign_out_3252611d') }, { value: '2-4-profile', title: rt('2_4_get_profile_7b96110a') }, ], }, { value: 'token-apis', title: rt('3_personal_access_token_endpoints_989f5d7c'), content: (

{rt('access_token_management_requires_a_session_login_42d91543')}

{rt('3_1_list_tokens_9840c227')}

{rt('endpoint_79a2369a')} GET{' '} /api/v1/user/access-tokens

{rt('description_3e633a20')}{' '} {rt('list_the_current_user_s_tokens_with_c34d2210')}

{rt('3_2_create_an_access_token_e53bd784')}

{rt('endpoint_79a2369a')} POST{' '} /api/v1/user/access-tokens

{rt('parameters_ba89685c')} {rt('ui_jsonBody')}{' '} {rt.raw('name_token_name_is_admin_false_4f3e4868')}

{rt('description_3e633a20')}{' '} {rt('generate_an_access_token_the_response_includes_70552390')}

is_admin {rt('optional_default_210b9d8f')}{' '} false {rt('grant_administrator_privileges_to_the_token_only_2292cad8')}{' '} /admin/**{' '} {rt('endpoints_815c88e5')}

{rt('successful_response_example_7783a39c')}

{rt('3_3_revoke_delete_a_token_ae510f58')}

{rt('endpoint_79a2369a')} DELETE{' '} /api/v1/user/access-tokens/:id

{rt('description_3e633a20')}{' '} {rt('permanently_delete_a_token_by_id_immediately_145287f6')}

{rt('3_4_rotate_a_token_secret_79209983')}

{rt('endpoint_79a2369a')} POST{' '} /api/v1/user/access-tokens/:id/rotate

{rt('description_3e633a20')}{' '} {rt('replace_a_token_s_secret_and_return_d2caca89')}

), children: [ { value: '3-1-list-token', title: rt('3_1_list_tokens_9840c227') }, { value: '3-2-create-token', title: rt('3_2_create_an_access_token_e53bd784'), }, { value: '3-3-delete-token', title: rt('3_3_revoke_delete_a_token_ae510f58'), }, { value: '3-4-rotate-token', title: rt('3_4_rotate_a_token_secret_79209983'), }, ], }, { value: 'config-apis', title: rt('4_public_configuration_and_administration_17ebdbd5'), content: (

{rt('4_1_public_system_configuration_2be912e4')}

{rt('endpoint_79a2369a')} GET{' '} /api/v1/config/public

{rt('description_3e633a20')}{' '} {rt('get_publicly_visible_configuration_keys_and_values_bc7bff66')}

{rt('response_example_d3087445')}

{rt('4_2_system_configuration_crud_administrator_2ce66c8b')}

{rt('description_3e633a20')}{' '} {rt( 'manage_system_configs_dynamically_through_an_administrator_acdcdb99', )}

), children: [ { value: '4-1-public-config', title: rt('4_1_public_system_configuration_2be912e4'), }, { value: '4-2-admin-configs', title: rt('4_2_system_configuration_crud_administrator_2ce66c8b'), }, ], }, ]; }