Demo Application
Learn how Ticketmaster's APIs can be integrated into a real-world application.
We'll cover the following
So far, we've explored the many endpoints provided by the Ticketmaster APIs. Now, we'll integrate those APIs into a real-world application.
- The first page we see when we run the application is the homepage. This page consists of a navigation bar, as well as suggested events, venues, and attractions displayed in the form of cards.
- Each card has a “View Details” button that redirects us to the details page for that specific entity.
- The “Load More…” buttons fetch more suggestions for each entity, rendering them to a new page.
- We can use the search bar in the navbar to search for events, attractions, and so on. To do so we first need to select the type of entity from the drop-down, then enter a search query in the search bar. The search results are then rendered to a search results page.
Integration with Ticketmaster
We've used several of the endpoints we've discussed in this course. These endpoints are being used in the view.py
file:
- Line 11: We invoke the
home
function every time the homepage is accessed. - We use the
resource
andsize
parameters to make a call to the suggest endpoint, and fetch three suggestions each for events, attractions, and venues. We render the suggestions to the application homepage. - Line 28: We invoke the
events
function by clicking the "Load More..." button for events. It makes a call to the events endpoint, which searches for events without any parameters. This search returns twenty events, rendering them to the events page. - Lines 43 and 58: Similarly, we use the
attractions
andvenues
functions to make calls to the attractions and venues endpoints respectively, rendering the results to their respective pages. - Line 73: The
search
function is invoked when a search is made using the search bar. Depending on the type of entity selected from the search drop-down, it makes calls to the events, attractions, or venues endpoints, using the search term as the value for thekeyword
parameter. The search results are rendered to the results page. - We invoke the
search
function when a search is made using the search bar. Depending on the type of entity selected from the search drop-down, we use the search term as the value for thekeyword
parameter to make calls to the events, attractions, or venues endpoints. We render the search results to the results page. - Line 98: We access the details page for the event to invoke the
event_detail
function. It makes a call to the event details endpoint and renders the returned details to the event details page. This function also makes an additional call to the availability endpoint of the Inventory Status API. - Lines 119 and 132: Similarly, the
attraction_detail
andvenue_detail
functions make calls to the attraction details and venue details endpoints, respectively.
Run the application
Click "Run" to run the demo application below.
Note: The widget below only shows the necessary files that show the integration of the Ticketmaster APIs. Other files, such as templates, helper files, and so on, have been hidden.
""" Django settings for example project. Generated by 'django-admin startproject' using Django 4.0.4. For more information on this file, see https://docs.djangoproject.com/en/4.0/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.0/ref/settings/ """ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-q0%6^t7$ioq8f1=^+$a7n20xxg4ks&%$g$qz)9owg_)(ftop+i' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ['{{EDUCATIVE_LIVE_VM_URL}}'.replace('https://','')] CSRF_TRUSTED_ORIGINS = ['{{EDUCATIVE_LIVE_VM_URL}}'] SESSION_COOKIE_SAMESITE = 'None' CSRF_COOKIE_SAMESITE = 'None' CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'ticketmaster' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'example.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'example.wsgi.application' # Database # https://docs.djangoproject.com/en/4.0/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } # Password validation # https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/4.0/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.0/howto/static-files/ STATIC_URL = 'static/' # Default primary key field type # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
The demo application