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-api-wrapper

v1.2.2

Published

A type safe wrapper for Pixiv App API

Downloads

5

Readme

pixiv-api-wrapper

A type safe wrapper for Pixiv App API.

How to use

Authentication

It recommended you authenticate with Refresh Token as ID authentication can easily produce errors in from browser processes. To retrieve your Refresh Token you may try to authenticate through Options 2 or 3 or through another program.

Authentication Options:

  1. Authenticate with Refresh Token (Recommended)
const client = await PixivApi.create("<your refresh token>");
  1. Authenticating with ID (Not recommended) see [1]
const browser = await puppeteer.launch({ headless: 'new' });
const client = await PixivApi.create({ userId, password }, browser);
  1. Complete authentication in an opened browser see [2]
const client = await PixivApi.create({ userId, password });

Retrieve Authenticated User

const auth = client.Auth.getAuthentication();
const { accessToken, refreshToken, user } = auth;

API

const illustDetail = await client.Illust.detail("<artworkId>");

Util

Downloading illustrations

const illustDetail = await client.Illust.detail("<artworkId>");
const downloadResults = await Utils.downloadIllusts(illustDetail);
	for (const result of downloadResults) {
		if (result.status == 'fulfilled') {
			const { data, metadata: { fileName, fileExtension } } = result.value;
					// save to file or do something else
			fs.writeFileSync(`${fileName}.${fileExtension}`, data);
		} else {
			const { reason } = result;
      		// handle 'rejected'
		}
	}

Downloading gif

const ugoiraMetadata = await client.Ugoira.metadata("<artworkId>");
const { metadata: { fileName, fileExtension }, data } = await Utils.downloadUgoira(ugoiraMetadata);
fs.writeFileSync(`${fileName}.${fileExtension}`, data);

[1]: Puppeteer is optional, however it is required if you choose to authenticate by ID in a headless browser. Recommended to use 'puppeteer-chromium-resolver' if you find difficulty.

[2]: If no puppeteer browser is provided, you will be prompted to enter a code by having to manually complete the login in the opened browser [source]:

  1. Open dev console (F12) and switch to network tab.
  2. Enable persistent logging ("Preserve log").
  3. Type into the filter field: callback?
  4. Proceed with Pixiv login.
  5. After logging in you should see a blank page and request that looks like this: https://app-api.pixiv.net/web/v1/users/auth/pixiv/callback?state=...&code=.... Copy value of the code parameter into the prompt and hit the Enter key.

License

MIT licensed