framework created to use the API provided by the online game Hattrick
Project description
pyCHPP
pyCHPP is an object-oriented python framework created to use the API provided by the online game Hattrick (www.hattrick.org).
Installation
pyCHPP can be installed using pip :
pip install pychpp
Usage
First connection
from pychpp import CHPP
# Set consumer_key and consumer_secret provided for your app by Hattrick
consumer_key = ''
consumer_secret = ''
# Initialize CHPP instance
chpp = CHPP(consumer_key, consumer_secret)
# Get url, request_token and request_token_secret to request API access
# You can set callback_url and scope
auth = chpp.get_auth(callback_url="www.mycallbackurl.com", scope="")
# auth['url'] contains the url to which the user can grant the application
# access to the Hattrick API
# Once the user has entered their credentials,
# a code is returned by Hattrick (directly or to the given callback url)
code = ""
# Get access token from Hattrick
# access_token['key'] and access_token['secret'] have to be stored
# in order to be used later by the app
access_token = chpp.get_access_token(
request_token=auth["request_token"],
request_token_secret=auth["request_token_secret"],
code=code,
)
Further connections
# Once you have obtained access_token for a user
# You can use it to call Hattrick API
chpp = CHPP(consumer_key,
consumer_secret,
access_token['key'],
access_token['secret'],
)
# Now you can use chpp methods to get datas from Hattrick API
# For example :
current_user = chpp.user()
all_teams = current_user.teams
best_team_ever = chpp.team(ht_id=1165592)
best_team_ever # <HTTeam object : Les Poitevins de La Chapelle (1165592)>
best_team_arena = best_team_ever.arena
best_team_arena # <HTArena object : Stade de La Chapelle (1162154)>
best_team_arena.name # 'Stade de La Chapelle'
worth_team_ever = chpp.team(ht_id=1750803)
worth_team_ever # <HTTeam object : Capdenaguet (1750803)>
player = chpp.player(ht_id=6993859)
player # <HTPlayer object : Pedro Zurita (6993859)>
player.career_goals # 1163
match = chpp.match(ht_id=68599186)
match # <HTMatch object : Skou United - FC Barentin (68599186)>
match.date # datetime.datetime(2006, 2, 23, 20, 0)
License
pyCHPP is licensed under the Apache License 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pychpp-0.2.2.tar.gz
(21.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pychpp-0.2.2-py3-none-any.whl
(27.3 kB
view details)
File details
Details for the file pychpp-0.2.2.tar.gz.
File metadata
- Download URL: pychpp-0.2.2.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.0 CPython/3.6.9 Linux/5.3.0-51-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99c32b72f4981a25bd56ba817baa21e7bd010cecf61e4bed67bfa23e28286f50
|
|
| MD5 |
2d5321009b6a7e158e00326a9c3b2d98
|
|
| BLAKE2b-256 |
fbd95b3f587324f51343e2feeea61eb6ba1c5ea2f7c0f33aa1b8ce20a6fd2fa7
|
File details
Details for the file pychpp-0.2.2-py3-none-any.whl.
File metadata
- Download URL: pychpp-0.2.2-py3-none-any.whl
- Upload date:
- Size: 27.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.0 CPython/3.6.9 Linux/5.3.0-51-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50895ae5da28971c568ef12220413d302792c65bd3f0bc4203bf905e374c6db7
|
|
| MD5 |
381e626c0eed19804d0bf0758117d499
|
|
| BLAKE2b-256 |
04aad67e269087c6ff54c311bf0bb08f0b98de78c950049d23081368164377cd
|