Searching for Events

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

Event search

The purpose of the Discovery API is—as the name implies—to discover events, venues, attractions, and so on. We can use the events endpoint of the Discovery API to search for and filter events based on different criteria.

The URL for this endpoint is:

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

Request parameters

We can provide multiple optional parameters to filter the search results. A few of these parameters and their uses are mentioned below. You can visit this lesson to see the complete list.

Parameter

Type

Category

Description

id

string

optional

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

keyword

string

optional

This is a keyword on which the search is performed.

attractionId

string

optional

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

venueId

string

optional

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

startDateTime

string

optional

If provided, the search results are filtered to return events with a start date after this date.

endDateTime

string

optional

If provided, the search results are filtered to return events with a start date before this date.

size

number

optional

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

page

number

optional

This is the page of search results to be returned. The default value is 0.

sort

string

optional

This is 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, or subtype. Negative filtering is supported with this format: -. Negative filters may cause decreased performance.

Let's try making an actual call to this endpoint, first with no search parameters. Later we'll make a call with a few of the optional parameters, such as size and id.

The code below makes a call to the events endpoint, using none of the optional parameters. If you haven't yet, provide your API key below before running the code.

Press + to interact
// Importing the required libraries
import fetch from "node-fetch";
// Defining the events endpoint URL
const endpointUrl = new URL("https://app.ticketmaster.com/discovery/v2/events");
// Defining the query parameters
const queryParameters = new URLSearchParams({
apikey: "{{API_KEY}}",
});
// Setting the API call options
const options = {
method: "GET",
};
// Defining the function to make the API call and search for events
async function searchForEvents() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
printResponse(response);
} catch (error) {
printError(error);
}
}
// Calling function to search for events
searchForEvents();

Here is the explanation for the code above:

  • Line 2: We import the node-fetch library. ...