diff --git a/README.md b/README.md index 3596086..fae1f0c 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ We support the following endpoints available in our API. * `broadcasts` * `events` * `features` +* `impact_area` * `places` * `radius` * `beam` @@ -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. @@ -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. @@ -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 diff --git a/predicthq/version.py b/predicthq/version.py index f575288..0419a93 100644 --- a/predicthq/version.py +++ b/predicthq/version.py @@ -1 +1 @@ -__version__ = "5.3.0" +__version__ = "5.3.1"