Search for Attractions

Learn to search for and filter attractions using Ticketmaster's Discovery API.

Attraction search

An attraction is the main person or act of interest in an event, be it a football team in a football match, a singer in a concert, or an actor in a stage play. The Discovery API provides us with the capability to search for and filter attractions through the attractions endpoint.

The URL for this endpoint is:

https://app.ticketmaster.com/discovery/v2/attractions

Like the event search endpoint, we can provide a number of optional parameters to filter the search results. An overview of some of the parameters is given below—you can visit this lesson to see the complete list of parameters:

Parameter

Type

Category

Description

id

string

optional

If provided, the search results are filtered by the attraction ID.

keyword

string

optional

A keyword on which the search is performed.

size

number

optional

The number of results to be returned per page. The default value is 20.

page

number

optional

The page number to be returned. The default value is 0.

sort

string

optional

The sorting order of the search results. Allowable values are, name,asc, name,desc, date,asc, date,desc, relevance,asc, relevance,desc, distance,asc, name,date,asc, name,date,desc, date,name,asc, date,name,desc, distance,date,asc, onSaleStartDate,asc, id,asc, venueName,asc, venueName,desc, random. The default value is relevance,desc.

classificationId

array[string]

optional

If provided, the search results are filtered by classification ID, that is, the ID of any segment, genre, subgenre, type, and subtype. Negative filtering is supported by using the following format '-'. (Negative filters may cause decreased performance.)

The table below gives an overview of the keys of the response object:

Property

Type

Description

_embedded

object

This contains a single property, attractions, that holds the search results in the form of an array of objects, with each object representing one attraction.

_links

object

This contains links to the first, next, and last pages in the search results, as well as the link to the current page.

page

object

This contains information regarding the pages of the search results, including the size of each page, the total number of elements, the total number of pages, and the current page.

The response object returned as the result of a single API call represents a single page of the search results—by default, the first page. We can specify the page we want using the page query parameter or use the links in the _links property to navigate to the next or previous pages of the results.

The actual results of the search are stored within the attractions array in the _embedded property, where each array element represents an attraction. We'll discuss the details of the attraction objects in a later chapter.

Search without parameters

Let's try making an actual call to this endpoint, first with no search parameters, then later with a few of the optional parameters, such as id and keyword.

The code below makes a call to the attractions endpoint, using none of the search parameters:

Press + to interact
import json
import requests
api_key = '{{API_KEY}}'
response = requests.get('https://app.ticketmaster.com/discovery/v2/attractions',
params = {
'apikey' : api_key
}).json()
print(json.dumps(response, indent=4))

This call returns several attractions, sorted in descending order of relevance, with the most relevant attraction at the top.

Search with optional parameters

Let's search with the id and keyword search parameters. A list of several attractions and their respective IDs is given below:

Attraction

ID

Phoenix Suns

K8vZ9171oZf

Los Angeles Lakers

K8vZ91718T0

Boston Red Sox

K8vZ9171okf

The Weeknd

K8vZ9172Ln7

Atif Aslam

K8vZ917GGnf

Backstreet Boys

K8vZ91719tf

Try replacing the value of the attraction_id and keyword variables on lines 5 and 6 with any pair from the table above and click the "Run" button:

Press + to interact
import json
import requests
api_key = '{{API_KEY}}'
attraction_id = 'K8vZ9171oZf'
keyword = 'Phoenix Suns'
response = requests.get('https://app.ticketmaster.com/discovery/v2/attractions',
params = {
'apikey' : api_key,
'id' : attraction_id,
'keyword' : keyword
}).json()
print(json.dumps(response, indent=4))

Since attraction IDs are unique, we would get a single search result for any ID-name pair from the table above. We can confirm this by checking the page property of the response object, where the value of totalElements is 1.