# PixivPy3 ![Build Status](https://github.com/upbit/pixivpy/workflows/pixivpy/badge.svg?branch=master) [![PyPI version](https://badge.fury.io/py/PixivPy3.svg)](https://badge.fury.io/py/PixivPy3)
> Due to [#158](https://github.com/upbit/pixivpy/issues) reason, password login
> no longer exist. Please use `api.auth(refresh_token=REFRESH_TOKEN)` instead
>
> To get `refresh_token`, see
> [@ZipFile Pixiv OAuth Flow](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362)
> or
> [OAuth with Selenium/ChromeDriver](https://gist.github.com/upbit/6edda27cb1644e94183291109b8a5fde)
_Pixiv API for Python (with Auth supported)_
- [2024/03/03] _v3.7.5_ Fix `novel_text()` BUG, add `webview_novel()`, see
[#337](https://github.com/upbit/pixivpy/issues/337) (thanks
[@xiyihan](https://github.com/xiyihan0))
- [2023/09/18] _v3.7.3_ Add `novel_follow()`, fix ByPassSniApi() host BUG, see
[#279](https://github.com/upbit/pixivpy/issues/279) (thanks
[@Solomon](https://github.com/Solomon-Edwards),
[@rhyryy](https://github.com/rhyryy))
- [2023/09/17] Move to new PEP 517 standard with poetry, and upgrade deps, see
[#270](https://github.com/upbit/pixivpy/pull/270) (thanks
[@Nachtalb](https://github.com/Nachtalb))
- [2022/02/04] Remove Public-API support as it's deprecated by Pixiv, see
[#201](https://github.com/upbit/pixivpy/commit/74e114e1cfe51e6c0e8c30c2024bcfcf0bae7ccc)
- [2021/11/23] Add `illust_new` for get latest works, see
[#189](https://github.com/upbit/pixivpy/commit/024d4e7212582ca6f31ef5592b4b5b46cb351cbc)
- [2021/03/02] Add user `follow/unfollow`, add `novel` API, see
[#161](https://github.com/upbit/pixivpy/pull/161/files) (thanks
[@y-young](https://github.com/y-young),
[@invobzvr](https://github.com/invobzvr))
- [2020/10/17] Use [cloudscraper](https://github.com/VeNoMouS/cloudscraper) to
bypass Cloudflare, fixed issue #140 (thanks
[@lllusion3469](https://github.com/lllusion3469))
- [2020/07/19] Add date specification for `search_illust()` (thanks
[Xdynix](https://github.com/Xdynix))
- [2020/06/06] Add `AppPixivAPI().search_novel()` for novel search
- [2019/09/23] 增加大陆地区 AppAPI 的免翻墙访问支持, release v3.5 (See
[example_bypass_sni.py](https://github.com/upbit/pixivpy/blob/master/example_bypass_sni.py),
thanks [@Notsfsssf](https://github.com/Notsfsssf))
- [2019/09/03] Support new auth() check `X-Client-Time/X-Client-Hash` (thanks
[DaRealFreak](https://github.com/DaRealFreak),
[#83](https://github.com/upbit/pixivpy/issues/83))
- [2019/04/27] Support hosts proxy for AppAPI, which can use behind the Great
Wall (See
[example_api_proxy.py](https://github.com/upbit/pixivpy/blob/master/example_api_proxy.py))
- [2017/04/18] Fix encoder BUG for
`illust_bookmark_add()/illust_bookmark_delete()` params (thanks
[naplings](https://github.com/naplings))
- [2017/01/05] Add `PixivAPI().works()` liked API `illust_detail()` for App-API
(thanks [Mapaler](https://github.com/Mapaler)), release v3.3
- [2016/12/17] Fixed encoding BUG for Public-API, see #26 (thanks
[Xdynix](https://github.com/Xdynix))
- [2016/07/27] Now `AppPixivAPI()` can call **without auth** (thanks
[zzycami](https://github.com/zzycami)), check
[demo.py](https://github.com/upbit/pixivpy/blob/b83578e066ddcba86295676d931ff3313d138b22/demo.py#L268)
- [2016/07/20] New **App-API** (Experimental) for `PixivIOSApp/6.0.9`
- [2016/07/11] Add new
[iOS 6.x API](https://github.com/upbit/pixivpy/wiki#6x-api) reference to Wiki
- [2015/12/02] Add write API for favorite an user / illust, release v3.1
- [2015/08/11] Remove SPAI and release v3.0 (pixivpy3) (Public-API with Search
API)
- [2015/05/16] As Pixiv **deprecated** SAPI in recent days, push new Public-API
**ranking_all**
- [2014/10/07] New framework, **SAPI / Public-API** supported (requests needed)
Use pip for installing:
```bash
# for Python3
pip install pixivpy3 --upgrade
# for Python2
pip install pixivpy --upgrade
```
Requirements: [requests](https://pypi.python.org/pypi/requests)
### [Mikubill/PixivPy-Async](https://github.com/Mikubill/pixivpy-async): Async Pixiv API for Python 3
> 性能对比(需要高性能访问场景,可以参
> 考[这个脚本](https://github.com/Mikubill/pixivpy-async/blob/master/Perf.py))
> Warning: The rate limit was hit multiple times during the test, so the result
> may not be informative. Script:
> https://github.com/Mikubill/pixivpy-async/blob/master/Perf.py
`sg -> Singapore, jp -> Japan, unit -> second`
| Method | Sync(10,sg) | Async(10,sg) | Sync(200,sg) | Async(200,sg) |
| ------------------ | ----------- | ------------ | ------------ | ------------- |
| illust_detail | 1.1209 | 0.8641 | 31.7041 | 2.4580 |
| illust_ranking | 1.0697 | 0.7936 | 28.4539 | 2.0693 |
| user_illusts | 0.8824 | 0.7505 | 28.3981 | 1.8199 |
| user_detail | 0.9628 | 0.7550 | 28.3055 | 1.7738 |
| ugoira_metadata | 0.8509 | 0.7459 | 29.5566 | 2.2331 |
| works | 1.1204 | 0.8912 | 32.2068 | 2.8513 |
| me_following_works | 1.1253 | 0.7845 | 39.3142 | 2.2785 |
| ranking | 1.0946 | 0.7944 | 39.6509 | 2.6548 |
| latest_works | 1.0483 | 0.8667 | 36.1992 | 2.5066 |
| Method | Sync(500,jp) | Async(500,jp) |
| ------------------ | ------------ | ------------- |
| illust_detail | 6.2178 | 0.6400 |
| illust_ranking | 6.4046 | 0.6119 |
| user_illusts | 7.6093 | 1.5266 |
| user_detail | 6.6759 | 0.5952 |
| ugoira_metadata | 6.5155 | 0.7577 |
| works | 13.3074 | 0.8619 |
| me_following_works | 24.2693 | 2.0835 |
| ranking | 21.4119 | 3.2805 |
| latest_works | 17.3502 | 2.7029 |
### Projects base on pixivpy
1. [Mikubill/PixivPy-Async](https://github.com/Mikubill/pixivpy-async): Async
Pixiv API for Python 3
### Example:
```python
from pixivpy3 import *
api = AppPixivAPI()
# api.login("username", "password") # Not required
# get origin url
json_result = api.illust_detail(59580629)
illust = json_result.illust
print(">>> origin url: %s" % illust.image_urls['large'])
# get ranking: 1-30
# mode: [day, week, month, day_male, day_female, week_original, week_rookie, day_manga]
json_result = api.illust_ranking('day')
for illust in json_result.illusts:
print(" p1 [%s] %s" % (illust.title, illust.image_urls.medium))
# next page: 31-60
next_qs = api.parse_qs(json_result.next_url)
json_result = api.illust_ranking(**next_qs)
for illust in json_result.illusts:
print(" p2 [%s] %s" % (illust.title, illust.image_urls.medium))
# get all page:
next_qs = {"mode": "day"}
while next_qs:
json_result = api.illust_ranking(**next_qs)
for illust in json_result.illusts:
print("[%s] %s" % (illust.title, illust.image_urls.medium))
next_qs = api.parse_qs(json_result.next_url)
```
### [Sniffer - App API](https://github.com/upbit/pixivpy/wiki#6x-api)
### [Sniffer - Public API (deprecated)](https://github.com/upbit/pixivpy/wiki/sniffer)
### [Using API proxy behind the Great Wall](https://github.com/upbit/pixivpy/blob/aec177aa7a1979f7ec4c5bbbeed9085cc256bdbd/example_bypass_sni.py#L17) See detail in [Issue#73](https://github.com/upbit/pixivpy/issues/73)
1. Upgrade pixivpy >= **v3.2.0**: `pip install pixivpy --upgrade`
2. Call `api.download()` like the below:
```python
aapi = AppPixivAPI()
json_result = aapi.illust_ranking()
for illust in json_result.illusts[:3]:
aapi.download(illust.image_urls.large)
```
### [Migrate pixivpy2 to pixivpy3](https://github.com/upbit/pixivpy/blob/b1ad6b98/demo.py#L15-L25)
1. Replace `api.papi.*` to `api.*`
2. Change deprecated SPAI call to Public-API call
```python
print(">>> new ranking_all(mode='daily', page=1, per_page=50)")
#rank_list = api.sapi.ranking("all", 'day', 1)
rank_list = api.ranking_all('daily', 1, 50)
print(rank_list)
# more fields about response: https://github.com/upbit/pixivpy/wiki/sniffer
ranking = rank_list.response[0]
for img in ranking.works:
# print(img.work)
print("[%s/%s(id=%s)] %s" % (img.work.user.name, img.work.title, img.work.id, img.work.image_urls.px_480mw))
```
### About
1. Blog:
[Pixiv Public-API (OAuth)分析](http://blog.imaou.com/opensource/2014/10/09/pixiv_api_for_ios_update.html)
If you have any questions, please feel free to contact me: rmusique@gmail.com
Find Pixiv API in **Objective-C**? You might also like
[**PixivAPI_iOS**](https://github.com/upbit/PixivAPI_iOS)
## API functions
### App-API (6.0 - app-api.pixiv.net)
```python
class AppPixivAPI(BasePixivAPI):
# 返回翻页用参数
def parse_qs(next_url):
# 用户详情
def user_detail(user_id):
# 用户作品列表
## type: [illust, manga]
def user_illusts(user_id, type="illust"):
# 用户收藏作品列表
# tag: 从 user_bookmark_tags_illust 获取的收藏标签
def user_bookmarks_illust(user_id, restrict="public"):
# 用户收藏作品列表中的小说
def user_bookmarks_novel(user_id, restrict="public"):
def user_related(seed_user_id):
# 关注用户的新作
# restrict: [public, private]
def illust_follow(restrict="public"):
# 作品详情 (类似PAPI.works(),iOS中未使用)
def illust_detail(illust_id):
# 作品评论
def illust_comments(illust_id, include_total_comments=None):
# 相关作品列表
def illust_related(illust_id):
# 插画推荐 (Home - Main)
# content_type: [illust, manga]
def illust_recommended(content_type="illust"):
# 小说推荐
def novel_recommended():
# 作品排行
# mode: [day, week, month, day_male, day_female, week_original, week_rookie, day_manga]
# date: '2016-08-01'
# mode (Past): [day, week, month, day_male, day_female, week_original, week_rookie,
# day_r18, day_male_r18, day_female_r18, week_r18, week_r18g]
def illust_ranking(mode="day", date=None):
# 趋势标签 (Search - tags)
def trending_tags_illust():
# 搜索 (Search)
# search_target - 搜索类型
# partial_match_for_tags - 标签部分一致
# exact_match_for_tags - 标签完全一致
# title_and_caption - 标题说明文
# sort: [date_desc, date_asc, popular_desc] - popular_desc为会员的热门排序
# duration: [within_last_day, within_last_week, within_last_month]
# start_date, end_date: '2020-07-01'
def search_illust(word, search_target="partial_match_for_tags", sort="date_desc", duration=None, start_date=None, end_date=None):
# 搜索小说 (Search Novel)
# search_target - 搜索类型
# partial_match_for_tags - 标签部分一致
# exact_match_for_tags - 标签完全一致
# text - 正文
# keyword - 关键词
# sort: [date_desc, date_asc]
# start_date/end_date: 2020-06-01
def search_novel(word, search_target="partial_match_for_tags", sort="date_desc", start_date=None, end_date=None):
def search_user(word, sort='date_desc', duration=None):
# 作品收藏详情
def illust_bookmark_detail(illust_id):
# 新增收藏
def illust_bookmark_add(illust_id, restrict="public", tags=None):
# 删除收藏
def illust_bookmark_delete(illust_id):
# 关注用户
def user_follow_add(user_id, restrict="public"):
# 取消关注用户
def user_follow_delete(user_id):
# 用户收藏标签列表
def user_bookmark_tags_illust(restrict="public"):
# Following用户列表
def user_following(user_id, restrict="public"):
# Followers用户列表
def user_follower(user_id):
# 好P友
def user_mypixiv(user_id):
# 黑名单用户
def user_list(user_id):
# 获取ugoira信息
def ugoira_metadata(illust_id):
# 用户小说列表
def user_novels(user_id):
# 小说系列详情
def novel_series(series_id, last_order=None):
# 小说详情
def novel_detail(novel_id):
# 小说 (包含正文)
def webview_novel(novel_id):
# 小说评论
def novel_comments(novel_id):
# 大家的新作
# content_type: [illust, manga]
def illust_new(content_type="illust", max_illust_id=None):
def novel_new(max_novel_id=None):
# 特辑详情 (无需登录,调用Web API)
def showcase_article(showcase_id):
```
[Usage](https://github.com/upbit/pixivpy/blob/aec177aa7a1979f7ec4c5bbbeed9085cc256bdbd/demo.py#L306):
```python
aapi = AppPixivAPI()
# 作品推荐
json_result = aapi.illust_recommended()
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# 作品相关推荐
json_result = aapi.illust_related(57065990)
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# 作品相关推荐-下一页 (.parse_qs(next_url) 用法)
next_qs = aapi.parse_qs(json_result.next_url)
json_result = aapi.illust_related(**next_qs)
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# 用户详情
json_result = aapi.user_detail(660788)
print(json_result)
user = json_result.user
print("%s(@%s) region=%s" % (user.name, user.account, json_result.profile.region))
# 用户作品列表
json_result = aapi.user_illusts(660788)
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# 用户收藏列表
json_result = aapi.user_bookmarks_illust(2088434)
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# 用户收藏列表中的小说
json_result = aapi.user_bookmarks_novel(42862448)
print(json_result)
novel = json_result.novels[0]
print(">>> {}, text_length: {}, series: {}".format(novel.title, novel.text_length, novel.series))
# 2016-07-15 日的过去一周排行
json_result = aapi.illust_ranking('week', date='2016-07-15')
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# 关注用户的新作 (需要login)
json_result = aapi.illust_follow(req_auth=True)
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# 标签 "水着" 搜索
json_result = aapi.search_illust('水着', search_target='partial_match_for_tags')
print(json_result)
illust = json_result.illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# 用户 "gomzi" 搜索
json_result = aapi.search_user("gomzi")
print(json_result)
illust = json_result.user_previews[0].illusts[0]
print(">>> %s, origin url: %s" % (illust.title, illust.image_urls['large']))
# 展示小说评论区
json_result = aapi.novel_comments(16509454, include_total_comments=True)
print("Total comments = {}".format(json_result["total_comments"]))
for comment in json_result["comments"]:
if comment["parent_comment"] != dict():
print("{user} replied to {target} at {time} : {content}".format(user = comment["user"]["name"], time = comment["date"], content = comment["comment"], target = comment["parent_comment"]["user"]["name"]))
else:
print("{user} at {time} : {content}".format(user=comment["user"]["name"], time=comment["date"], content=comment["comment"]))
```
## Package Publishing Instructions
Follow these simple steps to publish your Poetry package. We recommend
publishing to the [test.pypi.org](https://test.pypi.org/) instance first, to
verify everything is working as expected.
This step only has to be done once:
```sh
# Configure test.pypi.org
poetry config repositories.testpypi https://test.pypi.org/legacy/
# Configure API Keys for both PyPI and TestPyPY
poetry config pypi-token.testpypi <testpypi_api_key>
poetry config pypi-token.pypi <pypi_api_key>
```
Now publish the new version:
```sh
# Adjust the package version at the top of the "pyproject.toml" file
vim pyproject.toml
# Build python packages to dist/ folder
poetry build
# Publish package to TestPyPi
poetry publish -r testpypi
# Checkout published package in a different environment
pip install --index-url https://test.pypi.org/simple/ <your_package_name>
# Once confirmed that everything works, publish to the real PyPi
poetry publish
```
## License
Feel free to use, reuse and abuse the code in this project.
Raw data
{
"_id": null,
"home_page": "https://github.com/upbit/pixivpy",
"name": "pixivpy3",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "pixiv,api,pixivapi",
"author": "upbit",
"author_email": "rmusique@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/24/19/4a6798a8552dc5702618e3e340b995de959849704458392f4adbfcd697c8/pixivpy3-3.7.5.tar.gz",
"platform": null,
"description": "# PixivPy3 ![Build Status](https://github.com/upbit/pixivpy/workflows/pixivpy/badge.svg?branch=master) [![PyPI version](https://badge.fury.io/py/PixivPy3.svg)](https://badge.fury.io/py/PixivPy3)\n\n> Due to [#158](https://github.com/upbit/pixivpy/issues) reason, password login\n> no longer exist. Please use `api.auth(refresh_token=REFRESH_TOKEN)` instead\n>\n> To get `refresh_token`, see\n> [@ZipFile Pixiv OAuth Flow](https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362)\n> or\n> [OAuth with Selenium/ChromeDriver](https://gist.github.com/upbit/6edda27cb1644e94183291109b8a5fde)\n\n_Pixiv API for Python (with Auth supported)_\n\n- [2024/03/03] _v3.7.5_ Fix `novel_text()` BUG, add `webview_novel()`, see\n [#337](https://github.com/upbit/pixivpy/issues/337) (thanks\n [@xiyihan](https://github.com/xiyihan0))\n- [2023/09/18] _v3.7.3_ Add `novel_follow()`, fix ByPassSniApi() host BUG, see\n [#279](https://github.com/upbit/pixivpy/issues/279) (thanks\n [@Solomon](https://github.com/Solomon-Edwards),\n [@rhyryy](https://github.com/rhyryy))\n- [2023/09/17] Move to new PEP 517 standard with poetry, and upgrade deps, see\n [#270](https://github.com/upbit/pixivpy/pull/270) (thanks\n [@Nachtalb](https://github.com/Nachtalb))\n- [2022/02/04] Remove Public-API support as it's deprecated by Pixiv, see\n [#201](https://github.com/upbit/pixivpy/commit/74e114e1cfe51e6c0e8c30c2024bcfcf0bae7ccc)\n- [2021/11/23] Add `illust_new` for get latest works, see\n [#189](https://github.com/upbit/pixivpy/commit/024d4e7212582ca6f31ef5592b4b5b46cb351cbc)\n- [2021/03/02] Add user `follow/unfollow`, add `novel` API, see\n [#161](https://github.com/upbit/pixivpy/pull/161/files) (thanks\n [@y-young](https://github.com/y-young),\n [@invobzvr](https://github.com/invobzvr))\n- [2020/10/17] Use [cloudscraper](https://github.com/VeNoMouS/cloudscraper) to\n bypass Cloudflare, fixed issue #140 (thanks\n [@lllusion3469](https://github.com/lllusion3469))\n- [2020/07/19] Add date specification for `search_illust()` (thanks\n [Xdynix](https://github.com/Xdynix))\n- [2020/06/06] Add `AppPixivAPI().search_novel()` for novel search\n- [2019/09/23] \u589e\u52a0\u5927\u9646\u5730\u533a AppAPI \u7684\u514d\u7ffb\u5899\u8bbf\u95ee\u652f\u6301, release v3.5 (See\n [example_bypass_sni.py](https://github.com/upbit/pixivpy/blob/master/example_bypass_sni.py),\n thanks [@Notsfsssf](https://github.com/Notsfsssf))\n- [2019/09/03] Support new auth() check `X-Client-Time/X-Client-Hash` (thanks\n [DaRealFreak](https://github.com/DaRealFreak),\n [#83](https://github.com/upbit/pixivpy/issues/83))\n- [2019/04/27] Support hosts proxy for AppAPI, which can use behind the Great\n Wall (See\n [example_api_proxy.py](https://github.com/upbit/pixivpy/blob/master/example_api_proxy.py))\n- [2017/04/18] Fix encoder BUG for\n `illust_bookmark_add()/illust_bookmark_delete()` params (thanks\n [naplings](https://github.com/naplings))\n- [2017/01/05] Add `PixivAPI().works()` liked API `illust_detail()` for App-API\n (thanks [Mapaler](https://github.com/Mapaler)), release v3.3\n- [2016/12/17] Fixed encoding BUG for Public-API, see #26 (thanks\n [Xdynix](https://github.com/Xdynix))\n- [2016/07/27] Now `AppPixivAPI()` can call **without auth** (thanks\n [zzycami](https://github.com/zzycami)), check\n [demo.py](https://github.com/upbit/pixivpy/blob/b83578e066ddcba86295676d931ff3313d138b22/demo.py#L268)\n- [2016/07/20] New **App-API** (Experimental) for `PixivIOSApp/6.0.9`\n- [2016/07/11] Add new\n [iOS 6.x API](https://github.com/upbit/pixivpy/wiki#6x-api) reference to Wiki\n- [2015/12/02] Add write API for favorite an user / illust, release v3.1\n- [2015/08/11] Remove SPAI and release v3.0 (pixivpy3) (Public-API with Search\n API)\n- [2015/05/16] As Pixiv **deprecated** SAPI in recent days, push new Public-API\n **ranking_all**\n- [2014/10/07] New framework, **SAPI / Public-API** supported (requests needed)\n\nUse pip for installing:\n\n```bash\n# for Python3\npip install pixivpy3 --upgrade\n\n# for Python2\npip install pixivpy --upgrade\n```\n\nRequirements: [requests](https://pypi.python.org/pypi/requests)\n\n### [Mikubill/PixivPy-Async](https://github.com/Mikubill/pixivpy-async): Async Pixiv API for Python 3\n\n> \u6027\u80fd\u5bf9\u6bd4\uff08\u9700\u8981\u9ad8\u6027\u80fd\u8bbf\u95ee\u573a\u666f\uff0c\u53ef\u4ee5\u53c2\n> \u8003[\u8fd9\u4e2a\u811a\u672c](https://github.com/Mikubill/pixivpy-async/blob/master/Perf.py)\uff09\n\n> Warning: The rate limit was hit multiple times during the test, so the result\n> may not be informative. Script:\n> https://github.com/Mikubill/pixivpy-async/blob/master/Perf.py\n\n`sg -> Singapore, jp -> Japan, unit -> second`\n\n| Method | Sync(10,sg) | Async(10,sg) | Sync(200,sg) | Async(200,sg) |\n| ------------------ | ----------- | ------------ | ------------ | ------------- |\n| illust_detail | 1.1209 | 0.8641 | 31.7041 | 2.4580 |\n| illust_ranking | 1.0697 | 0.7936 | 28.4539 | 2.0693 |\n| user_illusts | 0.8824 | 0.7505 | 28.3981 | 1.8199 |\n| user_detail | 0.9628 | 0.7550 | 28.3055 | 1.7738 |\n| ugoira_metadata | 0.8509 | 0.7459 | 29.5566 | 2.2331 |\n| works | 1.1204 | 0.8912 | 32.2068 | 2.8513 |\n| me_following_works | 1.1253 | 0.7845 | 39.3142 | 2.2785 |\n| ranking | 1.0946 | 0.7944 | 39.6509 | 2.6548 |\n| latest_works | 1.0483 | 0.8667 | 36.1992 | 2.5066 |\n\n| Method | Sync(500,jp) | Async(500,jp) |\n| ------------------ | ------------ | ------------- |\n| illust_detail | 6.2178 | 0.6400 |\n| illust_ranking | 6.4046 | 0.6119 |\n| user_illusts | 7.6093 | 1.5266 |\n| user_detail | 6.6759 | 0.5952 |\n| ugoira_metadata | 6.5155 | 0.7577 |\n| works | 13.3074 | 0.8619 |\n| me_following_works | 24.2693 | 2.0835 |\n| ranking | 21.4119 | 3.2805 |\n| latest_works | 17.3502 | 2.7029 |\n\n### Projects base on pixivpy\n\n1. [Mikubill/PixivPy-Async](https://github.com/Mikubill/pixivpy-async): Async\n Pixiv API for Python 3\n\n### Example:\n\n```python\nfrom pixivpy3 import *\n\napi = AppPixivAPI()\n# api.login(\"username\", \"password\") # Not required\n\n# get origin url\njson_result = api.illust_detail(59580629)\nillust = json_result.illust\nprint(\">>> origin url: %s\" % illust.image_urls['large'])\n\n# get ranking: 1-30\n# mode: [day, week, month, day_male, day_female, week_original, week_rookie, day_manga]\njson_result = api.illust_ranking('day')\nfor illust in json_result.illusts:\n print(\" p1 [%s] %s\" % (illust.title, illust.image_urls.medium))\n\n# next page: 31-60\nnext_qs = api.parse_qs(json_result.next_url)\njson_result = api.illust_ranking(**next_qs)\nfor illust in json_result.illusts:\n print(\" p2 [%s] %s\" % (illust.title, illust.image_urls.medium))\n\n# get all page:\nnext_qs = {\"mode\": \"day\"}\nwhile next_qs:\n json_result = api.illust_ranking(**next_qs)\n for illust in json_result.illusts:\n print(\"[%s] %s\" % (illust.title, illust.image_urls.medium))\n next_qs = api.parse_qs(json_result.next_url)\n```\n\n### [Sniffer - App API](https://github.com/upbit/pixivpy/wiki#6x-api)\n\n### [Sniffer - Public API (deprecated)](https://github.com/upbit/pixivpy/wiki/sniffer)\n\n### [Using API proxy behind the Great Wall](https://github.com/upbit/pixivpy/blob/aec177aa7a1979f7ec4c5bbbeed9085cc256bdbd/example_bypass_sni.py#L17) See detail in [Issue#73](https://github.com/upbit/pixivpy/issues/73)\n\n1. Upgrade pixivpy >= **v3.2.0**: `pip install pixivpy --upgrade`\n2. Call `api.download()` like the below:\n\n```python\naapi = AppPixivAPI()\njson_result = aapi.illust_ranking()\nfor illust in json_result.illusts[:3]:\n aapi.download(illust.image_urls.large)\n```\n\n### [Migrate pixivpy2 to pixivpy3](https://github.com/upbit/pixivpy/blob/b1ad6b98/demo.py#L15-L25)\n\n1. Replace `api.papi.*` to `api.*`\n2. Change deprecated SPAI call to Public-API call\n\n```python\nprint(\">>> new ranking_all(mode='daily', page=1, per_page=50)\")\n#rank_list = api.sapi.ranking(\"all\", 'day', 1)\nrank_list = api.ranking_all('daily', 1, 50)\nprint(rank_list)\n\n# more fields about response: https://github.com/upbit/pixivpy/wiki/sniffer\nranking = rank_list.response[0]\nfor img in ranking.works:\n\t# print(img.work)\n\tprint(\"[%s/%s(id=%s)] %s\" % (img.work.user.name, img.work.title, img.work.id, img.work.image_urls.px_480mw))\n```\n\n### About\n\n1. Blog:\n [Pixiv Public-API (OAuth)\u5206\u6790](http://blog.imaou.com/opensource/2014/10/09/pixiv_api_for_ios_update.html)\n\nIf you have any questions, please feel free to contact me: rmusique@gmail.com\n\nFind Pixiv API in **Objective-C**? You might also like\n[**PixivAPI_iOS**](https://github.com/upbit/PixivAPI_iOS)\n\n## API functions\n\n### App-API (6.0 - app-api.pixiv.net)\n\n```python\nclass AppPixivAPI(BasePixivAPI):\n\n # \u8fd4\u56de\u7ffb\u9875\u7528\u53c2\u6570\n def parse_qs(next_url):\n\n # \u7528\u6237\u8be6\u60c5\n def user_detail(user_id):\n\n # \u7528\u6237\u4f5c\u54c1\u5217\u8868\n ## type: [illust, manga]\n def user_illusts(user_id, type=\"illust\"):\n\n # \u7528\u6237\u6536\u85cf\u4f5c\u54c1\u5217\u8868\n # tag: \u4ece user_bookmark_tags_illust \u83b7\u53d6\u7684\u6536\u85cf\u6807\u7b7e\n def user_bookmarks_illust(user_id, restrict=\"public\"):\n\n # \u7528\u6237\u6536\u85cf\u4f5c\u54c1\u5217\u8868\u4e2d\u7684\u5c0f\u8bf4\n def user_bookmarks_novel(user_id, restrict=\"public\"):\n\n def user_related(seed_user_id):\n\n # \u5173\u6ce8\u7528\u6237\u7684\u65b0\u4f5c\n # restrict: [public, private]\n def illust_follow(restrict=\"public\"):\n\n # \u4f5c\u54c1\u8be6\u60c5 (\u7c7b\u4f3cPAPI.works()\uff0ciOS\u4e2d\u672a\u4f7f\u7528)\n def illust_detail(illust_id):\n\n # \u4f5c\u54c1\u8bc4\u8bba\n def illust_comments(illust_id, include_total_comments=None):\n\n # \u76f8\u5173\u4f5c\u54c1\u5217\u8868\n def illust_related(illust_id):\n\n # \u63d2\u753b\u63a8\u8350 (Home - Main)\n # content_type: [illust, manga]\n def illust_recommended(content_type=\"illust\"):\n\n # \u5c0f\u8bf4\u63a8\u8350\n def novel_recommended():\n\n # \u4f5c\u54c1\u6392\u884c\n # mode: [day, week, month, day_male, day_female, week_original, week_rookie, day_manga]\n # date: '2016-08-01'\n # mode (Past): [day, week, month, day_male, day_female, week_original, week_rookie,\n # day_r18, day_male_r18, day_female_r18, week_r18, week_r18g]\n def illust_ranking(mode=\"day\", date=None):\n\n # \u8d8b\u52bf\u6807\u7b7e (Search - tags)\n def trending_tags_illust():\n\n # \u641c\u7d22 (Search)\n # search_target - \u641c\u7d22\u7c7b\u578b\n # partial_match_for_tags - \u6807\u7b7e\u90e8\u5206\u4e00\u81f4\n # exact_match_for_tags - \u6807\u7b7e\u5b8c\u5168\u4e00\u81f4\n # title_and_caption - \u6807\u9898\u8bf4\u660e\u6587\n # sort: [date_desc, date_asc, popular_desc] - popular_desc\u4e3a\u4f1a\u5458\u7684\u70ed\u95e8\u6392\u5e8f\n # duration: [within_last_day, within_last_week, within_last_month]\n # start_date, end_date: '2020-07-01'\n def search_illust(word, search_target=\"partial_match_for_tags\", sort=\"date_desc\", duration=None, start_date=None, end_date=None):\n\n # \u641c\u7d22\u5c0f\u8bf4 (Search Novel)\n # search_target - \u641c\u7d22\u7c7b\u578b\n # partial_match_for_tags - \u6807\u7b7e\u90e8\u5206\u4e00\u81f4\n # exact_match_for_tags - \u6807\u7b7e\u5b8c\u5168\u4e00\u81f4\n # text - \u6b63\u6587\n # keyword - \u5173\u952e\u8bcd\n # sort: [date_desc, date_asc]\n # start_date/end_date: 2020-06-01\n def search_novel(word, search_target=\"partial_match_for_tags\", sort=\"date_desc\", start_date=None, end_date=None):\n\n def search_user(word, sort='date_desc', duration=None):\n\n # \u4f5c\u54c1\u6536\u85cf\u8be6\u60c5\n def illust_bookmark_detail(illust_id):\n\n # \u65b0\u589e\u6536\u85cf\n def illust_bookmark_add(illust_id, restrict=\"public\", tags=None):\n\n # \u5220\u9664\u6536\u85cf\n def illust_bookmark_delete(illust_id):\n\n # \u5173\u6ce8\u7528\u6237\n def user_follow_add(user_id, restrict=\"public\"):\n\n # \u53d6\u6d88\u5173\u6ce8\u7528\u6237\n def user_follow_delete(user_id):\n\n # \u7528\u6237\u6536\u85cf\u6807\u7b7e\u5217\u8868\n def user_bookmark_tags_illust(restrict=\"public\"):\n\n # Following\u7528\u6237\u5217\u8868\n def user_following(user_id, restrict=\"public\"):\n\n # Followers\u7528\u6237\u5217\u8868\n def user_follower(user_id):\n\n # \u597dP\u53cb\n def user_mypixiv(user_id):\n\n # \u9ed1\u540d\u5355\u7528\u6237\n def user_list(user_id):\n\n # \u83b7\u53d6ugoira\u4fe1\u606f\n def ugoira_metadata(illust_id):\n\n # \u7528\u6237\u5c0f\u8bf4\u5217\u8868\n def user_novels(user_id):\n\n # \u5c0f\u8bf4\u7cfb\u5217\u8be6\u60c5\n def novel_series(series_id, last_order=None):\n\n # \u5c0f\u8bf4\u8be6\u60c5\n def novel_detail(novel_id):\n\n # \u5c0f\u8bf4 (\u5305\u542b\u6b63\u6587)\n def webview_novel(novel_id):\n\n # \u5c0f\u8bf4\u8bc4\u8bba\n def novel_comments(novel_id):\n\n # \u5927\u5bb6\u7684\u65b0\u4f5c\n # content_type: [illust, manga]\n def illust_new(content_type=\"illust\", max_illust_id=None):\n\n def novel_new(max_novel_id=None):\n\n # \u7279\u8f91\u8be6\u60c5 (\u65e0\u9700\u767b\u5f55\uff0c\u8c03\u7528Web API)\n def showcase_article(showcase_id):\n```\n\n[Usage](https://github.com/upbit/pixivpy/blob/aec177aa7a1979f7ec4c5bbbeed9085cc256bdbd/demo.py#L306):\n\n```python\naapi = AppPixivAPI()\n\n# \u4f5c\u54c1\u63a8\u8350\njson_result = aapi.illust_recommended()\nprint(json_result)\nillust = json_result.illusts[0]\nprint(\">>> %s, origin url: %s\" % (illust.title, illust.image_urls['large']))\n\n# \u4f5c\u54c1\u76f8\u5173\u63a8\u8350\njson_result = aapi.illust_related(57065990)\nprint(json_result)\nillust = json_result.illusts[0]\nprint(\">>> %s, origin url: %s\" % (illust.title, illust.image_urls['large']))\n\n# \u4f5c\u54c1\u76f8\u5173\u63a8\u8350-\u4e0b\u4e00\u9875 (.parse_qs(next_url) \u7528\u6cd5)\nnext_qs = aapi.parse_qs(json_result.next_url)\njson_result = aapi.illust_related(**next_qs)\nprint(json_result)\nillust = json_result.illusts[0]\nprint(\">>> %s, origin url: %s\" % (illust.title, illust.image_urls['large']))\n\n# \u7528\u6237\u8be6\u60c5\njson_result = aapi.user_detail(660788)\nprint(json_result)\nuser = json_result.user\nprint(\"%s(@%s) region=%s\" % (user.name, user.account, json_result.profile.region))\n\n# \u7528\u6237\u4f5c\u54c1\u5217\u8868\njson_result = aapi.user_illusts(660788)\nprint(json_result)\nillust = json_result.illusts[0]\nprint(\">>> %s, origin url: %s\" % (illust.title, illust.image_urls['large']))\n\n# \u7528\u6237\u6536\u85cf\u5217\u8868\njson_result = aapi.user_bookmarks_illust(2088434)\nprint(json_result)\nillust = json_result.illusts[0]\nprint(\">>> %s, origin url: %s\" % (illust.title, illust.image_urls['large']))\n\n# \u7528\u6237\u6536\u85cf\u5217\u8868\u4e2d\u7684\u5c0f\u8bf4\njson_result = aapi.user_bookmarks_novel(42862448)\nprint(json_result)\nnovel = json_result.novels[0]\nprint(\">>> {}, text_length: {}, series: {}\".format(novel.title, novel.text_length, novel.series))\n\n# 2016-07-15 \u65e5\u7684\u8fc7\u53bb\u4e00\u5468\u6392\u884c\njson_result = aapi.illust_ranking('week', date='2016-07-15')\nprint(json_result)\nillust = json_result.illusts[0]\nprint(\">>> %s, origin url: %s\" % (illust.title, illust.image_urls['large']))\n\n# \u5173\u6ce8\u7528\u6237\u7684\u65b0\u4f5c (\u9700\u8981login)\njson_result = aapi.illust_follow(req_auth=True)\nprint(json_result)\nillust = json_result.illusts[0]\nprint(\">>> %s, origin url: %s\" % (illust.title, illust.image_urls['large']))\n\n# \u6807\u7b7e \"\u6c34\u7740\" \u641c\u7d22\njson_result = aapi.search_illust('\u6c34\u7740', search_target='partial_match_for_tags')\nprint(json_result)\nillust = json_result.illusts[0]\nprint(\">>> %s, origin url: %s\" % (illust.title, illust.image_urls['large']))\n\n# \u7528\u6237 \"gomzi\" \u641c\u7d22\njson_result = aapi.search_user(\"gomzi\")\nprint(json_result)\nillust = json_result.user_previews[0].illusts[0]\nprint(\">>> %s, origin url: %s\" % (illust.title, illust.image_urls['large']))\n\n# \u5c55\u793a\u5c0f\u8bf4\u8bc4\u8bba\u533a\njson_result = aapi.novel_comments(16509454, include_total_comments=True)\nprint(\"Total comments = {}\".format(json_result[\"total_comments\"]))\nfor comment in json_result[\"comments\"]:\n if comment[\"parent_comment\"] != dict():\n print(\"{user} replied to {target} at {time} : {content}\".format(user = comment[\"user\"][\"name\"], time = comment[\"date\"], content = comment[\"comment\"], target = comment[\"parent_comment\"][\"user\"][\"name\"]))\n else:\n print(\"{user} at {time} : {content}\".format(user=comment[\"user\"][\"name\"], time=comment[\"date\"], content=comment[\"comment\"]))\n```\n\n## Package Publishing Instructions\n\nFollow these simple steps to publish your Poetry package. We recommend\npublishing to the [test.pypi.org](https://test.pypi.org/) instance first, to\nverify everything is working as expected.\n\nThis step only has to be done once:\n\n```sh\n# Configure test.pypi.org\npoetry config repositories.testpypi https://test.pypi.org/legacy/\n# Configure API Keys for both PyPI and TestPyPY\npoetry config pypi-token.testpypi <testpypi_api_key>\npoetry config pypi-token.pypi <pypi_api_key>\n```\n\nNow publish the new version:\n\n```sh\n# Adjust the package version at the top of the \"pyproject.toml\" file\nvim pyproject.toml\n# Build python packages to dist/ folder\npoetry build\n# Publish package to TestPyPi\npoetry publish -r testpypi\n# Checkout published package in a different environment\npip install --index-url https://test.pypi.org/simple/ <your_package_name>\n# Once confirmed that everything works, publish to the real PyPi\npoetry publish\n```\n\n## License\n\nFeel free to use, reuse and abuse the code in this project.\n",
"bugtrack_url": null,
"license": "Unlicense",
"summary": "Pixiv API for Python (with 6.x AppAPI supported)",
"version": "3.7.5",
"project_urls": {
"Homepage": "https://github.com/upbit/pixivpy"
},
"split_keywords": [
"pixiv",
"api",
"pixivapi"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "09f08f40168c6e4aa824543d67d17b3104f00c6e9bda53709693c1a0e30e0b72",
"md5": "abfb02c895cc55e2a83da5b82b49ef42",
"sha256": "3f9c3c9236d9924de9f80390cc3d1cc78bc494175a94cc9903f7b60308efca72"
},
"downloads": -1,
"filename": "pixivpy3-3.7.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "abfb02c895cc55e2a83da5b82b49ef42",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 17549,
"upload_time": "2024-03-03T10:09:48",
"upload_time_iso_8601": "2024-03-03T10:09:48.480976Z",
"url": "https://files.pythonhosted.org/packages/09/f0/8f40168c6e4aa824543d67d17b3104f00c6e9bda53709693c1a0e30e0b72/pixivpy3-3.7.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "24194a6798a8552dc5702618e3e340b995de959849704458392f4adbfcd697c8",
"md5": "3b765daeb44124d9202f7c0889823d39",
"sha256": "cfb0c444bea994a9b2c1c01e60f2e8ab1afe57b05f2d51545ef64a7df2f220cc"
},
"downloads": -1,
"filename": "pixivpy3-3.7.5.tar.gz",
"has_sig": false,
"md5_digest": "3b765daeb44124d9202f7c0889823d39",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 20527,
"upload_time": "2024-03-03T10:09:50",
"upload_time_iso_8601": "2024-03-03T10:09:50.747541Z",
"url": "https://files.pythonhosted.org/packages/24/19/4a6798a8552dc5702618e3e340b995de959849704458392f4adbfcd697c8/pixivpy3-3.7.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-03 10:09:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "upbit",
"github_project": "pixivpy",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"lcname": "pixivpy3"
}