npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pixiv-node

v1.0.8

Published

JavaScript wrapper for pixiv

Downloads

65

Readme

About

pixiv-node is a simple JavaScript wrapper for Pixiv, which sends requests to their backend API.

Features

  • Fully asynchronous
  • Provides support for most read-only actions
  • Doesn't require authentication for SFW content
  • Provides a way of authenticating for features locked behind accounts
  • Built with TypeScript for improved IDE support

Installation

$ npm i pixiv-node

Usage

Methods

| Method | Description | Authentication | | ----------------- | --------------------------------------------------------------- | ------------------ | | get | A private utility method used in all other methods | N/A | | getIllust | Get the data of an illustration/manga | No | | getIllustComments | Get all the comments of a specific illustration/manga | No | | getIllustImage | Get all the images associated with a illustration/manga | If NSFW | | getNovel | Get all the data associated with a novel | If NSFW | | getNovelComments | Get all the comments of a specific novel | If NSFW | | getNovelSeries | Get all novels inside of a series | If NSFW | | getUser | Get info asociated with a specific user id | If using bookmarks | | login | Store your cookie in memory for authentication | N/A | | search | Search for a specific query with additional optional parameters | If using r18 |

Pixiv groups illustrations and manga together, which is why some of the methods aren't called getIllustMangaX

Method parameters

// dist/index.d.ts

type NumericString = string | number;
export default class Pixiv {
	private static token;
	private static get;
	static getIllust(id: NumericString): Promise<Object>;
	static getIllustComments(
		id: NumericString,
		limit?: NumericString
	): Promise<Object>;
	static getIllustImages(id: NumericString): Promise<Object>;
	static getNovel(id: NumericString): Promise<Object>;
	static getNovelComments(
		id: NumericString,
		limit?: NumericString
	): Promise<Object>;
	static getNovelSeries(id: NumericString): Promise<Object>;
	static getUser(
		id: NumericString,
		option: "all" | "top" | "bookmarks/illusts" | "bookmarks/novels",
		limit?: NumericString
	): Promise<Object>;
	static login(token: string): typeof Pixiv;
	static search({
		query,
		order,
		mode,
		type,
		ai,
	}: {
		query: string;
		order?: "date" | "date_d";
		mode?: "all" | "safe" | "r18";
		type?: "top" | "illust_and_ugoira" | "manga" | "artworks" | "novels";
		ai?: 0 | 1;
	}): Promise<Object>;
}
export {};

Authentication

If you would like to authenticate in order to access account restricted features (NSFW content, bookmarks), then you can pass in part of your browser cookie to the login() method before calling any other methods. It should look something like the following:

const token = "PHPSESSID=xxxxxxx_xxxxxxxxxxxxxxxxx";

In order to access this, you can follow these steps:

  1. Log into pixiv
  2. Open up your browser developer tools
  3. Visit a post
  4. Go to the networks tab in developer tools and search for https://www.pixiv.net/ajax/illusts
  5. Click on the corresponding GET request and scroll down to the first Cookie: section
  6. Copy the part of the cookie that has PHPSESSID=

Example

import Pixiv from "pixiv-node";

(async () => {
	// get 3 comments of a specific illustration or manga
	const comments = await Pixiv.getIllustComments(119640517, 3);

	// get all the data of a specific illustration or manga
	const illust = await Pixiv.getIllust(119640517);

	// get all images of a specific illustration or manga
	const images = await Pixiv.getIllustImages(119640517);

	// get a specific novel
	const novel = await Pixiv.getNovel(17814676);

	// advanced usage:
	// login with browser cookie, then search for all nsfw artwork
	// with the query "gawr gura" using descending order (oldest)
	// and allowing ai artwork
	const search = await Pixiv.login(process.env.TOKEN).search({
		query: "gawr gura",
		order: "date_d",
		mode: "r18",
		type: "illust_and_ugoira",
		ai: 1,
	});
})();

For a more detailed example of how to use this library, you can refer to pixiv-cli.

Development

$ git clone https://github.com/FireStreaker2/pixiv-node.git
$ cd pixiv-node
$ npm i
$ npm run build
$ ./dist/index.js

License

MIT