Geography module
geography
Module
geography
ModuleExample
Here is an example of using pypply to retrieve Paris airport coordinates:
from pypply.geography import Geography
token_client = "01hp1***.69aa***"
# Create a Geography object using your development token
geography = Geography(access_token=token_client)
# Retrieve coordinates for a given query
coordinates = geography.get_lat_long(query="Paris", location_type="airport", country_code="FR")
print(f"Coordinates for Paris airport: {coordinates}")
Doc
class pypply.geography.Geography(access_token, env='prod', timeout=5, sleep_time=0.2, retries=0)
Bases: API
Creates a Geography object to request geography endpoint.
Geography.__init__(self, access_token: str, env: str = 'prod', timeout: int = 5, sleep_time: float = 0.2, retries: int = 0)
Geography.__init__(self, access_token: str, env: str = 'prod', timeout: int = 5, sleep_time: float = 0.2, retries: int = 0)
Initializes a Geography object with authentication and request settings.
- Parameters:
- access_token (
str
) – Authentication token required to access the API. - env (
str
) – API environment. Allowed values: prod, sandbox. - timeout (
int
) – Maximum time (in seconds) to wait for a response. - sleep_time (
float
) – Delay (in seconds) between retry attempts. - retries (
int
) – Number of retry attempts in case of a failed request.
- access_token (
Geography.get_lat_long(self, query: str, location_type: str, country_code: str) -> dict[str, typing.Union[float, int]]
Geography.get_lat_long(self, query: str, location_type: str, country_code: str) -> dict[str, typing.Union[float, int]]
Retrieves the latitude and longitude for a given location (city, airport, or seaport).
- Parameters:
- query (
str
) – Search string. - location_type (
str
) – Location type. Allowed values: city, airport, seaport. - country_code (
str
) – Country code ISO Alpha 2.
- query (
- Returns: dict[str, Union[float, int]] – Dictionary corresponding to latitude and longitude.
Updated 11 days ago