%global _empty_manifest_terminate_build 0
Name: python-predicthq
Version: 2.3.0
Release: 1
Summary: PredictHQ Event Intelligence
License: MIT
URL: https://github.com/predicthq/sdk-py
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/3f/61/40b552cb1610255605b464b9d2a4ef1acdc6e19b2557f058d6eb8b4d0a6a/predicthq-2.3.0.tar.gz
BuildArch: noarch
Requires: python3-requests
Requires: python3-schematics
Requires: python3-dateutil
Requires: python3-pytz
%description
For the latest source, discussions, bug reports, etc., please visit the [GitHub repository](https://github.com/predicthq/sdk-py)

# PredictHQ API Client for Python



[PredictHQ](https://www.predicthq.com/) 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 PredictHQ Python client is distributed as a pip package. You can simply install it by running
```Shell
pip install predicthq
```
## Usage
We support all the endpoints available in our API.
* `oauth2`
* `accounts`
* `broadcasts`
* `events`
* `features`
* `places`
* `radius`
Please refer to our [API Documentation](https://docs.predicthq.com/) for a description of each endpoint.
The [usecases/](https://github.com/predicthq/sdk-py/tree/master/usecases/pagination.py) folder is a good starting point to get familiar with the Python SDK.
You can also review the [tests](https://github.com/predicthq/sdk-py/tree/master/tests/endpoints/v1/) for a kitchen sink of all the parameters available per endpoint.
### Pagination
Additional examples are available in [usecases/pagination.py](https://github.com/predicthq/sdk-py/tree/master/usecases/pagination.py) file.
By default the `search()` method only returns the first page of results, with a default page size of 10.
```Python
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.
```Python
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](https://github.com/predicthq/sdk-py/tree/master/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.
```Python
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](https://docs.predicthq.com/resources/events/) for the lists of search parameters and event fields available.
### Broadcasts endpoint
Additional examples are available in [usecases/broadcasts](https://github.com/predicthq/sdk-py/tree/master/usecases/broadcasts) folder.
The following example searches for the broadcasts with PHQ viewership gte 100 and with event (the physical event the broadcast links to) label `nfl`.
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for broadcast in phq.broadcasts.search(phq_viewership__gte=100, event__label="nfl"):
print(broadcast.event.title, broadcast.phq_viewership, broadcast.event.labels, broadcast.dates.start.strftime("%Y-%m-%d"))
```
Please refer to our [Broadcasts endpoint documentation](https://docs.predicthq.com/resources/broadcasts/) for the lists of search parameters and broadcast fields available.
### Places endpoint
Additional examples are available in [usecases/places.py](https://github.com/predicthq/sdk-py/tree/master/usecases/places.py) file.
The following example searches for the `New York` places (full text search) in the US.
```Python
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](https://docs.predicthq.com/resources/places/) for the lists of search parameters and place fields available.
### Features endpoint
The following example obtain features of events which are active between 2017-12-31 and 2018-01-02, with place_id 4671654.
Requested features:
* rank_levels for public_holidays
* count and median of sporting events which has a phq_rank greater than 50
By place_id list (e.g. Austin):
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for feature in phq.features.obtain_features(
active__gte="2017-12-31",
active__lte="2018-01-02",
location__place_id=[4671654],
phq_rank_public_holidays=True,
phq_attendance_sports__stats=["count", "median"],
phq_attendance_sports__phq_rank={
"gt": 50
}
):
print(feature.date, feature.phq_attendance_sports.stats.count, feature.phq_rank_public_holidays.rank_levels)
```
by geo:
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for feature in phq.features.obtain_features(
active__gte="2017-12-31",
active__lte="2018-01-02",
location__geo={
"lon": -97.74306,
"lat": 30.26715,
"radius": "150km"
},
phq_rank_public_holidays=True,
phq_attendance_sports__stats=["count", "median"],
phq_attendance_sports__phq_rank={
"gt": 50
}
):
print(feature.date, feature.phq_attendance_sports.stats.count, feature.phq_rank_public_holidays.rank_levels)
```
The following example obtains features of broadcasts which are active between 2017-12-31 and 2018-01-02, with place_id 4671654
Requested features:
* count and median of broadcasts which start between 9am - 11am and have a `phq_rank` greater than 50
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for feature in phq.features.obtain_features(
active__gte="2017-12-31",
active__lte="2018-01-02",
hour_of_day_start__gt=9,
hour_of_day_start__lte=11,
location__place_id=[4671654],
phq_viewership_sports_american_football__stats=["count", "median"],
phq_viewership_sports_american_football__phq_rank={
"gt": 50
}
):
print(feature.date, feature.phq_viewership_sports_american_football.stats.count, feature.phq_viewership_sports_american_football.stats.median)
```
Please refer to our [Features endpoint documentation](https://docs.predicthq.com/start/features-api/) for the lists of supported features and response fields available.
### Radius endpoint
The following example obtain suggested radius to be used when retrieving events for location {"lat": 45.5051, "lon": -122.6750} and generic industry.
Additional examples are available in [usecases/radius](https://github.com/predicthq/sdk-py/tree/master/usecases/radius) folder.
```Python
from predicthq import Client
phq = Client(access_token="abc123")
suggested_radius = phq.radius.search(location__origin="45.5051,-122.6750")
print(suggested_radius.radius, suggested_radius.radius_unit, suggested_radius.location.to_dict())
```
### Config parameters
We support some `config` parameters for additional flexibility.
Supported config parameters:
- `verify_ssl`
```Python
from predicthq import Client
phq = Client(access_token="abc123")
# double underscore syntax
for event in phq.events.search(config__verify_ssl=False):
print(event.rank, event.category, event.title, event.start.strftime("%Y-%m-%d"))
# dictionary syntax
for event in phq.events.search(config={"verify_ssl": False}):
print(event.rank, event.category, event.title, event.start.strftime("%Y-%m-%d"))
```
## Running Tests
```Shell
pip install tox
tox
```
## Found a Bug?
Please [log an issue](https://github.com/predicthq/sdk-py/issues/new).
%package -n python3-predicthq
Summary: PredictHQ Event Intelligence
Provides: python-predicthq
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-predicthq
For the latest source, discussions, bug reports, etc., please visit the [GitHub repository](https://github.com/predicthq/sdk-py)

# PredictHQ API Client for Python



[PredictHQ](https://www.predicthq.com/) 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 PredictHQ Python client is distributed as a pip package. You can simply install it by running
```Shell
pip install predicthq
```
## Usage
We support all the endpoints available in our API.
* `oauth2`
* `accounts`
* `broadcasts`
* `events`
* `features`
* `places`
* `radius`
Please refer to our [API Documentation](https://docs.predicthq.com/) for a description of each endpoint.
The [usecases/](https://github.com/predicthq/sdk-py/tree/master/usecases/pagination.py) folder is a good starting point to get familiar with the Python SDK.
You can also review the [tests](https://github.com/predicthq/sdk-py/tree/master/tests/endpoints/v1/) for a kitchen sink of all the parameters available per endpoint.
### Pagination
Additional examples are available in [usecases/pagination.py](https://github.com/predicthq/sdk-py/tree/master/usecases/pagination.py) file.
By default the `search()` method only returns the first page of results, with a default page size of 10.
```Python
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.
```Python
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](https://github.com/predicthq/sdk-py/tree/master/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.
```Python
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](https://docs.predicthq.com/resources/events/) for the lists of search parameters and event fields available.
### Broadcasts endpoint
Additional examples are available in [usecases/broadcasts](https://github.com/predicthq/sdk-py/tree/master/usecases/broadcasts) folder.
The following example searches for the broadcasts with PHQ viewership gte 100 and with event (the physical event the broadcast links to) label `nfl`.
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for broadcast in phq.broadcasts.search(phq_viewership__gte=100, event__label="nfl"):
print(broadcast.event.title, broadcast.phq_viewership, broadcast.event.labels, broadcast.dates.start.strftime("%Y-%m-%d"))
```
Please refer to our [Broadcasts endpoint documentation](https://docs.predicthq.com/resources/broadcasts/) for the lists of search parameters and broadcast fields available.
### Places endpoint
Additional examples are available in [usecases/places.py](https://github.com/predicthq/sdk-py/tree/master/usecases/places.py) file.
The following example searches for the `New York` places (full text search) in the US.
```Python
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](https://docs.predicthq.com/resources/places/) for the lists of search parameters and place fields available.
### Features endpoint
The following example obtain features of events which are active between 2017-12-31 and 2018-01-02, with place_id 4671654.
Requested features:
* rank_levels for public_holidays
* count and median of sporting events which has a phq_rank greater than 50
By place_id list (e.g. Austin):
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for feature in phq.features.obtain_features(
active__gte="2017-12-31",
active__lte="2018-01-02",
location__place_id=[4671654],
phq_rank_public_holidays=True,
phq_attendance_sports__stats=["count", "median"],
phq_attendance_sports__phq_rank={
"gt": 50
}
):
print(feature.date, feature.phq_attendance_sports.stats.count, feature.phq_rank_public_holidays.rank_levels)
```
by geo:
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for feature in phq.features.obtain_features(
active__gte="2017-12-31",
active__lte="2018-01-02",
location__geo={
"lon": -97.74306,
"lat": 30.26715,
"radius": "150km"
},
phq_rank_public_holidays=True,
phq_attendance_sports__stats=["count", "median"],
phq_attendance_sports__phq_rank={
"gt": 50
}
):
print(feature.date, feature.phq_attendance_sports.stats.count, feature.phq_rank_public_holidays.rank_levels)
```
The following example obtains features of broadcasts which are active between 2017-12-31 and 2018-01-02, with place_id 4671654
Requested features:
* count and median of broadcasts which start between 9am - 11am and have a `phq_rank` greater than 50
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for feature in phq.features.obtain_features(
active__gte="2017-12-31",
active__lte="2018-01-02",
hour_of_day_start__gt=9,
hour_of_day_start__lte=11,
location__place_id=[4671654],
phq_viewership_sports_american_football__stats=["count", "median"],
phq_viewership_sports_american_football__phq_rank={
"gt": 50
}
):
print(feature.date, feature.phq_viewership_sports_american_football.stats.count, feature.phq_viewership_sports_american_football.stats.median)
```
Please refer to our [Features endpoint documentation](https://docs.predicthq.com/start/features-api/) for the lists of supported features and response fields available.
### Radius endpoint
The following example obtain suggested radius to be used when retrieving events for location {"lat": 45.5051, "lon": -122.6750} and generic industry.
Additional examples are available in [usecases/radius](https://github.com/predicthq/sdk-py/tree/master/usecases/radius) folder.
```Python
from predicthq import Client
phq = Client(access_token="abc123")
suggested_radius = phq.radius.search(location__origin="45.5051,-122.6750")
print(suggested_radius.radius, suggested_radius.radius_unit, suggested_radius.location.to_dict())
```
### Config parameters
We support some `config` parameters for additional flexibility.
Supported config parameters:
- `verify_ssl`
```Python
from predicthq import Client
phq = Client(access_token="abc123")
# double underscore syntax
for event in phq.events.search(config__verify_ssl=False):
print(event.rank, event.category, event.title, event.start.strftime("%Y-%m-%d"))
# dictionary syntax
for event in phq.events.search(config={"verify_ssl": False}):
print(event.rank, event.category, event.title, event.start.strftime("%Y-%m-%d"))
```
## Running Tests
```Shell
pip install tox
tox
```
## Found a Bug?
Please [log an issue](https://github.com/predicthq/sdk-py/issues/new).
%package help
Summary: Development documents and examples for predicthq
Provides: python3-predicthq-doc
%description help
For the latest source, discussions, bug reports, etc., please visit the [GitHub repository](https://github.com/predicthq/sdk-py)

# PredictHQ API Client for Python



[PredictHQ](https://www.predicthq.com/) 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 PredictHQ Python client is distributed as a pip package. You can simply install it by running
```Shell
pip install predicthq
```
## Usage
We support all the endpoints available in our API.
* `oauth2`
* `accounts`
* `broadcasts`
* `events`
* `features`
* `places`
* `radius`
Please refer to our [API Documentation](https://docs.predicthq.com/) for a description of each endpoint.
The [usecases/](https://github.com/predicthq/sdk-py/tree/master/usecases/pagination.py) folder is a good starting point to get familiar with the Python SDK.
You can also review the [tests](https://github.com/predicthq/sdk-py/tree/master/tests/endpoints/v1/) for a kitchen sink of all the parameters available per endpoint.
### Pagination
Additional examples are available in [usecases/pagination.py](https://github.com/predicthq/sdk-py/tree/master/usecases/pagination.py) file.
By default the `search()` method only returns the first page of results, with a default page size of 10.
```Python
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.
```Python
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](https://github.com/predicthq/sdk-py/tree/master/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.
```Python
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](https://docs.predicthq.com/resources/events/) for the lists of search parameters and event fields available.
### Broadcasts endpoint
Additional examples are available in [usecases/broadcasts](https://github.com/predicthq/sdk-py/tree/master/usecases/broadcasts) folder.
The following example searches for the broadcasts with PHQ viewership gte 100 and with event (the physical event the broadcast links to) label `nfl`.
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for broadcast in phq.broadcasts.search(phq_viewership__gte=100, event__label="nfl"):
print(broadcast.event.title, broadcast.phq_viewership, broadcast.event.labels, broadcast.dates.start.strftime("%Y-%m-%d"))
```
Please refer to our [Broadcasts endpoint documentation](https://docs.predicthq.com/resources/broadcasts/) for the lists of search parameters and broadcast fields available.
### Places endpoint
Additional examples are available in [usecases/places.py](https://github.com/predicthq/sdk-py/tree/master/usecases/places.py) file.
The following example searches for the `New York` places (full text search) in the US.
```Python
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](https://docs.predicthq.com/resources/places/) for the lists of search parameters and place fields available.
### Features endpoint
The following example obtain features of events which are active between 2017-12-31 and 2018-01-02, with place_id 4671654.
Requested features:
* rank_levels for public_holidays
* count and median of sporting events which has a phq_rank greater than 50
By place_id list (e.g. Austin):
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for feature in phq.features.obtain_features(
active__gte="2017-12-31",
active__lte="2018-01-02",
location__place_id=[4671654],
phq_rank_public_holidays=True,
phq_attendance_sports__stats=["count", "median"],
phq_attendance_sports__phq_rank={
"gt": 50
}
):
print(feature.date, feature.phq_attendance_sports.stats.count, feature.phq_rank_public_holidays.rank_levels)
```
by geo:
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for feature in phq.features.obtain_features(
active__gte="2017-12-31",
active__lte="2018-01-02",
location__geo={
"lon": -97.74306,
"lat": 30.26715,
"radius": "150km"
},
phq_rank_public_holidays=True,
phq_attendance_sports__stats=["count", "median"],
phq_attendance_sports__phq_rank={
"gt": 50
}
):
print(feature.date, feature.phq_attendance_sports.stats.count, feature.phq_rank_public_holidays.rank_levels)
```
The following example obtains features of broadcasts which are active between 2017-12-31 and 2018-01-02, with place_id 4671654
Requested features:
* count and median of broadcasts which start between 9am - 11am and have a `phq_rank` greater than 50
```Python
from predicthq import Client
phq = Client(access_token="abc123")
for feature in phq.features.obtain_features(
active__gte="2017-12-31",
active__lte="2018-01-02",
hour_of_day_start__gt=9,
hour_of_day_start__lte=11,
location__place_id=[4671654],
phq_viewership_sports_american_football__stats=["count", "median"],
phq_viewership_sports_american_football__phq_rank={
"gt": 50
}
):
print(feature.date, feature.phq_viewership_sports_american_football.stats.count, feature.phq_viewership_sports_american_football.stats.median)
```
Please refer to our [Features endpoint documentation](https://docs.predicthq.com/start/features-api/) for the lists of supported features and response fields available.
### Radius endpoint
The following example obtain suggested radius to be used when retrieving events for location {"lat": 45.5051, "lon": -122.6750} and generic industry.
Additional examples are available in [usecases/radius](https://github.com/predicthq/sdk-py/tree/master/usecases/radius) folder.
```Python
from predicthq import Client
phq = Client(access_token="abc123")
suggested_radius = phq.radius.search(location__origin="45.5051,-122.6750")
print(suggested_radius.radius, suggested_radius.radius_unit, suggested_radius.location.to_dict())
```
### Config parameters
We support some `config` parameters for additional flexibility.
Supported config parameters:
- `verify_ssl`
```Python
from predicthq import Client
phq = Client(access_token="abc123")
# double underscore syntax
for event in phq.events.search(config__verify_ssl=False):
print(event.rank, event.category, event.title, event.start.strftime("%Y-%m-%d"))
# dictionary syntax
for event in phq.events.search(config={"verify_ssl": False}):
print(event.rank, event.category, event.title, event.start.strftime("%Y-%m-%d"))
```
## Running Tests
```Shell
pip install tox
tox
```
## Found a Bug?
Please [log an issue](https://github.com/predicthq/sdk-py/issues/new).
%prep
%autosetup -n predicthq-2.3.0
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-predicthq -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Tue May 30 2023 Python_Bot - 2.3.0-1
- Package Spec generated