Skip to content
PredictHQ API Client for Python
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
predicthq
tests
.gitignore
.travis.yml
LICENSE
MANIFEST.in
README.rst
setup.cfg
setup.py
tox.ini

README.rst

PredictHQ API Client for Python

https://travis-ci.org/predicthq/sdk-py.svg?branch=master https://coveralls.io/repos/github/predicthq/sdk-py/badge.svg?branch=master

PredictHQ is the demand intelligence company combining real-world events into one global source of truth to help businesses better understand demand and plan for the future.

Installation

pip install predicthq

Usage

from predicthq import Client

phq = Client(access_token="$ACCESS_TOKEN")

# the search() method returns an EventResultSet which allows you to iterate over the 1st page of items
for event in phq.events.search(q="Foo Fighters", rank_level=[4, 5], place={"scope": ["5391959", "5368361"]}):
    print(event.rank, event.category, event.title, event.start.strftime('%Y-%m-%d'))

# if you want to iterate over all the results for your query, you can chain the iter_all() generator
for event in phq.events.search(q="matisse", country="FR").iter_all():
    print(event.rank, event.category, event.title, event.start.strftime('%Y-%m-%d'))

# you can skip results with the offset parameter and limit the number of results with the limit parameter
# the following skips the first 10 results and limits the results to 5 items
for event in phq.events.search(q="matisse", country="FR", offset=10, limit=5):
    print(event.rank, event.category, event.title, event.start.strftime('%Y-%m-%d'))

Endpoints

  • Client.oauth2
  • Client.accounts
  • Client.events
  • Client.signals
  • Client.places

For a description of all available endpoints, refer to our API Documentation.

Running Tests

pip install tox
tox

Found a Bug?

Please log an issue.

You can’t perform that action at this time.