BangumiNet.Api
1.0.11
dotnet add package BangumiNet.Api --version 1.0.11
NuGet\Install-Package BangumiNet.Api -Version 1.0.11
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BangumiNet.Api" Version="1.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BangumiNet.Api" Version="1.0.11" />
<PackageReference Include="BangumiNet.Api" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BangumiNet.Api --version 1.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BangumiNet.Api, 1.0.11"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BangumiNet.Api@1.0.11
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BangumiNet.Api&version=1.0.11
#tool nuget:?package=BangumiNet.Api&version=1.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
BangumiNet.Api
一个由 Kiota 根据 Bangumi 提供的 OpenAPI 定义生成的 API 客户端,来自 BangumiNet。
- Legacy API //api.bgm.tv/
- Open API //api.bgm.tv/v0/
- Private API //next.bgm.tv/p1/
- socket.io 订阅通知
- 时间线事件流 (SSE)
使用
构建 Client
// Access Token 或 chiiNextSessionID Cookie
var authProvider = new BangumiAuthenticationProvider(Token);
// 如无需登录,使用 AnonymousAuthenticationProvider
// var authProvider = new AnonymousAuthenticationProvider();
// 尽可能复用已有的 HttpClient,User-Agent 符合 bangumi 要求
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", UserAgent);
var requestAdapter = new HttpClientRequestAdapter(authProvider, httpClient: httpClient);
var client = new BangumiNet.Api.P1.ApiClient(requestAdapter);
// 不要使用同一个 RequestAdapter
// AuthenticationProvider 和 HttpClient 可以复用
var requestAdapterV0 = new HttpClientRequestAdapter(authProvider, httpClient: httpClient);
var client = new BangumiNet.Api.V0.ApiClient(requestAdapterV0);
Token 可以来自:
- 网页(持久):https://next.bgm.tv/demo/access-token
- Private API(临时):https://next.bgm.tv/p1/login
- OAuth 2.0
关于 User-Agent 的要求,见此处。
发起请求
API 文档见顶部链接。
var response = await client.P1.Calendar.GetAsync();
int id = 9912;
var response = await client.P1.Subject[id].GetAsync();
var type = (SubjectType?)response.Type;
int id = 77560;
var response = await client.V0.Users.Minus.Collections.Minus.Episodes[id].PutAsync(new()
{
Type = (int)EpisodeCollectionType.Done
});
时间线事件流 (SSE)
CancellationTokenSource cts = new();
var events = new BangumiNet.Api.Misc.TimelineEventStream(httpClient, token);
List<Timeline> items = [];
await foreach (var item in events.StartAsync(FilterMode.All, null, cts.Token))
{
items.Add(item);
}
// 请一定要在某处调用,否则连接将永远不会断开
cts.Cancel();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- BangumiNet.Common (>= 1.0.11)
- Microsoft.Kiota.Bundle (>= 1.22.0)
- SocketIOClient (>= 4.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.11 | 76 | 3/5/2026 |
| 1.0.9 | 98 | 2/2/2026 |
| 1.0.8 | 101 | 1/28/2026 |
| 1.0.6 | 104 | 1/22/2026 |
| 1.0.3 | 103 | 1/8/2026 |
| 1.0.2 | 104 | 1/8/2026 |
| 1.0.0 | 105 | 1/1/2026 |
| 0.16.1 | 280 | 12/19/2025 |
| 0.16.0 | 256 | 12/15/2025 |
| 0.14.0 | 440 | 12/8/2025 |
| 0.13.4 | 693 | 12/2/2025 |
| 0.13.3 | 694 | 12/1/2025 |
| 0.13.2 | 143 | 11/29/2025 |
| 0.13.1 | 133 | 11/29/2025 |
| 0.13.0 | 199 | 11/24/2025 |
| 0.12.3 | 358 | 11/17/2025 |
| 0.12.0 | 253 | 11/10/2025 |
| 0.11.5 | 214 | 11/4/2025 |
| 0.11.4 | 205 | 11/4/2025 |
| 0.11.3 | 202 | 11/4/2025 |
Loading failed