Skip to main content

getShowtimesForMovie()

Get all future showtimes for a specific movie, including cinema details. Results are ordered by start time.

Parameters

movieId
number
required
The unique identifier of the movie

Returns

showtimes
Promise<Array<Showtime & { cinema: Cinema }>>
Array of showtime objects with embedded cinema data

Example

import { getShowtimesForMovie } from '@/lib/queries';

const showtimes = await getShowtimesForMovie(123);

showtimes.forEach((showtime) => {
  console.log(`${showtime.cinema.name} - ${showtime.start_time}`);
  console.log(`Screen: ${showtime.screen_type}`);
  if (showtime.movie_url) {
    console.log(`Book: ${showtime.movie_url}`);
  }
});

Implementation

Uses Supabase to join showtimes with cinema data and filter for future times:
const now = new Date().toISOString();

const { data, error } = await supabase
  .from('showtimes')
  .select(`
    *,
    cinema:cinemas(*)
  `)
  .eq('movie_id', movieId)
  .gte('start_time', now)
  .order('start_time');

getShowtimesForCinema()

Get all future showtimes for a specific cinema, including movie details. Results are ordered by start time.

Parameters

cinemaId
number
required
The unique identifier of the cinema

Returns

showtimes
Promise<Array<Showtime & { movie: Movie }>>
Array of showtime objects with embedded movie data

Example

import { getShowtimesForCinema } from '@/lib/queries';

const showtimes = await getShowtimesForCinema(5);

showtimes.forEach((showtime) => {
  console.log(`${showtime.movie.title} - ${showtime.start_time}`);
  console.log(`Screen: ${showtime.screen_type}`);
  if (showtime.movie_url) {
    console.log(`Book: ${showtime.movie_url}`);
  }
});

Implementation

Uses Supabase to join showtimes with movie data and filter for future times:
const now = new Date().toISOString();

const { data, error } = await supabase
  .from('showtimes')
  .select(`
    *,
    movie:movies(*)
  `)
  .eq('cinema_id', cinemaId)
  .gte('start_time', now)
  .order('start_time');

Working with Showtimes

Date Filtering

Both showtime query functions automatically filter for future showtimes by comparing against the current timestamp:
const now = new Date().toISOString();
// Only returns showtimes where start_time >= now
The movie_url field contains direct links to cinema booking pages when available:
const showtimes = await getShowtimesForMovie(movieId);

const bookableShowtimes = showtimes.filter(st => st.movie_url);
// Redirect user to booking page
window.location.href = bookableShowtimes[0].movie_url;

Screen Types

The screen_type field indicates the viewing format. Common values include:
  • “Standard” - Regular screening
  • “IMAX” - Large format screen
  • “3D” - Three-dimensional presentation
  • “4DX” - Motion seats and environmental effects
  • “Dolby Cinema” - Enhanced audio/visual
const iMaxShowtimes = showtimes.filter(
  st => st.screen_type.includes('IMAX')
);

Build docs developers (and LLMs) love