Getting Started with the SeatGeek API

Introduction to the SeatGeek API

SeatGeek is an online ticket-booking platform for live events, mainly in the United States and Canada. The SeatGeek API facilitates this booking process by providing a powerful tool for filtering and fetching the vast data for live events from SeatGeek. The API, however, doesn’t support booking or buying tickets through SeatGeek.

The primary purpose of the SeatGeek API is to allow developers to build on top of it to help their users search and find events and, if required, direct those users to the SeatGeek booking page. Developers who are part of the SeatGeek partner program mainly use this API because they receive a payment if any of the directed users buy a ticket through SeatGeek.

Note: The SeatGeek API follows the RESTful API protocol and supports responses in JSON, JSONP, and XML.

API authentication

You first need authorized access when making an API call to use the services of the SeatGeek API. SeatGeek provides a client ID and secret, which allows you to get authorized access to its API.

Generate client credentials

You can get your client credentials from SeatGeek's developer platform. Follow the steps listed below to generate a client credentials:

Save credentials

Here’s how to save the client credentials that you generate throughout the course:

  1. Click the “Edit” button in the following widget.

  2. Paste the client ID in the CLIENT_ID field.

  3. Paste the app secret in the CLIENT_SECRET field.

  4. Click the “Save” button.

As soon as you save the value, the platform will replace it in the widget below:

Press + to interact
// Define client ID and client application secret here
const clientId = '{{CLIENT_ID}}';
const clientSecret = '{{CLIENT_SECRET}}';
// Authenticating credentials here
authenticateCredentials(clientId, clientSecret);

Use the client credentials

You must provide the client credentials in every HTTP request you make to the API. However, you can still be authenticated if you only pass the client ID and an empty string as the client secret. There are two ways to insert client credentials inside the HTTP request. Let’s look at both of these methods.

HTTP basic authentication

One way to provide the client credentials for access authorization is by passing them in the basic authentication tokenThe HTTP Basic Auth token is a token that an HTTP client can use to provide a user identifier and password when making an API request to authenticate themselves., which we pass in the API request. Here's a code example of how to do this when making an HTTP GET request to the events endpoint in JavaScript with basic authentication:

Press + to interact
import fetch from 'node-fetch';
// Define client ID and client application secret here
const clientId = '{{CLIENT_ID}}';
const clientSecret = '{{CLIENT_SECRET}}';
// Creating a basic authentication token using client id and application secret
const basicAuthToken = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
// Define Header Parameters here
const headerParameters = {
authorization: `Basic ${basicAuthToken}`,
};
// Setting API call options
const options = {
method: 'GET',
headers: headerParameters,
};
// Define endpoint url here
const endpointUrl = new URL('https://api.seatgeek.com/2/events');
// Function to make API call
async function authenticationBasicAuth() {
try {
const response = await fetch(endpointUrl, options);
// Custom function for printing list of events
printResponse(response);
} catch (error) {
// Custom function for printing the error message
printError(error);
}
}
// Making API call to authenticate credentials
authenticationBasicAuth();

Take a look at the following explanation of the code above:

  • Lines 4–5: We declare the clientId and clientSecret variables here.

  • Line 8: We encrypt the client credentials with the base64 encoding and save them in the basicAuthToken variable.

  • Line 12: We pass the basicAuthToken variable with encoded client credentials to the authorization header. If the client credentials are valid, SeatGeek will authenticate our request and respond with the requested data.

As a query parameter

Another way to provide the client credentials for access authorization is passing them as a string to additional query parameters called client_id and client_secret. Here's a code example of how to do this when making an HTTP GET request to the events endpoint in JavaScript using a query parameter:

Press + to interact
import fetch from 'node-fetch';
// Define client ID and client application secret here
const clientId = '{{CLIENT_ID}}';
const clientSecret = '{{CLIENT_SECRET}}';
// Setting API call options
const options = {
method: 'GET',
};
// Define Query Parameters here
const queryParameters = new URLSearchParams({
client_id: clientId,
client_secret: clientSecret,
});
// Define endpoint url here
const endpointUrl = new URL('https://api.seatgeek.com/2/events');
endpointUrl.search = queryParameters;
// Function to make API call
async function authenticationBasicAuth() {
try {
const response = await fetch(endpointUrl, options);
// Custom function for printing the API response
printResponse(response);
} catch (error) {
// Custom function for printing the error message
printError(error);
}
}
// Making API call to authenticate credentials
authenticationBasicAuth();

Take a look at the following explanation of the code above:

  • Lines 4–5: We declare the clientId and clientSecret variables here.

  • Lines 14–15: We pass the clientId and clientSecret variables to the client_id and client_secret query parameters, respectively. If the client credentials are valid, SeatGeek will authenticate our request and respond with the requested data.