Skip to main content

PredictHQ Event Intelligence

Project description

For the latest source, discussions, bug reports, etc., please visit the GitHub repository

PredictHQ logo

PredictHQ API Client for Python

Version PyPI package Build Status Coverage Status

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

The PredicHQ Python client is distributed as a pip package. You can simply install it by running

pip install predicthq

Usage

We support all the endpoints available in our API.

  • oauth2
  • accounts
  • events
  • places

Please refer to our API Documentation for a description of each endpoint.

Pagination

Additional examples are available in usecases/pagination.py file.

By default the search() method only returns the first page of results, with a default page size of 10.

from predicthq import Client

phq = Client(access_token="abc123")


for event in phq.events.search():
    print(event.rank, event.category, event.title, event.start.strftime('%Y-%m-%d'))

You can chain the iter_all() generator to iterate over all your events.

for event in phq.events.search().iter_all():
    print(event.rank, event.category, event.title, event.start.strftime('%Y-%m-%d'))

Events endpoint

Additional examples are available in usecases/events folder.

The following example searches for the 'Katy Perry' events (full text search) with rank level of 4 or 5 (rank >= 60) in the concerts category.

from predicthq import Client

phq = Client(access_token="abc123")


for event in phq.events.search(q='Katy Perry', rank_level=[4, 5], category='concerts'):
    print(event.rank, event.category, event.title, event.start.strftime('%Y-%m-%d'))

Please refer to our Events endpoint documentation for the lists of search parameters and event fields available.

Places endpoint

Additional examples are available in usecases/places.py file.

The following example searches for the 'New York' places (full text search) in the US.

from predicthq import Client

phq = Client(access_token="abc123")


for place in phq.places.search(q='New York', country='US'):
    print(place.id, place.name, place.type, place.location)

Please refer to our Places endpoint documentation for the lists of search parameters and place fields available.

Running Tests

pip install tox
tox

Found a Bug?

Please log an issue.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

predicthq-0.3.3-py2.py3-none-any.whl (17.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file predicthq-0.3.3-py2.py3-none-any.whl.

File metadata

  • Download URL: predicthq-0.3.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/2.7.15

File hashes

Hashes for predicthq-0.3.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 72afc4d5d3cb1d3f470893dd442e3332081c7ad24b5dfdfaca1e19ccb0ea2ad7
MD5 85f95eda1f89fb5c8d2d2206b9b27c52
BLAKE2b-256 3fcd9002d6f3e455bccc65c346d2d79f0ece18cb1b53297bbf0079934681f04a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page