Septzzz's picture
Upload folder using huggingface_hub (part 17)
e50b0a2 verified
Raw
History Blame Contribute Delete
3.49 kB
import requests
import json
from datetime import date, datetime, timedelta
import os
from typing import Optional, Dict, Union, List
def query_for_postal_code_boundary_by_location(longitude: int, latitude: int, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Query for Postal Code By location"
"""
url = f"https://de-boundaries-io1.p.rapidapi.com/rest/v1/public/boundary/postalcode/within"
querystring = {'longitude': longitude, 'latitude': latitude, }
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "de-boundaries-io1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def query_for_all_state_names(toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Query for all State names."
"""
url = f"https://de-boundaries-io1.p.rapidapi.com/rest/v1/public/boundary/state/names"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "de-boundaries-io1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def query_for_postal_code_boundary_by_postal_code(postalcode: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Query For Postal Code Boundary by postal code."
"""
url = f"https://de-boundaries-io1.p.rapidapi.com/rest/v1/public/boundary/postalcode/{postalcode}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "de-boundaries-io1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def query_for_city_names_by_state(state: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Query for list of city names by a state name."
"""
url = f"https://de-boundaries-io1.p.rapidapi.com/rest/v1/public/boundary/city/state/{state}/names"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "de-boundaries-io1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def query_for_city_boundary_by_name(name: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Query for City Boundary by City Name"
"""
url = f"https://de-boundaries-io1.p.rapidapi.com/rest/v1/public/boundary/city/{name}"
querystring = {}
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "de-boundaries-io1.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation