Skip to main content

A python-based bot for automatic resasports slot booking

Project description

No queues. Just gains.

Logo

Release Build status codecov Activity License Documentation Contributor Covenant Downloads

PySportBot empowers you to programmatically book fitness classes at any sports center that uses the Resasports booking management software.

Install

pip install pysportbot

Quick Start

from pysportbot import SportBot

# Create bot instance, will list available centres if requested
bot = SportBot(log_level='INFO', print_centres=False, time_zone = 'Europe/Madrid')

# Connect to service with email and password as well as the name of the centre
bot.login('email', 'password', 'centre')

# List available activites
bot.activities(limit = 10)

# List bookable slots for an activity on a specific day
bot.daily_slots(activity='YourFavouriteGymClass', day = '2025-01-03', limit = 10)

# Book an activity slot on a specific day and time
bot.book(activity='YourFavouriteGymClass', start_time = '2024-12-30 07:00:00')

# Cancel an activity slot on a specific day and time
bot.cancel(activity='YourFavouriteGymClass', start_time = '2024-12-30 07:00:00')

Advanced usage as service

You can easily run pysportbot as a service to manage your bookings automatically with

python -m pysportbot.service --config config.json

The service requires a json configuration file that specifies your user data and how you would like to book your classes. Currently, two types of configuration are supported:

1. Book an upcoming class now

Let's say you would like to book Yoga next Monday at 18:00:00, then your config.json would look like:

{
    "email": "your-email",
    "password": "your-password",
    "center": "your-gym-name",
    "booking_execution": "now",

    "classes": [
        {
            "activity": "Yoga",
            "class_day": "Monday",
            "class_time": "18:00:00",
        }
    ]
}

2. Book an upcoming class on a specific day and time

Let's say you would like to book Yoga next Monday at 18:00:00, but the execution of the booking should only happen on Friday at 07:30:00 then your config.json would look like:

{
    "email": "your-email",
    "password": "your-password",
    "center": "your-gym-name",
    "booking_execution": "Friday 07:30:00",

    "classes": [
        {
            "activity": "Yoga",
            "class_day": "Monday",
            "class_time": "18:00:00",
        }
    ]
}

Note:

  1. Bookings are always scheduled for the following week. For example, if your booking execution is set for Friday at 07:30:00 and your class is on Friday at 18:00:00, the system will schedule the booking for next Friday at 18:00:00, not the same day.
  2. PySportBot automatically attempts to execute up to N bookings in parallel, where N corresponds to the number of available CPU cores on your machine.
  3. If the number of bookings exceeds the available parallel slots, they will be processed sequentially in the exact order specified in your JSON configuration file.

The service also provides various other options that can be inspected with

python -m pysportbot.service --help

Currently supported options include:

  1. --booking-delay: sets a global delay in seconds before booking execution [default: 0]
  2. --retry-attempts: sets the number of retries attempted in case a booking attempt fails [default: 3]
  3. --retry-delay: sets the delay in seconds between booking retries [default: 5]
  4. --time-zone: sets the time zone for the service [default: Europe/Madrid]
  5. --log-level: sets the log-level of the service [default: INFO]
  6. --max-threads: limits the number of used threads for parallel bookings [default: -1]

Automating Weekly Bookings with GitHub Actions

While you can use PySportBot as a continuously running service, doing so often becomes cumbersome because it requires a server (or similar machine) that is always online.

Using GitHub Actions is one of the most reliable ways to schedule automated weekly bookings. With a simple workflow file, you can ensure your bookings run at a specific time each week — no manual intervention required.

For example, if you have a Yoga class on Monday at 18:00:00, and you want the booking to be executed on Friday at 07:30:00, you can automate the process by configuring a GitHub Actions workflow. Below is a sample workflow file that triggers every Friday at 06:00 UTC (07:00 CET), ensuring there is enough time before the actual booking execution at 07:30:00:

name: Weekly Booking

on:
  # Runs at 05:00 UTC (07:00 Madrid time during daylight saving time) on Fridays
  # Note: Update to '0 6 * * 5' for winter (standard) time when Madrid shifts to UTC+1
  # GitHub Actions cron expressions are always in UTC and do not support time zones
  # Reference: https://github.com/orgs/community/discussions/13454
  schedule:
    - cron: '0 5 * * 5'

jobs:
  book:
    runs-on: ubuntu-latest

    steps:
      - name: Check out repository
        uses: actions/checkout@v5

      - name: Set up Python 3.12
        uses: actions/setup-python@v6
        with:
          python-version: '3.12'

      - name: Install pysportbot
        run: |
          pip install pysportbot

      - name: Create config file
        run: |
          echo '{
            "email": "your-email",
            "password": "your-password",
            "centre": "your-gym",
            "booking_execution": "Friday 07:30:00",
            "classes": [
              {
                "activity": "Yoga",
                "class_day": "Monday",
                "class_time": "18:00:00"
              }
            ]
          }' > config.json

      - name: Run pysportbot
        run: |
          python -m pysportbot.service --config config.json --log-level INFO --booking-delay 1 --retry-attempts 3 --retry-delay 5

Note: Make sure the workflow starts early enough — before your booking execution time (e.g., 07:30 CET) — to allow for potential delays in job startup or execution.

LICENSE

pysportbot is free of use and open-source. All versions are published under the MIT License.

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

pysportbot-0.0.20.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

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

pysportbot-0.0.20-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file pysportbot-0.0.20.tar.gz.

File metadata

  • Download URL: pysportbot-0.0.20.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/6.11.0-1018-azure

File hashes

Hashes for pysportbot-0.0.20.tar.gz
Algorithm Hash digest
SHA256 68ed57a0bbb2e1c362977d8c6233162ec01c7106111e881a704a461d9ba02a06
MD5 999fb8e0f26a0537110b5693f31f985e
BLAKE2b-256 c50a34d5ee191adf07b30a74fbdfb6c6a47d31c02a9ecc5220c46fab1d41e6e8

See more details on using hashes here.

File details

Details for the file pysportbot-0.0.20-py3-none-any.whl.

File metadata

  • Download URL: pysportbot-0.0.20-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/6.11.0-1018-azure

File hashes

Hashes for pysportbot-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 25afd35a99a7009190023beb178314e36ab8104432475b0702396bd1705e5a2f
MD5 1562751e2e602f6af462b500e7850348
BLAKE2b-256 908450c557565adac15667dd65a8df014fae6a0180eae476d8b87f1f40248203

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