Natsukage.PixivCS
0.1.3
dotnet add package Natsukage.PixivCS --version 0.1.3
NuGet\Install-Package Natsukage.PixivCS -Version 0.1.3
<PackageReference Include="Natsukage.PixivCS" Version="0.1.3" />
<PackageVersion Include="Natsukage.PixivCS" Version="0.1.3" />
<PackageReference Include="Natsukage.PixivCS" />
paket add Natsukage.PixivCS --version 0.1.3
#r "nuget: Natsukage.PixivCS, 0.1.3"
#:package Natsukage.PixivCS@0.1.3
#addin nuget:?package=Natsukage.PixivCS&version=0.1.3
#tool nuget:?package=Natsukage.PixivCS&version=0.1.3
PixivCS
PixivCS 是一个现代化的 C# 版本 Pixiv API 库,基于 .NET 8.0 平台开发。
致谢: 本项目是 pixivpy 的 C# 实现,接口设计与数据结构均基于原项目。感谢 upbit 及其贡献者们为开源社区提供的卓越工作。
安装
通过 NuGet 安装:
dotnet add package Natsukage.PixivCS
快速开始
using PixivCS.Api;
using PixivCS.Network;
// 创建 API 实例
var api = new PixivAppApi();
// 认证
var authResult = await api.AuthAsync("your_refresh_token");
// 获取插画详情
var illustDetail = await api.GetIllustDetailAsync("133368512");
Console.WriteLine($"标题: {illustDetail.Illust?.Title}");
// 搜索插画
var searchResult = await api.SearchIllustAsync("初音ミク");
foreach (var illust in searchResult.Illusts ?? [])
{
Console.WriteLine($"ID: {illust.Id}, 标题: {illust.Title}");
}
获取 Refresh Token
由于密码登录已不再支持,请使用 refresh_token
进行认证。获取 refresh_token
的方法:
- @ZipFile Pixiv OAuth Flow
- gppt: get-pixivpy-token (推荐,基于 Selenium,易于使用)
- OAuth with Selenium/ChromeDriver
连接方式
支持三种连接方式:
普通连接
var config = new ConnectionConfig { Mode = ConnectionMode.Normal };
var api = new PixivAppApi(config);
免代理直连
var config = new ConnectionConfig { Mode = ConnectionMode.DirectBypass };
var api = new PixivAppApi(config);
注意: 在大陆网络环境下,直连 Pixiv 的 IP 地址速度通常较慢。特别是在进行图片下载时,原图下载可能需要很长时间,请设置足够长的超时时间。如果您有优质代理服务,建议优先使用代理方式连接。
代理连接
var config = new ConnectionConfig
{
Mode = ConnectionMode.Proxy,
ProxyUrl = "http://127.0.0.1:7890"
};
var api = new PixivAppApi(config);
示例程序
查看 PixivCS.Tests
项目获取完整的使用示例,该项目可以直接编译运行。
文档
详细文档请参考项目 Wiki。
许可证
MIT
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- System.Text.Json (>= 8.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v0.1.3 - Breaking change: Separated SearchTarget enum into SearchTarget (for illust) and NovelSearchTarget (for novel) to correctly support different search targets. Novel search now supports 'text' and 'keyword' targets while illust search supports 'title_and_caption' target.