{"id":15763150,"url":"https://github.com/shigma/pxapi","last_synced_at":"2025-06-20T20:34:50.494Z","repository":{"id":103501007,"uuid":"141557997","full_name":"shigma/pxapi","owner":"shigma","description":"Promise based Pixiv API client for NodeJS.","archived":false,"fork":false,"pushed_at":"2018-08-04T11:40:16.000Z","size":61,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T16:18:38.593Z","etag":null,"topics":["pixiv","pixiv-api","pixiv-client"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shigma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-19T09:40:00.000Z","updated_at":"2023-11-09T13:36:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"14760d97-b18c-4c4f-a878-0bc5be34d864","html_url":"https://github.com/shigma/pxapi","commit_stats":null,"previous_names":["shigma/pixiv-api-client"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/shigma/pxapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigma%2Fpxapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigma%2Fpxapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigma%2Fpxapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigma%2Fpxapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shigma","download_url":"https://codeload.github.com/shigma/pxapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shigma%2Fpxapi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261012850,"owners_count":23096924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pixiv","pixiv-api","pixiv-client"],"created_at":"2024-10-04T11:40:43.661Z","updated_at":"2025-06-20T20:34:45.475Z","avatar_url":"https://github.com/shigma.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pixiv API Client\n\n这是受到 [alphasp](https://github.com/alphasp/pixiv-api-client) 启发而开发的一套 Pixiv 客户端函数库。相比原仓库增加了以下优点：\n\n- 完全使用 NodeJS 原生库编写，无需任何依赖。\n- 支持 https 等多种网络库，登录信息更加安全。\n- 自带 hosts 接口，可以实现自动翻墙功能。\n- 同时支持 camel-case，kebab-case 和 snake-case。\n- 减少了 API 的数量和长度，专注于 API 的功能和逻辑。\n- 完全基于 Promise 的同时也允许你像同步函数一样编程。\n- 当检测到 premium 用户时自动启动按热度排序。\n- 所有函数使用 jsDoc 进行注释，便于阅读。\n\n## 安装与使用\n\n安装：\n```\nnpm i pxapi\n```\n\n使用：\n```JavaScript\nconst PixivAPI = require('pxapi')\n```\n\n## 文档\n\n下面的文档将介绍 Pixiv API Client 的使用方法。我会按照类的顺序依次介绍：\n- AsyncWrapper\n- Collection\n- PixivAPI\n- PixivUser\n- PixivNovel\n- PixivIllust\n- PixivComment\n\n### AsyncWrapper\n\nAsyncWrapper 是一个 Proxy，可以用来简化 Promise 的书写。看一个例子：\n\n```JavaScript\nconst pixiv = new PixivApi()\npixiv.login(username, password).then(() =\u003e {\n  pixiv\n    .searchIllust(68910277) // 查找某一部作品\n    .author() // 作品的作者\n    .illusts() // 作者的全部作品\n    .itemAt(2) // 第 2 个作品\n    .comments() // 作品的全部评论\n    .itemAt(1) // 第 1 个评论\n    .author() // 评论的作者\n    .following() // 作者的关注\n    .itemAt(5) // 第 5 个关注\n    .detail() // 用户的详细信息\n    .then(console.log)\n}).catch(console.log)\n```\n\nPixiv API Client 中的几乎所有函数都是异步的，但你不必使用大量的`then`，因为 AsyncWrapper 为你做好了相关的绑定工作。你只需要像同步函数一样书写，同时记得最后加上补完异步的逻辑即可。\n\n### Collection\n\nCollection 也是一个 Proxy，可以用来简化数组的更新。一些请求列表的 API 并不会一次性地返回所有结果，而是只会返回一部分，这时候 Collection 会自动检测所需的数据，并按需自行向列表中添加。\n\n除了支持 Array 的所有属性和方法外，Collection 还有下列实例属性和方法：\n\n#### coll.next: string | null\n\n返回数组中下一批未加载的数据的 URL。如果已经没有下一批数据则返回 null。\n\n#### coll.itemAt(index: number): AsyncWrapper\n\n- index: 元素的序号，从 1 开始计数。\n- 返回: 当前数组中的第 index 个元素。\n\n### PixivAPI\n\nPixivAPI 是这个库的入口。它可以由一个构造函数来创建实例。每个实例会绑定一个账号，实例中大部分的方法都需要注册过的账号，否则会返回一个 Authorization required 错误。它有一些配置可以通过构造函数实现：\n\n#### new PixivAPI({library?: {request: Function}, hosts?: string | object})\n\n- library: 要使用的网络库，必须有一个 request 方法。默认值为`require('https')`。\n- hosts: 要使用的 Hosts。可以是一个字符串，格式为 hosts 文件的格式。也可以是一个对象，键形如`pixiv.pximg.net`，对应的值是其 IP 地址。如果不写则默认为我们自带的 hosts。如果不想使用 hosts 只需使用空对象`{}`即可。\n\nPixivAPI 有下列实例方法：\n\n#### pixiv.setLanguage(language: string): void\n\n重新设置当前语言。默认语言为`en-US`。\n- language: 要设置的语言名。形如`en-US`。\n\n#### pixiv.login(username: string, password: string, remember?: boolean): AsyncWrapper\n\n登录到 Pixiv 账号。\n- username: 用户名或者邮箱地址。\n- password: 密码。\n- remember: 是否记住密码。默认为`true`。\n- 返回：提交得到的结果。\n\n#### pixiv.logout(): void\n\n登出当前的 Pixiv 账号。\n\n#### pixiv.refreshAccessToken(token?: string): AsyncWrapper\n\n更新 Pixiv 账号的访问令牌。\n- token: 新的访问令牌。默认值为旧的访问令牌。\n- 返回：提交得到的结果。\n\n#### pixiv.createProvisionalAccount(nickname: string): AsyncWrapper\n\n创建一个临时账号。\n- nickname: 昵称。\n- 返回: 提交得到的结果。\n\n#### pixiv.userState(): AsyncWrapper\n\n- 返回: 当前用户的状态信息。\n\n#### pixiv.editUserAccount({password?: string, pixivId?: string, newPassword?: string, email?: string}): AsyncWrapper\n\n#### pixiv.sendAccountVerificationEmail(): AsyncWrapper\n\n#### Search API\n\nSearch API 包含 searchWord，searchUser，searchIllust，searchNovel，searchComment 和 searchSeries。它们的使用方法类似，我们一并介绍。\n\n#### Get API\n\nGet API 包含 getUsers，getIllusts，getNovels，getMangas。它们的使用方法类似，我们一并介绍。\n\n### PixivUser\n\n### PixivNovel\n\n### PixivIllust\n\n### PixivComment\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshigma%2Fpxapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshigma%2Fpxapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshigma%2Fpxapi/lists"}