pixiv: Pixiv API binding based on servant-client

[ bsd3, library, web ] [ Propose Tags ] [ Report a vulnerability ]

Pixiv API binding based on servant-client. See README for details.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.1
Change log CHANGELOG.md
Dependencies aeson (>=1.5.4 && <2.3), base (>=4.10 && <5), base16-bytestring (>=0.1.1 && <1.1), bytestring (>=0.10 && <0.12.0), cryptohash-md5 (>=0.11.100 && <0.12), exceptions (>=0.10.4 && <0.11), filepath (>=1.4.2 && <1.5.1), http-client (>=0.5), http-client-tls, lens (>=4.19 && <5.3), monad-control (>=1.0.2 && <1.1), mtl, process, servant (>=0.18.2 && <0.21), servant-client (>=0.18.2 && <0.21), servant-client-core (>=0.18.2 && <0.21), template-haskell (>=2.15.0 && <2.16 || >=2.16.0 && <2.17 || >=2.17.0 && <2.18 || >=2.18.0 && <2.19 || >=2.19.0 && <2.20 || >=2.20.0 && <2.21 || >=2.21.0 && <2.22), temporary (>=1.3 && <1.4), text, time (>=1.9.3 && <1.13), transformers (>=0.5.6 && <0.6.2), transformers-base (>=0.4.5 && <0.5), zip-archive (>=0.4.1 && <0.5) [details]
Tested with ghc ==8.8.3 || ==8.8.4 || ==8.10.4 || ==8.10.5 || ==9.0.1 || ==9.0.2
License BSD-3-Clause
Copyright Copyright (c) The closed eye of love 2021
Author Poscat, berberman
Maintainer Poscat <poscat@mail.poscat.moe>, berberman <berberman@yandex.com>
Revised Revision 2 made by berberman at 2024-01-15T21:18:53Z
Category Web
Home page https://github.com/The-closed-eye-of-love/pixiv
Bug tracker https://github.com/The-closed-eye-of-love/pixiv/issues
Source repo head: git clone https://github.com/The-closed-eye-of-love/pixiv
Uploaded by berberman at 2022-07-25T19:47:29Z
Distributions
Downloads 283 total (10 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-07-25 [all 1 reports]

Readme for pixiv-0.1.1

[back to package description]

pixiv

build nix Hackage Hackage-Deps LICENSE

Haskell implementation of Pixiv API, based on servant-client.

Usage

In most cases, it is enough to import only Web.Pixiv. If you want to use lenses to access and operate data types, you should import Web.Pixiv.Types.Lens as well. Pixiv API requires authentication before being accessed, thus the PixivT monad transformer provides an user-friendly and thread-safe interface to manage, and renew access token on demand, where you just need to give the username and password refresh token (See https://github.com/upbit/pixivpy/issues/158) of your pixiv account.

Example

Here is a simpe example:

import Control.Lens ((^.))
import Control.Monad.IO.Class (liftIO)
import Web.Pixiv
import Web.Pixiv.Types.Lens

main :: IO ()
main = do
  let credential = RefreshToken "token"
  result <- runPixivT' credential action
  case result of
    Left err -> print err
    Right x -> pure x

action :: PixivT IO ()
action = do
  -- gets the details of user <https://www.pixiv.net/users/16731>
  userDetail <- getUserDetail 16731
  liftIO $ print userDetail

  -- gets the details of illustration <https://www.pixiv.net/artworks/80132896>
  illustDetail <- getIllustDetail 80132896
  liftIO $ print illustDetail

  -- gets day ranking illustrations
  -- 1 means the first page of the results
  ranking <- getIllustRanking (Just Day) 1
  liftIO $ print ranking

  -- searches the user who has name "玉之けだま" then gets their first work
  -- (function 'head' is not total, just used for demonstration) 
  targetUser <- head <$> searchUser "玉之けだま" Nothing 1
  firstWork <- head <$> getUserIllusts (targetUser ^. user . userId) (Just TypeIllust) 1
  liftIO $ print firstWork

As you can see, functions accessing Pixiv API are run in PixivT IO monad. For more functionalities this library provides and relevant information about functions or data types, please refer to the documentation.

Documentation

Documentation is available at hackage (latest release) and our github pages (master).