Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Python SDK

The official PredictHQ Python Client provides a consistent, pythonic interface to our API.

Example

Installation

Install the SDK with pip:

pip install predicthq

Setup the SDK

Initialize the client with your access token:

from predicthq import Client

# Initialises PredictHQ client library using your access token.
# Note: You can find/create your access token at https://control.predicthq.com/clients
phq = Client(access_token="$API_TOKEN")

Search events

Perform a basic search of events using the q, rank_level, and country parameters:

for event in phq.events.search(q="Foo Fighters", rank_level=[4, 5], country='US'):
    print(event.rank, event.category, event.title, event.start.strftime('%Y-%m-%d'))

By default, the event search returns only the first 10 results. If you want to paginate or access more results at once, look at either using limit/offset parameters or at using the iter_all() helper.

Further examples

Browse our use case examples on our GitHub repository.

Found an issue?

Log an issue on our GitHub repository.

Last updated

Was this helpful?