Git Product home page Git Product logo

pixiv's Introduction

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 upbit/pixivpy#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).

Related projects

pixiv's People

Contributors

berberman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.