Skip to content

Instantly share code, notes, and snippets.

@souravs17031999
Created April 24, 2022 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save souravs17031999/291dcbb6ee5f350674a5a8579707b56e to your computer and use it in GitHub Desktop.
Save souravs17031999/291dcbb6ee5f350674a5a8579707b56e to your computer and use it in GitHub Desktop.
def get_amazon_product_response():
apiParams = {
'api_key': AMAZON_API_KEY,
'type': 'product',
'amazon_domain': 'amazon.in',
'asin': 'B093L8FSP2',
'output': 'json'
}
headers = {"Content-Type": "application/json"}
print(f"[AMAZON]: Trying for product ID {AMAZON_PRODUCT_ID_ASIN}")
try:
print(f"[REQUEST]: GET {AMAZON_PRODUCT_API} {apiParams}")
product_get_response = requests.get(
AMAZON_PRODUCT_API,
headers=headers,
params=apiParams
)
print(f"[RESPONSE]: {product_get_response.status_code}")
json_product_response = product_get_response.json()
# print(json_product_response)
except Exception as e:
print(f"[ERROR]: {e}")
print(
"status: failure, message: Failure in sending request to Amazon Server !"
)
return json_product_response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment