Code Monkey home page Code Monkey logo

Comments (2)

nkilm avatar nkilm commented on June 7, 2024

You did NOT provide correct API_KEY or API_SECRET to Client(). Generate new set of keys and check again.

For me it's working fine.

from amadeus import Client, ResponseError
from dotenv import load_dotenv
from os import environ
from requests import get

load_dotenv()

try:
  amadeus = Client(
      client_id=environ.get("API_KEY"),
      client_secret=environ.get("API_SECRET")
)

except Exception as e:
  print("Hint: Add API Key and API Secret to class Client")
  exit(1)

res = amadeus.shopping.hotel_offers.get(cityCode='LON')
print(res)

output
image

Similarly we can use the API directly also using requests. E.g,

URL = "https://test.api.amadeus.com/v3/shopping/hotel-offers?hotelIds=MCLONGHM&adults=1&checkInDate=2022-11-22&roomQuantity=1&paymentPolicy=NONE&bestRateOnly=true"

headers = {}
headers["Accept"] = "application/json"
headers["Authorization"] = "Bearer " + environ.get("AUTH")

response = get(URL,headers = headers)

results= response.json()

for item in results.items():
    print(item)

NOTE: Token should be generated every 30 min in the above case

from amadeus-python.

tsolakoua avatar tsolakoua commented on June 7, 2024

Hello @vladisa88 , this issue is not related to the SDK but to the API itself. Newly created accounts can't access the Hotel Search v2 and the technical team needs to give access explicitly. Please get in touch with the support in order to give access to you.

from amadeus-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.