Files
libilibili/src/lib.rs
T
felis b3e3a3c87c refactor: reorganize API and WebSocket modules
Split client, endpoint, and WebSocket implementations into domain-focused modules while preserving the public API.\n\nImprove crate and API documentation to describe responsibilities, authentication boundaries, and response compatibility.
2026-07-19 22:31:47 -07:00

40 lines
1.5 KiB
Rust

//! Bilibili Web 与直播接口的异步 Rust 客户端。
//!
//! # 设计范围
//!
//! 本 crate 提供可复用的 HTTP 请求基础设施、WBI 查询签名、会话凭据处理,以及直播
//! WebSocket 数据包与业务命令解析。常用 Web API 按直播、视频、用户、评论和搜索等
//! 领域组织;各领域方法返回 [`serde_json::Value`],以兼容服务端持续变化的响应字段。
//! 调用方也可以使用 [`Client`] 的通用请求方法访问尚未封装的端点。
//!
//! # 认证与状态变更
//!
//! 本 crate 不实现密码、二维码、验证码或 OAuth 登录流程。请通过 Bilibili 的正常登录
//! 流程取得会话,再将 `SESSDATA` 和 `bili_jct` 提供给 [`Credentials`]。需要会话的
//! 状态变更请求会自动补充 `csrf` 与 `csrf_token`;没有可用 CSRF token 时会返回错误。
//!
//! ```no_run
//! use libilibili::Client;
//!
//! # async fn example() -> Result<(), libilibili::Error> {
//! let client = Client::anonymous()?;
//! let room = client.live().room_init(5050).await?;
//! println!("{room:#}");
//! # Ok(()) }
//! ```
mod auth;
mod client;
mod endpoints;
mod error;
mod wbi;
#[cfg(feature = "websocket")]
pub mod websocket;
pub use auth::{Credentials, CredentialsBuilder};
pub use client::{Client, ClientBuilder, Response};
pub use endpoints::{CommentApi, LiveApi, SearchApi, UserApi, VideoApi};
pub use error::{ApiError, Error, Result};
pub use wbi::{WbiKey, WBI_MIXIN_TABLE};