Skip to main content

A library for the Pixiv API.

Project description

CI Codecov Docs PyPI

A documented, idiomatic, and tested wrapper library around Pixiv’s App API.

Supports Python versions 3.6+.

Install with:

$ pip install pixiv-api

Quickstart

To start making requests to the Pixiv API, instantiate a client object.

from pixivapi import Client

client = Client()

The client can be authenticated to Pixiv’s API in multiple ways. One is by logging in with a username and password:

client.login("username", "password")

And another is with a refresh token.

client.authenticate("refresh_token")

Once authenticated, a refresh token can be saved for future authorizations.

refresh_token = client.refresh_token

After authenticating, the client can begin making requests to all of the Pixiv endpoints. For example, the following code block downloads an image from Pixiv.

from pathlib import Path
from pixivapi import Size

illustration = client.fetch_illustration(75523989)

illustration.download(
    directory=Path.home() / "my_pixiv_images",
    size=Size.ORIGINAL,
)

And the next code block downloads all illustrations of an artist.

from pathlib import Path
from pixivapi import Size

artist_id = 2188232
directory = Path.home() / "wlop"

response = client.fetch_user_illustrations(artist_id)

while True:
    for illust in response["illustrations"]:
        illust.download(directory=directory, size=Size.ORIGINAL)

    if not response["next"]:
        break

    response = client.fetch_user_illustrations(
        artist_id,
        offset=response["next"],
    )

Read the full documentation at https://pixiv-api.readthedocs.io.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pixiv-api-1.0.0.tar.gz (18.0 kB view hashes)

Uploaded Source

Built Distribution

pixiv_api-1.0.0-py3-none-any.whl (18.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page