DEV Community

Cover image for How to Pull Agoda Hotel Prices into Python with an Apify Actor
ReventaData
ReventaData

Posted on Originally published at apify.com

How to Pull Agoda Hotel Prices into Python with an Apify Actor

By the end of this tutorial you will have a Python script that asks for the hotels in one Agoda city for one stay, waits for the run to finish, and prints one line per hotel with its name, its price per night and its cancellation terms. The output is JSON rows you can store, filter or load into a spreadsheet.

Agoda shows a different price for every pair of dates you pick. Comparing a few hotels for one stay means opening each property page by hand and copying the numbers. This guide replaces that with one API call from Python.

We use the Agoda Hotel Scraper Actor (reventadata/agoda-scraper) from Python with the official apify-client package. The Actor reads public search results on agoda.com. It needs no login, and it returns the hotels the search page lists for the dates you set.


Prerequisites

To follow this tutorial, you need:

  1. Python 3 installed on your machine.
  2. The Apify API client for Python. Install or upgrade it with:
pip install -U "apify-client~=3.0"
Enter fullscreen mode Exit fullscreen mode
  1. An Apify account and your API token from the API & Integrations page in the Apify Console.

Set the token as an environment variable in your terminal:

export APIFY_API_TOKEN="your_apify_token_here"
Enter fullscreen mode Exit fullscreen mode

What you'll achieve

Each dataset row is one hotel. The main fields are propertyId, name, url, stars, reviewScore, reviewCount, address, pricePerNight, pricePerNightExclTaxes, priceTotal, originalPrice, discount, currency, freeCancellation, cheapestRoomCancellationType, payLater and soldOut. The checkIn, checkOut and nights fields repeat the stay you searched.

Example use case: list the hotels in Barcelona for one night in December, with the price per night and the cancellation terms, then save the rows to a file each morning.

The rows below are a sample from a run dated 2026-11-20. Agoda changes its prices, so a run today can show different numbers. This is one hotel from that sample, with the main fields only:

{
  "propertyId": 86413,
  "name": "Hilton Barcelona",
  "stars": 4,
  "reviewScore": 8.6,
  "reviewCount": 981,
  "address": {"countryCode": "ES", "country": "Spain", "city": "Barcelona", "area": "Les Corts"},
  "pricePerNight": 172.33,
  "pricePerNightExclTaxes": 139.86,
  "priceTotal": 172.33,
  "currency": "EUR",
  "freeCancellation": true,
  "cheapestRoomCancellationType": "NonRefundable",
  "checkIn": "2026-12-20",
  "checkOut": "2026-12-21",
  "nights": 1
}
Enter fullscreen mode Exit fullscreen mode

Step 1: Open the Actor

Open the Agoda Hotel Scraper page on Apify Store. It lists the input fields and the output fields. You can also run the Actor from the Console, but this guide calls it from Python.


Step 2: Set the search inputs

The Actor takes its search from the input you pass to it. These are the fields this guide uses:

Field Type What it does
cityId integer The Agoda city id. Barcelona is 2002. It is the city value in an Agoda search address.
checkIn string Check-in date, YYYY-MM-DD.
checkOut string Check-out date, YYYY-MM-DD, after check-in.
adults integer Adults. Default 2.
rooms integer Rooms. Default 1.
currency string Three-letter currency code for every price. Default EUR.
maxItems integer Maximum hotels saved.
maxPages integer Maximum result pages read, 45 hotels each.

A city name is not resolved to an id, so use cityId or paste an Agoda search address into cityUrl. Create the client and define the input:

import os
from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_API_TOKEN"])

run_input = {
    "cityId": 2002,
    "checkIn": "2026-12-20",
    "checkOut": "2026-12-21",
    "adults": 2,
    "rooms": 1,
    "currency": "EUR",
    "maxItems": 20,
    "maxPages": 2,
}
Enter fullscreen mode Exit fullscreen mode

Apart from the dates, this is the Store's prefilled input; adults, rooms and currency show their defaults. The sample rows in this post came from a run with maxItems set to 10 and the default dates, 30 days ahead.


Step 3: Run the Actor

Call the Actor and wait for it to finish:

run = client.actor("reventadata/agoda-scraper").call(run_input=run_input)

if run.status != "SUCCEEDED":
    raise SystemExit(f"The run ended with status {run.status}. Check its log in the Console.")

items = client.dataset(run.default_dataset_id).list_items().items
Enter fullscreen mode Exit fullscreen mode

The call method starts the run, waits for it to finish, and returns a run object. The script checks run.status before it reads any rows. A run that does not succeed stops the script with a message.


Step 4: Print the results

Print one line per hotel:

for hotel in items:
    name = hotel["name"].strip()
    price = hotel["pricePerNight"]
    cancel = hotel["cheapestRoomCancellationType"]
    print(f"{name}: {price} {hotel['currency']} per night, cheapest offer {cancel}")
Enter fullscreen mode Exit fullscreen mode

Some prices are null. A sold-out hotel has no price, so check for None before you do arithmetic on pricePerNight.


Step 5: Save the rows

Write the rows to a JSON file that you can open in a spreadsheet tool:

import json

with open("agoda_hotels.json", "w", encoding="utf-8") as f:
    json.dump(items, f, ensure_ascii=False, indent=2)
Enter fullscreen mode Exit fullscreen mode

Understanding your results

pricePerNight is the all-inclusive price per night of the first offer the search lists for the hotel. pricePerNightExclTaxes is the same offer without taxes and fees. priceTotal is the same offer for the whole stay. For a one-night stay, the per-night and total fields match, as they do in the sample.

originalPrice is the crossed-out price before the discount, and discount is the discount Agoda reports for the offer. In the sample, two hotels carry a discount. Storni Barcelona shows a discount of 10, with a crossed-out price of 158.95 and a price per night of 152.10.

The cancellation fields need care. freeCancellation is true when Agoda lists a free-cancellation option for the property. It may describe a different offer from the one the price fields describe. cheapestRoomCancellationType is the cancellation type of the offer the prices belong to. In this sample, every hotel has freeCancellation set to true, but the cheapest offer is NonRefundable for nine of the ten hotels in the sample. Read cheapestRoomCancellationType before you tell anyone that a hotel can be cancelled for free.

reviewScore runs from 0 to 10, and reviewCount shows how many guests scored it, so read the two together.


Pro tips and advanced usage

Narrow the search with the filters the Actor accepts before the rows are saved:

  • minPrice and maxPrice keep only hotels whose all-inclusive price per night falls in the band you set.
  • minReviewScore keeps only hotels with a score at or above the value you set. Hotels with no score are dropped.
  • minStars keeps only hotels with a star rating at or above the value you set.
  • includeSoldOut is off by default. Turn it on only if you want hotels that have no price for the dates.

To compare two stays, change checkIn and checkOut and run the script again. Save each output file with the dates in its name, so the comparison stays clear.

Keep maxItems and maxPages small while you test. The Actor's own description says a large city can have thousands of hotels, so a small cap keeps a test run short.

Note: the Actor reads public pages and sends no login. Check Agoda's terms of use before you use the data for your own project.


Troubleshooting common issues

If run.status is not SUCCEEDED, open the run's log in the Apify Console. The log shows the message the Actor wrote. A checkOut date on or before checkIn, or a currency that is not a three-letter code, stops the run before any search starts.

If the run ends with no rows, check the cityId and the dates first. Then try the same input again later.

If a field is null for one hotel, it is not an error. Some hotels have no price for the dates, no score or no star rating, and the Actor keeps the row with the field left empty.


Next steps

Start with one city and one night, then add the filters once the rows look right. Put the script on a timer on your own machine if you want a daily copy of the same search.

For current pricing and details, see the Store page.

About the author: reventadata builds public-data scrapers for the Apify Store.

Try the script for a city you know, and tell us which fields you would add.

Top comments (0)