跳转到正文

API 参考

本页按运行时 OpenAPI 结果整理,覆盖当前应用暴露的主要运行路由;页面保留静态索引格式,便于快速定位接口与实现文件。

路由挂载

  • announcements.router -> /api
  • cart_sync.router -> /api
  • chem.router -> /api
  • chemical_info.router -> /api
  • chemical_name_map.router -> /api
  • common_shelf.router -> /api
  • consumable_orders.router -> /api
  • dashboard.router -> /api
  • error_logs.router -> /api
  • events.router -> /api
  • inventory.router -> /api
  • inventory_timeline 通过 register_inventory_timeline_routes 挂到 inventory.router,最终前缀为 /api/inventory
  • procedure_inventory_search.router -> /api
  • reagent_brands.router -> /api
  • reagent_orders.router -> /api
  • user_logs.router -> /api
  • user_sessions.router -> /api/users/me
  • users.router -> /api
  • search_completions.router -> /api
  • inventory_extended_routes 通过 register_* 动态挂到 inventory.router,最终前缀为 /api/inventory
  • reagent_orders_workflow 通过 register_* 动态挂到 reagent_orders.router,最终前缀为 /api/reagent-orders

权限判定

  • 管理员:路由依赖 require_admin 或参数类型为 AdminUser
  • 已登录用户:路由依赖 get_current_user / get_current_session 或参数类型为 CurrentUser
  • 公开:无上述依赖。
  • POST /api/users/logout 为公开接口,但实现会校验当前会话 Cookie/Token 后执行退出。

路由清单

应用级路由 (main)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/root公开200app/main.py
GET/cart-importcart_import_redirect公开200app/main.py
GET/healthhealth_check公开200app/main.py
GET/robots.txtrobots_txt公开PlainTextResponse200app/main.py
GET/api/runtime/cache-versionget_runtime_cache_version公开dict[str, str]200app/main.py

用户与认证 (users)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/users/list_users管理员query: username;query: full_namedict200app/api/users.py
POST/api/users/create_user管理员body: UserCreateUserResponsestatus.HTTP_201_CREATEDapp/api/users.py
POST/api/users/change-passwordchange_password已登录用户body: ChangePasswordRequest200app/api/users.py
POST/api/users/loginlogin公开body: LoginRequest200app/api/users.py
POST/api/users/login/tokenlogin_cli_token公开body: LoginRequestCLILoginResponse200app/api/users.py
POST/api/users/logoutlogout公开200app/api/users.py
GET/api/users/meget_me已登录用户UserResponse200app/api/users.py
GET/api/users/searchsearch_users已登录用户query: qlist[UserSearchItem]200app/api/users.py
DELETE/api/users/{user_id}delete_user管理员path: user_idstatus.HTTP_204_NO_CONTENTapp/api/users.py
GET/api/users/{user_id}get_user已登录用户path: user_idPublicUserResponse200app/api/users.py
PUT/api/users/{user_id}update_user已登录用户path: user_id;body: UserUpdateUserResponse200app/api/users.py
POST/api/users/{user_id}/activateactivate_user管理员path: user_idUserResponse200app/api/users.py
DELETE/api/users/{user_id}/avatardelete_avatar已登录用户path: user_iddict200app/api/users.py
POST/api/users/{user_id}/avatarupload_avatar已登录用户path: user_iddict200app/api/users.py
POST/api/users/{user_id}/reset-passwordreset_user_password管理员path: user_id;body: ResetPasswordRequest200app/api/users.py
PUT/api/users/{user_id}/roleupdate_user_role管理员path: user_idUserResponse200app/api/users.py

会话与设备 (user_sessions)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
DELETE/api/users/me/sessions/delete_all_sessions已登录用户200app/api/user_sessions.py
GET/api/users/me/sessions/list_sessions已登录用户List[SessionResponse]200app/api/user_sessions.py
POST/api/users/me/sessions/refreshrefresh_session已登录用户200app/api/user_sessions.py
DELETE/api/users/me/sessions/{session_id}delete_session已登录用户path: session_id200app/api/user_sessions.py
PATCH/api/users/me/sessions/{session_id}update_session已登录用户path: session_id;body: SessionUpdateRequestSessionResponse200app/api/user_sessions.py

管理员用户日志 (user_logs)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
POST/api/admin/users/logs/queryget_user_logs本人或管理员body: LogsQueryRequestLogsQueryResponse200app/api/user_logs.py
POST/api/admin/users/{user_id}/logs-tokengenerate_logs_token本人或管理员path: user_id200app/api/user_logs.py

仪表盘聚合接口 (dashboard)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/dashboard/personal/summaryget_personal_dashboard_summary非公用账号DashboardPersonalSummaryEnvelope200app/api/dashboard.py
GET/api/dashboard/board/summaryget_dashboard_board_summary已登录用户DashboardBoardSummaryEnvelope200app/api/dashboard.py
GET/api/dashboard/board/sections/{section}get_dashboard_board_section_items已登录用户path: section;query: skip;query: limitDashboardSectionItemsEnvelope200app/api/dashboard.py
GET/api/dashboard/board/summary/window-statsget_dashboard_board_window_stats已登录用户query: window_days;query: all_timeDashboardWindowStatsEnvelope200app/api/dashboard.py
GET/api/dashboard/admin/summaryget_admin_dashboard_summary管理员DashboardAdminSummaryEnvelope200app/api/dashboard.py
GET/api/dashboard/admin/sections/{section}get_admin_dashboard_section_items管理员path: section;query: skip;query: limitDashboardSectionItemsEnvelope200app/api/dashboard.py
GET/api/dashboard/admin/summary/window-statsget_admin_dashboard_window_stats管理员query: window_days;query: all_timeDashboardWindowStatsEnvelope200app/api/dashboard.py

库存基础接口 (inventory)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/inventory/list_inventory已登录用户query: search200app/api/inventory.py
GET/api/inventory/code/{internal_code}/timelineget_inventory_timeline已登录用户path: internal_code;query: searchskiplimitInventoryTimelineResponse200404app/api/inventory_timeline.py
DELETE/api/inventory/{inventory_id}delete_inventory非公用账号path: inventory_idstatus.HTTP_204_NO_CONTENTapp/api/inventory.py
GET/api/inventory/{inventory_id}get_inventory已登录用户path: inventory_idInventoryResponse200app/api/inventory.py
PUT/api/inventory/{inventory_id}update_inventory已登录用户path: inventory_id;body: InventoryUpdateInventoryResponse200app/api/inventory.py

库存扩展接口 (inventory_extended_routes)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/inventory/cas/{cas_number}check_cas_inventory已登录用户path: cas_number200app/api/inventory_extended_routes.py
GET/api/inventory/cas/{cas_number}/totalget_cas_total_quantity已登录用户path: cas_number200app/api/inventory_extended_routes.py
GET/api/inventory/code/{internal_code}get_inventory_by_internal_code已登录用户path: internal_codeInventoryResponse200app/api/inventory_extended_routes.py
GET/api/inventory/dashboard/my-borrowsget_my_borrows已登录用户200app/api/inventory_extended_routes.py
GET/api/inventory/dashboard/admin/borrowsget_admin_borrows管理员200app/api/inventory_extended_routes.py
GET/api/inventory/dashboard/pending-stockinget_pending_stockin已登录用户200app/api/inventory_extended_routes.py
GET/api/inventory/dashboard/admin/pending-stockinget_admin_pending_stockin管理员200app/api/inventory_extended_routes.py
GET/api/inventory/exportexport_inventory已登录用户200app/api/inventory_extended_routes.py
POST/api/inventory/import/previewpreview_inventory_import非公用账号file: file200app/api/inventory_extended_routes.py
POST/api/inventory/import/confirmconfirm_inventory_import非公用账号body: preview_token200app/api/inventory_extended_routes.py
GET/api/inventory/import/templateget_import_template非公用账号200app/api/inventory_extended_routes.py
POST/api/inventory/manual-addmanual_add_inventory非公用账号body: ManualInventoryCreatedict200app/api/inventory_extended_routes.py
POST/api/inventory/{inventory_id}/borrowborrow_item已登录用户path: inventory_idInventoryResponse200app/api/inventory_extended_routes.py
GET/api/inventory/{inventory_id}/borrow-historyget_borrow_history已登录用户path: inventory_id200app/api/inventory_extended_routes.py
POST/api/inventory/{inventory_id}/complete-stockincomplete_manual_pending_stockin已登录用户path: inventory_id;body: ManualPendingStockInRequestInventoryResponse200app/api/inventory_extended_routes.py
POST/api/inventory/{inventory_id}/returnreturn_item已登录用户path: inventory_id;body: InventoryBorrowReturndict200app/api/inventory_extended_routes.py
POST/api/inventory/{inventory_id}/return-deletedelete_zero_remaining_borrowed_item已登录用户path: inventory_id;body: InventoryBorrowReturn204app/api/inventory_extended_routes.py

常用货架接口 (common_shelf)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/common-shelf/groupslist_common_shelf_groups已登录用户query: searchsearch_fieldfuzzysort_bysort_orderCommonShelfGroupListResponse200app/api/common_shelf.py
POST/api/common-shelf/manual-addmanual_add_common_shelf已登录用户body: CommonShelfManualCreatedict200app/api/common_shelf.py
GET/api/common-shelf/groups/{group_key}/locationsget_common_shelf_group_locations已登录用户path: group_keylist[CommonShelfLocationSummaryResponse]200app/api/common_shelf.py
GET/api/common-shelf/groups/{group_key}/location-suggestionsget_common_shelf_group_location_suggestions已登录用户path: group_keylist[str]200app/api/common_shelf.py
GET/api/common-shelf/location-suggestionsget_common_shelf_location_suggestions_by_fields已登录用户query: cas_numberbrandspecificationlist[str]200app/api/common_shelf.py
GET/api/common-shelf/groups/{group_key}/itemsget_common_shelf_group_items已登录用户path: group_keylist[CommonShelfGroupItemResponse]200app/api/common_shelf.py
PUT/api/common-shelf/groups/{group_key}update_common_shelf_group已登录用户path: group_key;body: CommonShelfGroupEditRequestdict200app/api/common_shelf.py
PUT/api/common-shelf/groups/{group_key}/items/{item_id}update_common_shelf_item已登录用户path: group_keyitem_id;body: CommonShelfGroupItemUpdateRequestdict200app/api/common_shelf.py
POST/api/common-shelf/groups/{group_key}/add-bottlesadd_common_shelf_bottles已登录用户path: group_key;body: CommonShelfAddBottlesRequestdict200app/api/common_shelf.py
POST/api/common-shelf/groups/{group_key}/remove-oneremove_one_common_shelf已登录用户path: group_key;body: CommonShelfRemoveOneRequestdict200app/api/common_shelf.py
DELETE/api/common-shelf/groups/{group_key}/items/{item_id}delete_common_shelf_item已登录用户path: group_keyitem_iddict200app/api/common_shelf.py
DELETE/api/common-shelf/groups/{group_key}delete_common_shelf_group管理员path: group_keydict200app/api/common_shelf.py
GET/api/common-shelf/exportexport_common_shelf已登录用户200app/api/common_shelf.py

CAS 主数据接口 (chemical_name_map)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/chemical-name-maplist_chemical_name_map已登录用户query: searchsearch_fieldfuzzyskiplimitdict200app/api/chemical_name_map.py
POST/api/chemical-name-mapcreate_chemical_name_map已登录用户body: ChemicalNameMapCreateChemicalNameMapResponse200app/api/chemical_name_map.py
PUT/api/chemical-name-map/{item_id}update_chemical_name_map已登录用户path: item_id;body: ChemicalNameMapUpdateChemicalNameMapResponse200app/api/chemical_name_map.py
DELETE/api/chemical-name-map/{item_id}delete_chemical_name_map已登录用户path: item_iddict200app/api/chemical_name_map.py

试剂品牌接口 (reagent_brands)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/reagent-brandslist_reagent_brands已登录用户query: searchsort_bysort_orderskiplimitinclude_inactiveReagentBrandListResponse200app/api/reagent_brands.py
POST/api/reagent-brandscreate_reagent_brand非公用账号body: ReagentBrandCreateReagentBrandResponse200app/api/reagent_brands.py
PUT/api/reagent-brands/{brand_id}update_reagent_brand非公用账号path: brand_id;body: ReagentBrandUpdateReagentBrandResponse200app/api/reagent_brands.py
DELETE/api/reagent-brands/{brand_id}delete_reagent_brand非公用账号path: brand_iddict200app/api/reagent_brands.py

试剂订单基础接口 (reagent_orders)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/reagent-orders/list_reagent_orders已登录用户query: search200app/api/reagent_orders.py
POST/api/reagent-orders/create_reagent_order已登录用户body: ReagentOrderCreateReagentOrderResponsestatus.HTTP_201_CREATEDapp/api/reagent_orders.py
GET/api/reagent-orders/cas-overview/{cas_number}get_cas_overview已登录用户path: cas_number200app/api/reagent_orders.py
GET/api/reagent-orders/exportexport_reagent_orders管理员200app/api/reagent_orders.py
GET/api/reagent-orders/{order_id}get_reagent_order已登录用户path: order_idReagentOrderResponse200app/api/reagent_orders.py
PUT/api/reagent-orders/{order_id}update_reagent_order已登录用户path: order_id;body: ReagentOrderUpdateReagentOrderResponse200app/api/reagent_orders.py

试剂订单工作流接口 (reagent_orders_workflow)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/reagent-orders/dashboard/arrived-ordersget_arrived_reagent_orders已登录用户200app/api/reagent_orders_workflow.py
GET/api/reagent-orders/dashboard/my-reagent-ordersget_my_reagent_orders已登录用户200app/api/reagent_orders_workflow.py
GET/api/reagent-orders/dashboard/admin/reagent-ordersget_admin_reagent_orders管理员200app/api/reagent_orders_workflow.py
DELETE/api/reagent-orders/{order_id}delete_reagent_order已登录用户path: order_idstatus.HTTP_204_NO_CONTENTapp/api/reagent_orders_workflow.py
POST/api/reagent-orders/{order_id}/approveapprove_reagent_order管理员path: order_id200app/api/reagent_orders_workflow.py
POST/api/reagent-orders/{order_id}/confirm-arrivalconfirm_reagent_arrival已登录用户path: order_id200app/api/reagent_orders_workflow.py
POST/api/reagent-orders/{order_id}/rejectreject_reagent_order管理员path: order_id200app/api/reagent_orders_workflow.py
POST/api/reagent-orders/{order_id}/stock-instock_in_reagent_order已登录用户path: order_id;body: StockInRequestdict200app/api/reagent_orders_workflow.py

耗材订单接口 (consumable_orders)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/consumable-orders/list_consumable_orders已登录用户query: search200app/api/consumable_orders.py
POST/api/consumable-orders/create_consumable_order已登录用户body: ConsumableOrderCreateConsumableOrderResponsestatus.HTTP_201_CREATEDapp/api/consumable_orders.py
GET/api/consumable-orders/dashboard/my-consumable-ordersget_my_consumable_orders已登录用户200app/api/consumable_orders.py
GET/api/consumable-orders/dashboard/admin/consumable-ordersget_admin_consumable_orders管理员200app/api/consumable_orders.py
GET/api/consumable-orders/exportexport_consumable_orders管理员200app/api/consumable_orders.py
DELETE/api/consumable-orders/{order_id}delete_consumable_order已登录用户path: order_idstatus.HTTP_204_NO_CONTENTapp/api/consumable_orders.py
GET/api/consumable-orders/{order_id}get_consumable_order已登录用户path: order_idConsumableOrderResponse200app/api/consumable_orders.py
PUT/api/consumable-orders/{order_id}update_consumable_order已登录用户path: order_id;body: ConsumableOrderUpdateConsumableOrderResponse200app/api/consumable_orders.py
POST/api/consumable-orders/{order_id}/approveapprove_consumable_order管理员path: order_id200app/api/consumable_orders.py
POST/api/consumable-orders/{order_id}/completecomplete_consumable_order已登录用户path: order_id200app/api/consumable_orders.py
POST/api/consumable-orders/{order_id}/rejectreject_consumable_order管理员path: order_id200app/api/consumable_orders.py

公告接口 (announcements)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/announcements/list_announcements管理员List[AnnouncementResponse]200app/api/announcements.py
POST/api/announcements/create_announcement管理员body: AnnouncementCreateAnnouncementResponsestatus.HTTP_201_CREATEDapp/api/announcements.py
DELETE/api/announcements/images/{filename}delete_announcement_image管理员path: filenamestatus.HTTP_204_NO_CONTENTapp/api/announcements.py
GET/api/announcements/publicget_public_announcements已登录用户List[AnnouncementResponse]200app/api/announcements.py
GET/api/announcements/storage-infoget_storage_info管理员200app/api/announcements.py
POST/api/announcements/upload-imageupload_announcement_image管理员200app/api/announcements.py
DELETE/api/announcements/{announcement_id}delete_announcement管理员path: announcement_idstatus.HTTP_204_NO_CONTENTapp/api/announcements.py
GET/api/announcements/{announcement_id}get_announcement管理员path: announcement_idAnnouncementResponse200app/api/announcements.py
PUT/api/announcements/{announcement_id}update_announcement管理员path: announcement_id;body: AnnouncementUpdateAnnouncementResponse200app/api/announcements.py
POST/api/announcements/{announcement_id}/toggle-pintoggle_pin_announcement管理员path: announcement_idAnnouncementResponse200app/api/announcements.py
POST/api/announcements/{announcement_id}/toggle-visibilitytoggle_visibility_announcement管理员path: announcement_idAnnouncementResponse200app/api/announcements.py

SSE 事件接口 (events)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/eventssse_events已登录用户200app/api/events.py

错误日志接口 (error_logs)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/error-logsget_error_logs已登录用户query: hours;query: lines200app/api/error_logs.py

购物车同步接口 (cart_sync)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
POST/api/cart-syncsync_cart已登录用户body: CartItemRequestCartSyncResponse200app/api/cart_sync.py

化学信息接口 (chemical_info)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/chemical-info/{cas_number}get_chemical_info已登录用户path: cas_number200app/services/chemical_info.py
方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
POST/api/procedure-inventory-search/extractextract_inventory_from_procedure非公用账号body: ProcedureInventorySearchRequestProcedureInventoryExtractionResult200app/api/procedure_inventory_search.py
POST/api/procedure-inventory-search/resolveresolve_inventory_from_procedure非公用账号body: ProcedureInventoryResolveRequestProcedureInventorySearchResult200app/api/procedure_inventory_search.py
POST/api/procedure-inventory-searchsearch_inventory_from_procedure非公用账号body: ProcedureInventorySearchRequestProcedureInventorySearchResult200app/api/procedure_inventory_search.py

搜索补全 (search_completions)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/search-completions/inlineget_inline_completion_endpoint已登录用户query: endpointqfieldInlineCompletionResponse200app/api/search_completions.py
POST/api/search-completions/feedbacksubmit_feedback已登录用户body: CompletionFeedbackRequestdict200app/api/search_completions.py
GET/api/search-completions/preferencesget_preferences已登录用户SearchPreferencesResponse200app/api/search_completions.py
PUT/api/search-completions/preferencesupdate_preferences已登录用户body: SearchPreferencesUpdateSearchPreferencesResponse200app/api/search_completions.py

化学结构接口 (chem)

方法路径函数权限关键参数(path/query/body/file)返回模型状态码代码
GET/api/chem/index/statusget_structure_index_status已登录用户StructureIndexStatusResponse200app/api/chem.py
POST/api/chem/index/rebuildrebuild_structure_index管理员StructureIndexStatusResponse200app/api/chem.py
GET/api/chem/structures/cachelist_structure_cache已登录用户query: status_filtersearchskiplimitStructureCacheListResponse200app/api/chem.py
GET/api/chem/structures/cache/{cas_number}get_structure_cache_status已登录用户path: cas_numberCompoundStructureCacheResponse or None200app/api/chem.py
POST/api/chem/structures/cache/{cas_number}/pubchem-candidatespreview_structure_pubchem_candidates管理员path: cas_numberPubChemCandidatePreviewResponse200app/api/chem.py
POST/api/chem/structures/resolve-casresolve_structure_cas管理员body: ResolveCasRequestCompoundStructureCacheResponse200app/api/chem.py
PUT/api/chem/structures/cache/{cas_number}/manualsave_manual_structure管理员path: cas_number;body: ManualStructureRequestCompoundStructureCacheResponse200app/api/chem.py
POST/api/chem/structures/cache/{cas_number}/confirm-pubchemconfirm_pubchem_candidate管理员path: cas_number;body: ConfirmPubChemCidRequestCompoundStructureCacheResponse200app/api/chem.py
POST/api/chem/search/substructuresearch_substructure已登录用户body: SubstructureSearchRequestSubstructureSearchResponse200app/api/chem.py

二次开发规则

  • 新增 API 时,优先沿用现有依赖模式(CurrentUser / AdminUser),避免权限漂移。
  • 新增 /api/inventory/*/api/reagent-orders/* 路径时,先确认命名路由优先级,避免被 /{id} 路由吞掉。
  • 新增列表筛选条件时,需要同步评估索引、缓存 Key、FTS 字段和前端查询参数。

参考代码

开源项目 · Apache-2.0 license