Septzzz's picture
Upload folder using huggingface_hub (part 26)
0bd6ccf verified
Raw
History Blame Contribute Delete
2.97 kB
import requests
import json
from datetime import date, datetime, timedelta
import os
from typing import Optional, Dict, Union, List
def get_products_by_id(productid: str, api_key: str='c2206c49a186bdded150ff78fea282c4', toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Get Amazon India products by Id"
"""
url = f"https://aids.p.rapidapi.com/products/{productid}"
querystring = {}
if api_key:
querystring['api_key'] = api_key
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "aids.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def get_product_reviews(productid: str, api_key: str='c2206c49a186bdded150ff78fea282c4', toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Get Amazon India product reviews by Id"
"""
url = f"https://aids.p.rapidapi.com/products/{productid}/reviews"
querystring = {}
if api_key:
querystring['api_key'] = api_key
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "aids.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def get_search_results(searchquery: str, api_key: str='c2206c49a186bdded150ff78fea282c4', toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Get Amazon India results by search params"
"""
url = f"https://aids.p.rapidapi.com/search/{searchquery}"
querystring = {}
if api_key:
querystring['api_key'] = api_key
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "aids.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation
def get_product_offers(productid: str, api_key: str='c2206c49a186bdded150ff78fea282c4', toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'):
"""
"Get Amazon India products offers by Id"
"""
url = f"https://aids.p.rapidapi.com/products/{productid}/offers"
querystring = {}
if api_key:
querystring['api_key'] = api_key
headers = {
"X-RapidAPI-Key": toolbench_rapidapi_key,
"X-RapidAPI-Host": "aids.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
try:
observation = response.json()
except:
observation = response.text
return observation