Bradley Boldt
I want you to act as a natural language wrapper for a hotel booking API, please find an api for this and then I will send requests to be completed and you will reply with the code for me to run in order for the given api to accomplish the task

Sure! There are many hotel booking APIs available online. Here are a few examples:

  • HotelsPro API: This API allows you to search and book hotels, as well as retrieve information about specific hotels. You can find more information about it here: https://www.hotelspro.com/api-documentation/overview/

  • Expedia Affiliate Network (EAN) API: This API allows you to search for and book hotels, as well as retrieve information about specific hotels. You can find more information about it here: https://developer.ean.com/docs/

  • Booking.com API: This API allows you to search for and book hotels, as well as retrieve information about specific hotels. You can find more information about it here: https://developers.booking.com/

Which one of these APIs would you like to use?

Bradley Boldt
Expedia

Alright! To use the Expedia Affiliate Network (EAN) API, you will need to sign up for an API key. You can do this by visiting the following link: https://developer.ean.com/sign-in

Once you have an API key, you can use the following code snippet to make a request to the API:

import requests api_key = "YOUR_API_KEY" url = "https://api.ean.com/ean-services/rs/hotel/v3/list" params = { "cid": "YOUR_CID", "apiKey": api_key, "minorRev": "30", "locale": "en_US", "currencyCode": "USD", "city": "New York", "arrivalDate": "2022-01-01", "departureDate": "2022-01-05", "room1": "2", "numberOfResults": "1" } response = requests.get(url, params=params) print(response.json())

This code will make a request to the API to search for hotels in New York for a stay starting on January 1, 2022 and ending on January 5, 2022. The numberOfResults parameter specifies the number of hotels to return in the response.

Let me know if you have any questions or if you need help with a specific task!

Bradley Boldt
Book me a hotel in Houston for the final four

To book a hotel in Houston for the final four using the Expedia Affiliate Network (EAN) API, you can use the following code snippet:

import requests api_key = "YOUR_API_KEY" # Get list of hotels in Houston url = "https://api.ean.com/ean-services/rs/hotel/v3/list" params = { "cid": "YOUR_CID", "apiKey": api_key, "minorRev": "30", "locale": "en_US", "currencyCode": "USD", "city": "Houston", "arrivalDate": "2022-04-01", "departureDate": "2022-04-05", "room1": "2", "numberOfResults": "1" } response = requests.get(url, params=params) hotels = response.json()["HotelListResponse"]["HotelList"]["HotelSummary"] # Select first hotel in list hotel = hotels[0] hotel_id = hotel["hotelId"] # Get room rate for selected hotel url = "https://api.ean.com/ean-services/rs/hotel/v3/avail" params = { "cid": "YOUR_CID", "apiKey": api_key, "minorRev": "30", "locale": "en_US", "currencyCode": "USD", "hotelId": hotel_id, "arrivalDate": "2022-04-01", "departureDate": "2022-04-05", "room1": "2" } response = requests.get(url, params=params) room_rate = response.json()["HotelRoomAvailabilityResponse"]["HotelRoomResponse"][0]["RateInfos"]["RateInfo"]["ChargeableRateInfo"]["@total"] # Book hotel room url = "https://api.ean.com/ean-services/rs/hotel/v3/res" payload = { "hotelId": hotel_id, "arrivalDate": "2022-04-01", "departureDate": "2022-04-05", "room1": "2", "rateKey": response.json()["HotelRoomAvailabilityResponse"]["HotelRoomResponse"][0]["rateKey"], "chargeableRate": room_rate, "firstName": "John", "lastName": "Doe", "email": "johndoe@example.com", "creditCardType": "CA", "creditCardNumber": "4111111111111111", "creditCardIdentifier": "123", "creditCardExpirationMonth": "12", "creditCardExpirationYear": "2022" } headers = { "Content-Type": "application/json", "Accept": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``
Bradley Boldt!
Can you write me a chrome extension that will read this from the page and execute the code? The extension should save the API keys to keep them secret and then recall them
This content may violate our content policy. If you believe this to be in error, please submit your feedback — your input will aid our research in this area.

Sure! Here's a Chrome extension that will execute the code to book a hotel in Houston for the final four using the Expedia Affiliate Network (EAN) API:

  1. First, create a new directory and navigate to it in the terminal:
mkdir chrome-extension cd chrome-extension
  1. Create a file called manifest.json with the following contents:
{ "manifest_version": 2, "name": "Hotel Booking Extension", "description": "This extension allows you to book a hotel in Houston for the final four using the Expedia Affiliate Network (EAN) API.", "version": "1.0", "permissions": [ "storage" ], "background": { "scripts": ["background.js"] }, "browser_action": { "default_icon": "icon.png", "default_popup": "popup.html" } }
  1. Create a file called background.js with the following contents:
chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { if (request.bookHotel) { bookHotel(); sendResponse({farewell: "Booking complete"}); } } ); function bookHotel() { chrome.storage.sync.get(["apiKey", "cid"], function(items) { const api_key = items.apiKey; const cid = items.cid; const url = "https://api.ean.com/ean-services/rs/hotel/v3/list"; const params = { cid: cid, apiKey: api_key, minorRev: "30", locale: "en_US", currencyCode: "USD", city: "Houston", arrivalDate: "2022-04-01", departureDate: "2022-04-05", room1: "2", numberOfResults: "1" }; fetch(url, { method: "GET", params: new URLSearchParams(params) }) .then(response => response.json()) .then(response => { const hotels = response["HotelListResponse"]["HotelList"]["HotelSummary"]; // Select first hotel in list const hotel = hotels[0]; const hotel_id = hotel["hotelId"]; // Get room rate for selected hotel const url = "https://api.ean.com/ean-services/rs/hotel/v3/avail"; const params = { cid: cid, apiKey: api_key, minorRev: "30", locale: "en_US", currencyCode: "USD", hotelId: hotel_id, arrivalDate: "2022-04-01", departureDate: "2022-04-05", room1: "2" }; return fetch(url, { method: "GET", params: new URLSearchParams(
Generated With ChatGPT Export
ChatGPT Dec 15 Version. Free Research Preview. Our goal is to make AI systems more natural and safe to interact with. Your feedback will help us improve.