API Quickstart

This article describes how to quickly create an access token, view and replicate a Streamlit demo app and explore our APIs.

What you need:

  1. A PredictHQ account:

  2. An API Access Token: We'll guide you through creating one below.

Create an Access Token

Read a more in-depth guide to creating a new API Token or follow the basic steps below:

  1. Log into Control Center and visit the API Tokens page under API tools.

  2. The first time you create a token - enter the name of the token and click "Create Token". For the second and subsequent times click the "Create New Token" button and enter the name, then click Create Token.

  3. Click "Copy Token" to copy your token to the clipboard. You can now paste the token into another application. Keep a copy of your new API Token, as it will not be shown again.

  4. Use the new API Access Token in the Authorization header of your API requests as shown in the example below

Access Events API

Now you can use the new API Access Token in the Authorization header of your API requests as in the example below:

import requests

response = requests.get(
    url="https://api.predicthq.com/v1/events/",
    headers={
      "Authorization": "Bearer $ACCESS_TOKEN",
      "Accept": "application/json"
    },
    params={
        "q": "taylor swift"
    }
)

print(response.json())
How to set up and access PredictHQ APIs

Refer to Filtering and Finding Relevant Events for guidance on how to identify events relevant to your business.

Streamlit Demo Apps

To demonstrate how quick and easy it is to build extremely powerful apps using our APIs, we put together some Streamlit demos. All the code is available on GitHub and we encourage you to take the code, modify it, and use your own locations of interest to demo our APIs internally to your team or to simply better understand our technology.

Streamlit Demo Apps

Explore the API

Below is a guide to point you in the right direction if you're new to the PredictHQ APIs:

Events API

Search for real-world events.

Customers also use this API to keep a copy of PredictHQ Event data updated in their environment.

Every event has unique-to-PredictHQ values like Predicted Attendance, Ranks, Predicted End Times and more.

Broadcasts API

Full broadcast (Live TV) information covering many sporting events in USA.

Customers also use this API to keep a copy of PredictHQ Broadcast data updated in their environment.

Every Broadcast has Predicted Viewership and more.

Features API

Aggregated daily-level features ready for use by ML models.

Customers use this API to very quickly get features that can be used by their forecasting (and other) machine-learning models.

This API removes all of the hard, time-consuming work of aggregating the individual events from Events API.

Beam API

Decomposition, correlation and feature-importance engine.

Customers use this API to understand how events have impacted their business in the past and to know which types of events are likely to impact them in the future so they can prepare for changes in demand.

Demand Surge API

Identify abnormal increases in predicted attendance around your location.

Suggested Radius API

Takes the guesswork out of working out a suitable radius around your location when searching for events.

Customers use this API to more accurately work out a suitable radius around their stores/businesses. Different types of events affect different types of businesses nearer and further away depending on the type.

We strongly recommend using Suggested Radius API for each of your locations to remove the guesswork and improve the accuracy.

Saved Locations API

Get insights about your locations.

Loop API

Manage Loop Links and enable submitting events and feedback.

Places API

Geonames place data.

Did you know - Control Center uses the same APIs you have access to. One of the easiest ways to learn how to use our APIs is to see it in action in Control Center.

Last updated

© 2024 PredictHQ Ltd