Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 58 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ We support the following endpoints available in our API.
* `broadcasts`
* `events`
* `features`
* `impact_area`
* `places`
* `radius`
* `beam`
Expand Down Expand Up @@ -205,7 +206,43 @@ for feature in phq.features.obtain_features(

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
### Predicted Impact Area endpoint

> Predicted Impact Area is the successor to the Suggested Radius API. It provides a more accurate representation of event impact than a radius-based approach.

Additional examples are available in [usecases/impact_area.py](https://github.com/predicthq/sdk-py/tree/master/usecases/impact_area.py) file.

The following example obtains the impact area as a polygon for a given location and industry.

```Python
from predicthq import Client

phq = Client(access_token="abc123")


result = phq.impact_area.search(location__origin="45.5051,-122.6750", industry="accommodation")
print(result.geojson.geometry.type, result.geojson.geometry.coordinates)
print(result.location.model_dump(exclude_none=True))
```

You can also get the impact area as a radius instead of a polygon.

```Python
from predicthq import Client

phq = Client(access_token="abc123")


result = phq.impact_area.search(location__origin="45.5051,-122.6750", industry="retail", area_type="radius", radius_unit="km")
print(result.geojson.properties.radius, result.geojson.properties.radius_unit)
print(result.geojson.geometry.coordinates)
```

Please refer to our [Predicted Impact Area endpoint documentation](https://docs.predicthq.com/api/impact-area/get-impact-area) for the lists of search parameters and response fields available.

### Suggested Radius endpoint

> Predicted Impact Area is the successor to this API, providing a more accurate representation of event impact than a radius. Suggested Radius remains available and existing implementations are unaffected.

The following example obtain suggested radius to be used when retrieving events for location {"lat": 45.5051, "lon": -122.6750} and generic industry.

Expand Down Expand Up @@ -251,6 +288,26 @@ analysis_group = phq.beam.analysis_group.get(group_id="abc123")
print(analysis_group.model_dump(exlcude_none=True))
```

### Saved Locations endpoints

Additional examples are available in [usecases/saved_locations.py](https://github.com/predicthq/sdk-py/tree/master/usecases/places.py) file.

The following example searches for the saved_locations according to the parameters defined:

```Python
from predicthq import Client

phq = Client(access_token="abc123")


for saved_location in phq.saved_locations.search(
labels=["test", "retail"],
q="London",
sort="-created",
):
print(saved_location.location_id, saved_location.create_dt, saved_location.status)
```

### Serializing search results into a dictionary

All search results can be serialized into a dictionary using the `.model_dump()` method call.
Expand Down Expand Up @@ -315,27 +372,6 @@ for event in phq.events.search(config={"verify_ssl": False}):
```


### Saved_Locations endpoints

Additional examples are available in [usecases/saved_locations.py](https://github.com/predicthq/sdk-py/tree/master/usecases/places.py) file.

The following example searches for the saved_locations according to the parameters defined:

```Python
from predicthq import Client

phq = Client(access_token="abc123")


for saved_location in phq.saved_locations.search(
labels=["test", "retail"],
q="London",
sort="-created",
):
print(saved_location.location_id, saved_location.create_dt, saved_location.status)
```


## Running Tests

```Shell
Expand Down
2 changes: 1 addition & 1 deletion predicthq/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.3.0"
__version__ = "5.3.1"
Loading