Skip to main content
# dmm_search3

[![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat)](https://github.com/0x0u/dmm/blob/master/LICENSE.txt)
[![Build Status](https://travis-ci.org/0x0u/dmm_search3.svg?branch=master)](https://travis-ci.org/0x0u/dmm_search3)
[![Requirements Status](https://requires.io/github/0x0u/dmm_search3/requirements.svg?branch=master)](https://requires.io/github/0x0u/dmm_search3/requirements/?branch=master)

https://pypi.org/project/dmm-search3/

## dmm_search3 is 何
[DMM Webサービス](https://affiliate.dmm.com/api/)をPythonで扱うためのライブラリです。[コチラ](https://affiliate.dmm.com/api/regist_guide/)からアカウントを作成して、API IDとアフィリエイトIDを取得しておく必要があります。

## インストール
pipでインストールします。
```
$ pip3 install dmm_search3
```

## 使い方
#### モジュールのインポート
```Python
from dmm import DMM
```

#### 取得したAPI IDとアフィリエイトIDをセット
```Python
api_id = 'your_api_id'
affiliate_id = 'your_affiliate_id'
```

#### インスタンスの作成
```Python
dmm = DMM(api_id=api_id, affiliate_id=affiliate_id)
```

#### 検索(search)メソッド
```Python
dmm.search('ItemList', keyword='バレンタイン', hits=5, offset=10, sort='review')
```

検索メソッドの第一引数は、ItemList(商品検索)、FloorList(フロア検索)、ActressSearch(女優検索)、GenreSearch(ジャンル検索)、MakerSearch(メーカー検索)、SeriesSearch(シリーズ検索)、AuthorSearch(作者検索)のいずれかを指定します。第二引数以降は[APIリファレンス](https://affiliate.dmm.com/api/v3/itemlist.html)のリクエストパラメータを指定します。可変長引数で受け取るので、`keyword='バレンタイン'`のように明示的にキーワードと値を指定します。必須パラメーターである`api_id`、`affiliate_id`はインスタンス作成時、`site`はデフォルトで'FANZA'に設定してあります。

#### 商品検索の例
```Python
items = dmm.search('ItemList', keyword='バレンタイン', hits=9)
for i in items['items']:
print(i.get('title'))

# => バレンタイン・ゲーム(単話)
# 落合くんの半減(単話)
# オトメ錬金術(単話)
# アクションピザッツ 2016年4月号
# コミックホットミルク 2016年03月号
# comicアンスリウム Vol.35
# すぺしゃるでこれーしょん(単話)
# とっぴんぐえんじぇるず(単話)
# チョコはおまけで(単話)
```

レスポンスに関しても[APIリファレンス](https://affiliate.dmm.com/api/v3/itemlist.html)のレスポンスフィールドを参照してください。

## searchメソッド引数
#### 第一引数

|論理名|物理名|APIリファレンス|
|:--:|:--:|:--:|
|商品検索|ItemList|https://affiliate.dmm.com/api/v3/itemlist.html
|フロア検索|FloorList|https://affiliate.dmm.com/api/v3/floorlist.html
|女優検索|ActressSearch|https://affiliate.dmm.com/api/v3/actresssearch.html
|ジャンル検索|GenreSearch|https://affiliate.dmm.com/api/v3/genresearch.html
|メーカー検索|MakerSearch|https://affiliate.dmm.com/api/v3/makersearch.html
|シリーズ検索|SeriesSearch|https://affiliate.dmm.com/api/v3/seriessearch.html
|作者検索|AuthorSearch|https://affiliate.dmm.com/api/v3/authorsearch.html

#### 第二引数以降(商品検索のリクエストパラメーター引用)

|論理名|物理名|必須|値のサンプル|概要|
|:--|:--|:--|:--|:--|
|APIID|api_id|○||登録時に割り振られたID|
|アフィリエイトID|affiliate_id|○|affiliate-990|登録時に割り振られた990|
|サイト|site|○|FANZA|一般(DMM.com)かアダルト(FANZA)か|
|サービス|service||digital|フロアAPIから取得できるサービスコードを指定|
|フロア|floor||videoa|フロアAPIから取得できるフロアコードを指定|
|取得件数|hits||20|初期値:20 最大:100|
|検索開始位置|offset||1|初期値:1 最大:50000|
|ソート順|sort||rank|初期値:rank<br>人気:rank<br>価格が高い:pric<br>価格が安い順:-price<br>新着:date<br>評価:review|
|キーワード|keyword||上原亜衣|UTF-8で指定|
|商品ID|cid||15dss00145|商品に振られているcontent_id
|絞りこみ項目|article||actress|女優:actress<br>作者:author<br>ジャンル:genre<br>シリーズ:series<br>メーカー:maker
|絞り込みID|article_id||1011199|上記絞り込み項目のID(各検索APIから取得可能)|
|発売日絞り込み|gte_date||2016-04-01T00:00:00|このパラメータで指定した日付以降に発売された商品を絞り込むことができます。ISO8601形式でフォーマットした日付を指定してください。(ただし、タイムゾーンは指定できません)
|在庫絞り込み|mono_stock||mono|初期値:絞り込みなし<br>在庫あり:stock<br>予約受付中:reserve<br>DMM通販のみ:mono<br>マーケットプレイスのみ:dmp<br>※通販サービスのみ指定可能
|出力形式|output||json|json / xml|
|コールバック|callback||callback|出力形式jsonで指定した場合に、このパラメータでコールバック関数名を指定すると、JSONP形式で出力されます

## License
MIT
https://github.com/0x0u/dmm_search3/blob/master/LICENSE.txt

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dmm_search3-1.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dmm_search3-1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file dmm_search3-1.1.tar.gz.

File metadata

  • Download URL: dmm_search3-1.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.2

File hashes

Hashes for dmm_search3-1.1.tar.gz
Algorithm Hash digest
SHA256 3d38c040e85b41fcc11563e10dc2c9d2a05665fdd7017cbc76412221fdac69a5
MD5 de6947e4557ea5bb2e11232e4eae77da
BLAKE2b-256 7f0a061799917fd1638d7192c0d462341f7a1541262f5d32254cd08d4b2993cf

See more details on using hashes here.

File details

Details for the file dmm_search3-1.1-py3-none-any.whl.

File metadata

  • Download URL: dmm_search3-1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.2

File hashes

Hashes for dmm_search3-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52afb92166d2482f5143a3fae9c036897ebc62ca3311e9d26facf8fa7b94a787
MD5 8bd3bc1af8599fe8d4772d835b1e1a79
BLAKE2b-256 b6bade1d9ffc2bd1ed2491f58fb364f5d552abb1504bb6a3fa9a8b1392b656af

See more details on using hashes here.

Release history Release notifications | RSS feed

2.3

1 file

2.2

1 file

2.1

1 file

2.0

1 file

1.2.1

1 file

1.2

2 files

This release

1.1 This release

2 files

1.0

2 files

0.3

1 file

0.2

1 file

0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page