Untappd wrapper library
Project description
untappd-python
Python wrapper for the Untappd v4 API. Developed to power No Gluten Beer.
Based almost entirely on the excellent foursquare.
Installation
pip install untappd
Usage
# Construct the client object (user_agent is optional, at least 'authorize' endpoint responds with 'HTTP 429 Too Many Requests' to default User-Agent header string like 'python-requests/2.24.0')
client = untappd.Untappd(client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', redirect_url='YOUR_REDIRECT_URL', user_agent='letmein')
Authentication
For endpoints that access a user's data, you must obtain an access token before you can request data from the API:
# Build the authorization url for your app
auth_url = client.oauth.get_auth_url()
Redirect your user to the address auth_url and let them authorize your app. They will then be redirected to your redirect_url, with a query paramater of code=XX_CODE_RETURNED_IN_REDIRECT_XX. In your webserver, parse out the code value, and use it to call client.oauth.get_access_token()
# Interrogate Untappd to get the user's access_token
access_token = client.oauth.get_access_token('XX_CODE_RETURNED_IN_REDIRECT_XX')
# Apply the returned access token to the client
client.set_access_token(access_token)
# Grab authenticated data
user = client.user.info()
Making Requests
Making requests to the Untappd API is simple. This wrapper mirrors the API endpoint structure detailed in the documentation. For example, the Activity Feed endpoint is /v4/checkin/recent so you can pull data from this endpoint like this:
activity_feed = client.checkin.recent()
You can send parameters using keyword arguments:
activity_feed = client.checkin.recent(min_id=10, limit=50)
For endpoints that require a parameter in the endpoint URL, like Brewery Info (/v4/brewery/info/BREWERY_ID), you include that parameter as the first argument in your request:
brewery_info = client.brewery.info('BREWERY_ID')
Any additional parameters you want to include should be keyword arguments:
brewery_info = client.brewery.info('BREWERY_ID', compact='true')
If the endpoint URL has three components, like Add to Wish List (/v4/user/wishlist/add), you must separate the second and third component with an underscore:
result = client.user.wishlist_add(bid='BEER_ID')
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
Built Distribution
File details
Details for the file untappd-0.5.tar.gz
.
File metadata
- Download URL: untappd-0.5.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9cfca43f2340921c8ffbe473fa15103e5fd3fa46ca35cd8da649e29c9a136b8 |
|
MD5 | 159b02a495a2c6f49c69c1dee3a0ba05 |
|
BLAKE2b-256 | 93baddc7157a938b2336e009ce656525ad95f82a9f4654919a55f0e23fdbdc49 |
File details
Details for the file untappd-0.5-py3-none-any.whl
.
File metadata
- Download URL: untappd-0.5-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e22ea9b60dc1a162f8034758a781f4959bf34cfa42c00f21087f3a0d1fbad24 |
|
MD5 | 20ce059def73594514e11cffe4b53eef |
|
BLAKE2b-256 | 1c931cbe220597e429dc471e1388561ca034ef5d4e8f9e34b036e8a16cc902a2 |