Giter Club home page Giter Club logo

pixiv-api's Introduction

pixiv-api

PyPI Pyversions Docs

A library for the Pixiv API. Uses Pixiv's App API.

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 complete documentation at https://pixiv-api.readthedocs.io.

Changelog

v0.3.6

  • Fix inability to login.

v0.3.5

  • Fix issue with offset not working in fetch_illustrations_following.

v0.3.4

  • Fix issue with Python 3.6 compatibility wrt. datetime module.

v0.3.3

  • Fix arguments of Novel class instantiation.

v0.3.1

  • Fix quickstart example documentation.

v0.3.0

  • Update authentication in response to Pixiv's changes.

v0.2.0

  • Change Client.account from a dict to an Account model.
  • Remove None attributes from User that only applied to responses from Client.fetch_user and move them to a FullUser subclass.
  • Change return type of Client.fetch_user to a FullUser. No attributes were changed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.