Skip to content

BookingApi

BookingApi

API for managing OrangeTheory class bookings.

Provides methods to list, create, and cancel bookings, as well as retrieve class schedules and rate completed classes.

get_bookings_new

get_bookings_new(start_date=None, end_date=None, exclude_cancelled=True, remove_duplicates=True)

Get the bookings for the user.

If no dates are provided, it will return all bookings between today and 45 days from now.

Parameters:

Name Type Description Default
start_date datetime | date | str | None

The start date for the bookings. Default is None.

None
end_date datetime | date | str | None

The end date for the bookings. Default is None.

None
exclude_cancelled bool

Whether to exclude cancelled bookings. Default is True.

True
remove_duplicates bool

When True, only keeps the most recent booking for a given class_id. This is helpful to avoid duplicates caused by cancel/rebook scenarios, class changes, etc. Default is True.

True

Returns:

Type Description
list[BookingV2]

list[BookingV2]: The bookings for the user.

Note

Setting exclude_cancelled to False will return all bookings, which may result in multiple bookings for the same class_id. Setting exclude_cancelled to True will prevent this, but has the side effect of not returning any results for a cancelled (and not rebooked) booking. If you want a unique list of bookings that includes cancelled bookings, you should set exclude_cancelled to False and remove_duplicates to True.

Warning

If you do not set either exclude_cancelled or remove_duplicates to True you may receive multiple bookings for the same workout. This will happen if you cancel and rebook or if a class changes, such as from a 2G to a 3G. Apparently the system actually creates a new booking for the new class, which is normally transparent to the user.

get_bookings_new_by_date

get_bookings_new_by_date(start_date=None, end_date=None)

Get the bookings for the user, returned in a dictionary keyed by start datetime.

This is a convenience method that calls get_bookings_new and returns a dictionary instead of a list. Because this returns a dictionary, it will only return the most recent booking for each class_id. It will also include cancelled bookings.

Parameters:

Name Type Description Default
start_date datetime | date | str | None

The start date for the bookings. Default is None.

None
end_date datetime | date | str | None

The end date for the bookings. Default is None.

None

Returns:

Type Description
dict[datetime, BookingV2]

dict[datetime, BookingV2]: A dictionary of bookings keyed by their start datetime.

get_booking_new

get_booking_new(booking_id)

Get a booking by ID from the new bookings endpoint.

Parameters:

Name Type Description Default
booking_id str

The booking ID to get.

required

Returns:

Name Type Description
BookingV2 BookingV2

The booking.

Raises:

Type Description
ValueError

If booking_id is None or empty string.

ResourceNotFoundError

If the booking with the given ID does not exist.

get_classes

get_classes(start_date=None, end_date=None, studio_uuids=None, include_home_studio=True, filters=None)

Get the classes for the user.

Returns a list of classes that are available for the user, based on the studio UUIDs provided. If no studio UUIDs are provided, it will default to the user's home studio.

Parameters:

Name Type Description Default
start_date date | str | None

The start date for the classes. Default is None.

None
end_date date | str | None

The end date for the classes. Default is None.

None
studio_uuids list[str] | None

The studio UUIDs to get the classes for. Default is None, which will default to the user's home studio only.

None
include_home_studio bool | None

Whether to include the home studio in the classes. Default is True.

True
filters list[ClassFilter] | ClassFilter | None

A list of filters to apply to the classes, or a single filter. Filters are applied as an OR operation. Default is None.

None

Returns:

Type Description
list[OtfClass]

list[OtfClass]: The classes for the user.

get_booking

get_booking(booking_uuid)

Get a specific booking by booking_uuid, from the old bookings endpoint.

Parameters:

Name Type Description Default
booking_uuid str

The booking UUID to get.

required

Returns:

Name Type Description
BookingList Booking

The booking.

Raises:

Type Description
ValueError

If booking_uuid is None or empty string.

get_booking_from_class

get_booking_from_class(otf_class)

Get a specific booking by class_uuid or OtfClass object.

Parameters:

Name Type Description Default
otf_class str | OtfClass

The class UUID or the OtfClass object to get the booking for.

required

Returns:

Name Type Description
Booking Booking

The booking.

Raises:

Type Description
ResourceNotFoundError

If the booking does not exist.

ValueError

If class_uuid is None or empty string.

get_booking_from_class_new

get_booking_from_class_new(otf_class)

Get a specific booking by class_uuid or OtfClass object.

Parameters:

Name Type Description Default
otf_class str | OtfClass | BookingV2Class

The class UUID or the OtfClass object to get the booking for.

required

Returns:

Name Type Description
BookingV2 BookingV2

The booking.

Raises:

Type Description
ResourceNotFoundError

If the booking does not exist.

ValueError

If class_uuid is None or empty string.

get_class_from_booking

get_class_from_booking(booking)

Get the class details from a Booking or BookingV2 object.

Parameters:

Name Type Description Default
booking Booking | BookingV2

The booking to get the class details from.

required

Returns:

Name Type Description
OtfClass OtfClass

The class details.

Raises:

Type Description
ValueError

If the booking does not have a class_id.

get_class_from_booking_new

get_class_from_booking_new(booking)

Get the class details from a BookingV2 object.

Parameters:

Name Type Description Default
booking BookingV2

The booking to get the class details from.

required

Returns:

Name Type Description
OtfClass OtfClass

The class details.

Raises:

Type Description
ValueError

If the booking does not have a class_id.

book_class

book_class(otf_class)

Book a class by providing either the class_uuid or the OtfClass object.

Parameters:

Name Type Description Default
otf_class str | OtfClass

The class UUID or the OtfClass object to book.

required

Returns:

Name Type Description
Booking Booking

The booking.

Raises:

Type Description
AlreadyBookedError

If the class is already booked.

OutsideSchedulingWindowError

If the class is outside the scheduling window.

ValueError

If class_uuid is None or empty string.

OtfError

If there is an error booking the class.

book_class_new

book_class_new(class_id)

Book a class by providing either the class_id or the BookingV2Class object.

This uses the new booking endpoint.

Parameters:

Name Type Description Default
class_id str

The class ID to book.

required

Returns:

Name Type Description
BookingV2 BookingV2

The booking.

Raises:

Type Description
OtfError

If there is an error booking the class.

TypeError

If the input is not a string or BookingV2Class.

cancel_booking

cancel_booking(booking)

Cancel a booking by providing either the booking_uuid or the Booking object.

Parameters:

Name Type Description Default
booking str | Booking

The booking UUID or the Booking object to cancel.

required

Raises:

Type Description
TypeError

If booking is not a string or Booking object.

ValueError

If the booking UUID is empty.

ResourceNotFoundError

If the booking does not exist.

cancel_booking_new

cancel_booking_new(booking)

Cancel a booking by providing either the booking_id or the BookingV2 object.

Parameters:

Name Type Description Default
booking str | BookingV2

The booking ID or the BookingV2 object to cancel.

required

Raises:

Type Description
TypeError

If booking is not a string or BookingV2 object.

ResourceNotFoundError

If the booking does not exist.

get_bookings

get_bookings(start_date=None, end_date=None, status=None, exclude_cancelled=True, exclude_checkedin=True)

Get the member's bookings.

If no dates are provided, it will return all bookings between today and 45 days from now.

Parameters:

Name Type Description Default
start_date date | str | None

The start date for the bookings. Default is None.

None
end_date date | str | None

The end date for the bookings. Default is None.

None
status BookingStatus | list[BookingStatus] | None

The status(es) to filter by. Default is None.

None
exclude_cancelled bool

Whether to exclude cancelled bookings. Default is True.

True
exclude_checkedin bool

Whether to exclude checked-in bookings. Default is True.

True

Returns:

Type Description
list[Booking]

list[Booking]: The member's bookings.

Warning

Incorrect statuses do not cause any bad status code, they just return no results.

Tip

CheckedIn - you must provide dates if you want to get bookings with a status of CheckedIn. If you do not provide dates, the endpoint will return no results for this status.

get_historical_bookings

get_historical_bookings()

Get the member's historical bookings.

This will go back 45 days and return all bookings for that time period.

Returns:

Type Description
list[Booking]

list[Booking]: The member's historical bookings.

rate_class

rate_class(class_uuid, performance_summary_id, class_rating, coach_rating)

Rate a class and coach. A simpler method is provided in rate_class_from_workout.

The class rating must be between 0 and 4. 0 is the same as dismissing the prompt to rate the class/coach in the app. 1 through 3 is a range from bad to good.

Parameters:

Name Type Description Default
class_uuid str

The class UUID.

required
performance_summary_id str

The performance summary ID.

required
class_rating int

The class rating. Must be 0, 1, 2, or 3.

required
coach_rating int

The coach rating. Must be 0, 1, 2, or 3.

required

Returns:

Type Description
None

None