Created
June 24, 2025 20:35
-
-
Save lukeyeager/39ded0127bf8c1962e0f900c2919870d to your computer and use it in GitHub Desktop.
tabletop.events - Chupacabracon Attendees
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
import getpass | |
import os | |
import requests | |
def get_all_items(sess, uri, **extra_params): | |
page = 1 | |
while True: | |
r = sess.get(uri, params={'_page_number': page, **extra_params}) | |
r.raise_for_status() | |
result = r.json()['result'] | |
assert int(result['paging']['page_number']) == page, result['paging'] | |
items = result['items'] | |
for item in items: | |
yield item | |
if len(items) == 0: | |
return | |
page = result['paging']['next_page_number'] | |
def main(): | |
p = argparse.ArgumentParser() | |
p.add_argument('api_key') | |
p.add_argument('username') | |
args = p.parse_args() | |
pw = os.environ.get('PASSWORD', None) | |
if pw is None: | |
pw = getpass.getpass(f'Password for "{args.username}": ') | |
sess = requests.Session() | |
r = sess.post( | |
'https://tabletop.events/api/session', | |
data={ | |
'username': args.username, | |
'password': pw, | |
'api_key_id': args.api_key, | |
}, | |
) | |
r.raise_for_status() | |
# session_id = r.json()['result']['id'] | |
conventions = [] | |
for venue in get_all_items(sess, 'https://tabletop.events/api/venue', query='Embassy Suites by Hilton San Marcos'): | |
conventions.extend(get_all_items(sess, f'https://tabletop.events/api/venue/{venue["id"]}/conventions')) | |
conventions = sorted(conventions, key=lambda i: i['start_date']) | |
for convention in conventions: | |
print(convention["name"]) | |
print(f'\tStart date: {convention["start_date"]}') | |
badge_types = get_all_items(sess, f'https://tabletop.events/api/convention/{convention["id"]}/badgetypes') | |
badge_types = sorted(badge_types, key=lambda i: i['sequence_number']) | |
total_avail = 0 | |
total_sold = 0 | |
for badge_type in badge_types: | |
avail = badge_type['max_quantity'] | |
remaining = badge_type['available_quantity'] | |
sold = avail - remaining | |
total_avail += avail | |
total_sold += sold | |
print(f'\tBadges sold: {total_sold} / {total_avail}') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment