Skip to main content

A simple wrapper for multiple tokens of multiple APIs

Project description

Build Status Downloads Latest Version Supported Python versions Development Status Download format License

About

APIs usually require access tokens to limit frequencies of requests.

If you want to request over limitations, you need to generate multiple tokens and roop over them.

Capybara is a simple wrapper for multiple tokens.

Dependencies

Installation

pip install capybara

or

pip install git+https@github.com:AkihikoITOH/capybara.git

Available Services

Send Pull Requests to add services!

Amazon

Wrapper of Amazon Product Advertising API.

楽天

Wrapper of 楽天商品検索API.

Usage

import capybara

c = capybara.Capybara(config_dir='/path/to/config/', tokens_dir='/path/to/tokens/')

# Amazon
result = c.get(service='amazon', item='B005CSYH5Y')
print result['raw']
print result['title']
print result['category']

# 楽天
result = c.get(service='rakuten', item='urutoragion:10000866')
print result['raw']
print result['title']
print result['url']
print result['category_id']
print result['category']

Setup

anywhere/you/like
   ├── config
   │   ├── amazon_config.json
   │   └── rakuten_config.json
   └── tokens
       ├── amazon_tokens.tsv
       └── rakuten_tokens.tsv

config directory

Set access frequency or other configurations in JSON format for each service.

attribute

type

description

example

interval

integer

interval time between requests per token (in milli second)

1000

slow

float

extension ratio of interval

1.2

path/to/config/sample_config.json

{
    "interval": 1000,
    "slow": 1.2
}

Note: Attributes must be in lower cases and “double quoted”.

Note

  • Actual interval time per token will be [interval]*[slow]

  • Thus actual access frequency(per hour) will be [# of tokens]*3600/[interval]*[slow]

tokens directory

List access tokens and other required parameters in TSV format for each service.

See Product Advertising API to get new access tokens.

Amazon

parameter

description

ACCESS_KEY

access key

SECRET_KEY

secret key

ASSOC_TAG

associate tag

LOCALE

locale

path/to/tokens/amazon_tokens.tsv

ACCESS_KEY1 SECRET_KEY1 ASSOC_TAG1  LOCALE
ACCESS_KEY2 SECRET_KEY2 ASSOC_TAG2  LOCALE
ACCESS_KEY3 SECRET_KEY3 ASSOC_TAG3  LOCALE
ACCESS_KEY4 SECRET_KEY4 ASSOC_TAG4  LOCALE

楽天

See 楽天商品検索API to get new access tokens.

parameter

description

applicationId

application id

lib/tokens/rakuten_tokens.tsv

applicationId1
applicationId2
applicationId3
applicationId4

License

Copyright &copy 2015 ITOH Akihiko

See LICENSE for details.

Project details


Download files

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

Source Distribution

capybara-0.1.6.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

capybara-0.1.6-py2.py3-none-any.whl (10.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file capybara-0.1.6.tar.gz.

File metadata

  • Download URL: capybara-0.1.6.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for capybara-0.1.6.tar.gz
Algorithm Hash digest
SHA256 218c2500256b843dc0c32bd6cc089c521385dfe825a54f3cbfb71ce8ff448720
MD5 77dc72c4849ca5faa68f29ffc04b9156
BLAKE2b-256 7b80f543efa92b80c4e7eb3b74aa0387c777f6327733dbcba6b4e10f1476b83a

See more details on using hashes here.

File details

Details for the file capybara-0.1.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for capybara-0.1.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a531ddd67b0df5e52fe4f1931f400cb2fd4d3df1d5a60c3bfd93448bb077b55e
MD5 750f047aa64aed6b0378e0ab6a2e2ea4
BLAKE2b-256 f4b9fb2752b95a303ee16c203e05e8b3e7bcc5265bf2754421fe75597475909a

See more details on using hashes here.

Supported by

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