Introducing the Forecasts API — Event-driven forecasts for precise demand planning. Fast, accurate, and easy to run.
Explore Now
LogoLogo
Visit websiteWebAppGet DemoTry for Free
  • Introduction
  • Swagger UI
  • Loop
  • System Status
  • Getting Started
    • API Quickstart
    • Data Science Notebooks
    • PredictHQ Data
      • Data Accuracy
      • Event Categories
        • Attendance-Based Events
        • Non-Attendance-Based Events
        • Unscheduled Events
        • Live TV Events
      • Labels
      • Entities
      • Ranks
        • PHQ Rank
        • Local Rank
        • Aviation Rank
      • Predicted Attendance
      • Predicted End Times
      • Predicted Event Spend
      • Predicted Events
      • Predicted Impact Patterns
    • Guides
      • Geolocation Guides
        • Overview
        • Searching by Location
          • Find Events by Latitude/Longitude and Radius
          • Find Events by Place ID
          • Find Events by IATA Code
          • Find Events by Country Code
          • Find Events by Placekey
          • Working with Location-Based Subscriptions
        • Understanding Place Hierarchies
        • Working with Polygons
        • Join Events using Placekey
      • Date and Time Guides
        • Working with Recurring Events
        • Working with Multi-day and Umbrella Events
        • Working with Dates, Times and Timezones
      • Events API Guides
        • Understanding Relevance Field in Event Results
        • Attendance-Based Events Notebooks
        • Non-Attendance-Based Events Notebooks
        • Severe Weather Events Notebooks
        • Academic Events Notebooks
        • Working with Venues Notebook
      • Features API Guides
        • Increase Accuracy with the Features API
        • Get ML Features
        • Demand Forecasting with Event Features
      • Forecasts API Guides
        • Getting Started with Forecasts API
        • Understanding Forecast Accuracy Metrics
        • Troubleshooting Guide for Forecasts API
      • Live TV Event Guides
        • Find Broadcasts by County Place ID
        • Find Broadcasts by Latitude and Longitude
        • Find all Broadcasts for an Event
        • Find Broadcasts for Specific Sport Types
        • Aggregating Live TV Events
        • Live TV Events Notebooks
      • Beam Guides
        • ML Features by Location
        • ML Features by Group
      • Demand Surge API Guides
        • Demand Surge Notebook
      • Guide to Protecting PredictHQ Data
      • Streamlit Demo Apps
      • Guide to Bulk Export Data via the WebApp
      • Industry-Specific Event Filters
      • Tutorials
        • Filtering and Finding Relevant Events
        • Improving Demand Forecasting Models with Event Features
        • Using Event Data in Power BI
        • Using Event Data in Tableau
        • Connecting to PredictHQ APIs with Microsoft Excel
        • Loading Event Data into a Data Warehouse
        • Displaying Events in a Heatmap Calendar
        • Displaying Events on a Map
    • Tutorials by Use Case
      • Demand Forecasting with ML Models
      • Dynamic Pricing
      • Inventory Management
      • Workforce Optimization
      • Visualization and Insights
  • Integrations
    • Integration Guides
      • Keep Data Updated via API
      • Integrate with Beam
      • Integrate with Loop Links
    • Third-Party Integrations
      • Receive Data via Snowflake
        • Example SQL Queries for Snowflake
        • Snowflake Data Science Guide
          • Snowpark Method Guide
          • SQL Method Guide
      • Receive Data via AWS Data Exchange
        • CSV/Parquet Data Structure for ADX
        • NDJSON Data Structure for ADX
      • Integrate with Databricks
      • Integrate with Tableau
      • Integrate with a Demand Forecast in PowerBI
      • Google Cloud BigQuery
    • PredictHQ SDKs
      • Python SDK
      • Javascript SDK
  • API Reference
    • API Overview
      • Authenticating
      • API Specs
      • Rate Limits
      • Pagination
      • API Changes
      • Attribution
      • Troubleshooting
    • Events
      • Search Events
      • Get Event Counts
    • Broadcasts
      • Search Broadcasts
      • Get Broadcasts Count
    • Features
      • Get ML Features
    • Forecasts
      • Models
        • Create Model
        • Update Model
        • Replace Model
        • Delete Model
        • Search Models
        • Get Model
        • Train Model
      • Demand Data
        • Upload Demand Data
        • Get Demand Data
      • Forecasts
        • Get Forecast
      • Algorithms
        • Get Algorithms
    • Beam
      • Create an Analysis
      • Upload Demand Data
      • Search Analyses
      • Get an Analysis
      • Update an Analysis
      • Partially Update an Analysis
      • Get Correlation Results
      • Get Feature Importance
      • Refresh an Analysis
      • Delete an Analysis
      • Analysis Groups
        • Create an Analysis Group
        • Get an Analysis Group
        • Search Analysis Groups
        • Update an Analysis Group
        • Partially Update an Analysis Group
        • Refresh an Analysis Group
        • Delete an Analysis Group
        • Get Feature Importance for an Analysis Group
    • Demand Surge
      • Get Demand Surges
    • Suggested Radius
      • Get Suggested Radius
    • Saved Locations
      • Create a Saved Location
      • Search Saved Locations
      • Get a Saved Location
      • Search Events for a Saved Location
      • Update a Saved Location
      • Delete a Saved Location
    • Loop
      • Loop Links
        • Create a Loop Link
        • Search Loop Links
        • Get a Loop Link
        • Update a Loop Link
        • Delete a Loop Link
      • Loop Settings
        • Get Loop Settings
        • Update Loop Settings
      • Loop Submissions
        • Search Submitted Events
      • Loop Feedback
        • Search Feedback
    • Places
      • Search Places
      • Get Place Hierarchies
  • WebApp Support
    • WebApp Overview
      • Using the WebApp
      • API Tools
      • Events Search
      • How to Create an API Token
    • Getting Started
      • Can I Give PredictHQ a Go on a Free Trial Basis?
      • How Do I Get in Touch if I Need Help?
      • Using AWS Data Exchange to Access PredictHQ Events Data
      • Using Snowflake to Access PredictHQ Events Data
      • What Happens at the End of My Free Trial?
      • Export Events Data from the WebApp
    • Account Management
      • Managing your Account Settings
      • How Do I Change My Name in My Account?
      • How Do I Change My Password?
      • How Do I Delete My Account?
      • How Do I Invite People Into My Organization?
      • How Do I Log In With My Google or LinkedIn Account?
      • How Do I Update My Email Address?
      • I Signed Up Using My Google/LinkedIn Account, but I Want To Log In With My Own Email
    • API Plans, Pricing & Billing
      • Do I Need To Provide Credit Card Details for the 14-Day Trial?
      • How Do I Cancel My API Subscription?
      • Learn About Our 14-Day Trial
      • What Are the Definitions for "Storing" and "Caching"?
      • What Attribution Do I Have To Give PredictHQ?
      • What Does "Commercial Use" Mean?
      • What Happens If I Go Over My API Plan's Rate Limit?
    • FAQ
      • How Does PredictHQ Support Placekey?
      • Using Power BI and Tableau With PredictHQ Data
      • Can I Download a CSV of Your Data?
      • Can I Suggest a New Event Category?
      • Does PredictHQ Have Historical Event Data?
      • Is There a PredictHQ Mobile App?
      • What Are Labels?
      • What Countries Do You Have School Holidays For?
      • What Do The Different Event Ranks Mean?
      • What Does Event Visibility Window Mean?
      • What Is the Difference Between an Observed Holiday and an Observance?
    • Tools
      • Is PHQ Attendance Available for All Categories?
      • See Event Trends in the WebApp
      • What is Event Trends?
      • Live TV Events
        • What is Live TV Events?
        • Can You Access Live TV Events via the WebApp?
        • How Do I Integrate Live TV Events into Forecasting Models?
      • Labels
        • What Does the Closed-Doors Label Mean?
    • Beam (Relevancy Engine)
      • An Overview of Beam - Relevancy Engine
      • Creating an Analysis in Beam
      • Uploading Your Demand Data to Beam
      • Viewing the List of Analysis in Beam
      • Viewing the Table of Results in Beam
      • Viewing the Category Importance Information in Beam
      • Feature Importance With Beam - Find the ML Features to Use in Your Forecasts
      • Beam Value Quantification
      • Exporting Correlation Data With Beam
      • Getting More Details on a Date on the Beam Graph
      • Grouping Analyses in Beam
      • Using the Beam Graph
      • Viewing the Time Series Impact Analysis in Beam
    • Location Insights
      • An Overview of Location Insights
      • How to Set a Default Location
      • How Do I Add a Location?
      • How Do I Edit a Location?
      • How Do I Share Location Insights With My Team?
      • How Do I View Details for One Location?
      • How Do I View My Saved Locations as a List?
      • Search and View Event Impact in Location Insights
      • What Do Each of the Columns Mean?
      • What Is the Difference Between Center Point & Radius and City, State, Country?
Powered by GitBook

PredictHQ

  • Terms of Service
  • Privacy Policy
  • GitHub

© 2025 PredictHQ Ltd

On this page
  • Initial Search
  • Full-Text Search
  • Temporal Relevance
  • Spatial Relevance
  • Event Rank

Was this helpful?

  1. Getting Started
  2. Guides
  3. Events API Guides

Understanding Relevance Field in Event Results

Understand how some parameters in Events API affect the order of results and the relevance field.

Note that the relevance field has been deprecated. Please do not rely on this field being present in Events API responses.

The relevance field in Events API responses is purely a sorting mechanism and is only set when using certain (relevance-affecting) parameters. By default relevance will be 0 but when using a parameter like q (full-text search) the relevance field will reflect the relevance of the event to the search terms used.

Throughout the guide we'll be using the scenario of adding an "Events Near Me" feature to a mobile application, with the example use case of a user wanting to find a jazz concert to attend. We'll show how information from/about the user can be translated to search parameters that help tailor results to what the user wants.

Initial Search

Let's start by defining a basic search. We know the user is in the United States of America, so we use a US country filter. They've also selected concerts as the type of event they want to find in the app, so we can map that to a concert category filter. Finally, users of this feature aren't interested in past events, so we'll filter to events that are active on or after the $CURRENT_DATE (replace with the current date in yyyy-MM-dd format).

Perform an event search with the parameters category=concerts&country=US&active.gte=$CURRENT_DATE.

This will return the first page of current/future concert events in the US that fall inside your event visibility window, sorted in reverse chronological order. It's likely there's more than one page of results, and more results than your result limit allows you to fetch. Our goal is to get the concerts the user would most like to attend in the first page of results.

import requests

response = requests.get(
    url = "https://api.predicthq.com/v1/events/",
    headers = {
        "Authorization": "Bearer $ACCESS_TOKEN"
    },
    params = {
        "category": "concerts",
        "country": "US",
        "active.gte": "$CURRENT_DATE"
    }
)

print(response.json())

Full-Text Search

The user likes jazz music, so types "jazz" in the app's search box. A search box can be mapped to the q parameter.

The q parameter performs a text search on the title and description of events. This parameter has two effects - it filters results to events whose titles or descriptions have some similarity to the search string, and it also scores events by this similarity.

The similarity score can influence the relevance field of each event. By default, results are sorted by relevance,-start - first by relevance, and then by -start if two events have the same relevance. Previously all events had the same relevance, so results were sorted in reverse chronological order. By adding a parameter that affects relevance the results will be sorted so events with the highest relevance are returned first.

Add parameter q=jazz to our previous request.

Parameters that can affect relevance are automatically included in the relevance calculation when they are used. We'll cover using the relevance parameter to control the components used to calculate the relevance field later in this guide.

import requests

response = requests.get(
    url = "https://api.predicthq.com/v1/events/",
    headers = {
        "Authorization": "Bearer $ACCESS_TOKEN"
    },
    params = {
        "q": "jazz",
        "category": "concerts",
        "country": "US",
        "active.gte": "$CURRENT_DATE"
    }
)

print(response.json())

Temporal Relevance

We've filtered out past events, but we're still getting events that are well in the future. The user might still want to go to them, but events that are happening sooner are more important.

We could sort by start ascending so earlier events are returned first. However, this only takes into account the "soon-ness" of the event without considering any other factors of what the user wants, such as the relevance to the q parameter (and the other factors we'll introduce below).

Instead, we'll use the start_around.origin parameter to add proximity of an event's start date to the $CURRENT_DATE as a relevance component, prioritizing events that start soon.

Add parameter start_around.origin=$CURRENT_DATE to our previous request.

import requests

response = requests.get(
    url = "https://api.predicthq.com/v1/events/",
    headers = {
        "Authorization": "Bearer $ACCESS_TOKEN"
    },
    params = {
        "start_around.origin": "$CURRENT_DATE",
        "q": "jazz",
        "category": "concerts",
        "country": "US",
        "active.gte": "$CURRENT_DATE"
    }
)

print(response.json())

Spatial Relevance

We've prioritized events that are near in time, but what about near in space? We are aiming to build an "Events Near Me" feature after all.

The user's location (as reported by our app) is 40.782409,-73.971885 (lat,lon) - near the American Museum of Natural History in New York. We can use this as our location_around.origin to add the proximity of the event to the user's location as a relevance component.

We'll assume they are happy to travel a km or so, setting location_around.offset so all events within 1km have the same location_around relevance, with the relevance reducing as the distance to the event increases beyond that.

Add parameters location_around.origin=40.782409,-73.971885&location_around.offset=1km to our previous request.

import requests

response = requests.get(
    url = "https://api.predicthq.com/v1/events/",
    headers = {
        "Authorization": "Bearer $ACCESS_TOKEN"
    },
    params = {
        "location_around.origin": "40.782409,-73.971885",
        "location_around.offset": "1km",
        "start_around.origin": "$CURRENT_DATE",
        "q": "jazz",
        "category": "concerts",
        "country": "US",
        "active.gte": "$CURRENT_DATE"
    }
)

print(response.json())

Event Rank

Our final relevance adjustment is to prioritize events with higher ranks, as they're more likely to be of interest to the user. Here we're not going to add a parameter that will start influencing relevance automatically, like we have with q, start_around.* and location_around.*. Instead we're going to directly change how the relevance field is calculated by using the relevance parameter.

The relevance parameter controls which relevance components are multiplied together to produce the final relevance field. When it isn't explicitly set it defaults to including all the components from the relevance-influencing parameters used in the search - in our case, q, start_around, and location_around.

We want to add the rank component into the mix, so we need to set the relevance parameter explicity. We still want the existing components, so need to include them, but we'll add rank as well.

Add parameter relevance=rank,q,start_around,location_around to our previous request.

import requests

response = requests.get(
    url = "https://api.predicthq.com/v1/events/",
    headers = {
        "Authorization": "Bearer $ACCESS_TOKEN"
    },
    params = {
        "relevance": "rank,q,start_around,location_around",
        "location_around.origin": "40.782409,-73.971885",
        "location_around.offset": "1km",
        "start_around.origin": "$CURRENT_DATE",
        "q": "jazz",
        "category": "concerts",
        "country": "US",
        "active.gte": "$CURRENT_DATE"
    }
)

print(response.json())

And there you have it - a search that returns the most relevant results for the user, based on the user's search terms, how soon the events start, how close the events are to the user, and the events' ranks.

PreviousEvents API GuidesNextAttendance-Based Events Notebooks

Last updated 1 month ago

Was this helpful?

The other start_around.* parameters can be used to tune how the relevance of an event changes as its start date moves away from the origin. See the for details.

The other location_around.* parameters can be used to further tune how the relevance of an event changes as its location moves away from the origin. See the for details.

See the for more information about the relevance parameter.

parameter documentation
parameter documentation
relevance parameter documentation