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')
Metadata
Release files for untappd 0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| untappd-0.5.tar.gz | 6.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| untappd-0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 kB
Release files / untappd-0.5.tar.gz
| Download URL | untappd-0.5.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9cfca43f2340921c8ffbe473fa15103e5fd3fa46ca35cd8da649e29c9a136b8
|
|
BLAKE2b-256 checksum How to use checksums |
93baddc7157a938b2336e009ce656525ad95f82a9f4654919a55f0e23fdbdc49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.4
|
Release files / untappd-0.5-py3-none-any.whl
| Download URL | untappd-0.5-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e22ea9b60dc1a162f8034758a781f4959bf34cfa42c00f21087f3a0d1fbad24
|
|
BLAKE2b-256 checksum How to use checksums |
1c931cbe220597e429dc471e1388561ca034ef5d4e8f9e34b036e8a16cc902a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.4
|