pixiv: Pixiv API binding based on servant-client

[ bsd3, library, web ] [ Propose Tags ]

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


[Skip to Readme]
Versions [RSS] [faq] 0.1.0
Change log CHANGELOG.md
Dependencies aeson (>=1.5.4 && <1.6), base (>=4.10 && <5), base16-bytestring (>=0.1.1 && <1.1), bytestring (>=0.10.12 && <0.11), cryptohash-md5 (>=0.11.100 && <0.12), directory (>=1.3.6 && <1.4), exceptions (>=0.10.4 && <0.11), filepath (>=1.4.2 && <1.5), http-client (>=0.6.4 && <0.7), http-client-tls (>=0.3.5 && <0.4), lens (>=4.19.2 && <4.20), monad-control (>=1.0.2 && <1.1), mtl (>=2.2.2 && <2.3), process (>=1.6.9 && <1.7), servant (>=0.18.2 && <0.19), servant-client (>=0.18.2 && <0.19), servant-client-core (>=0.18.2 && <0.19), template-haskell, temporary (==1.3.*), text (>=1.2.3 && <1.3), time (>=1.9.3 && <1.10), transformers (>=0.5.6 && <0.6), transformers-base (>=0.4.5 && <0.5), zip-archive (>=0.4.1 && <0.5) [details]
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 1 made by berberman at 2021-04-14T05:59:28Z
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 2021-01-30T05:56:41Z
Distributions NixOS:0.1.0
Downloads 79 total (5 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2021-01-30 [all 1 reports]

Modules

[Index] [Quick Jump]

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

For package maintainers and hackage trustees

Candidates


Readme for pixiv-0.1.0

[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 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 = Password "username" "password"
  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).