# Vietnam Lottery Results Scraper (XSMN, XSMT, XSMB) (`mrbridge/vietnam-lottery-results-scraper`) Actor

Get Vietnamese lottery results (xổ số, XSMN, XSMT, XSMB, KQXS) by region and date. One row per province draw or per drawn number, with all prizes and the lô tô list. Latest draw or date range up to 366 days, from 2008 (North) and 2009 (South, Centre). Export to JSON, CSV or Excel.

- **URL**: https://apify.com/mrbridge/vietnam-lottery-results-scraper.md
- **Developed by:** [MrBridge](https://apify.com/mrbridge) (community)
- **Categories:** News, Other
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.70 / 1,000 lottery draws

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Vietnam Lottery Results Scraper

Vietnam Lottery Results Scraper collects Vietnamese lottery results (xổ số, XSMN, XSMT, XSMB, KQXS) from xsmn.mobi. It covers the three regions, South (XSMN), Centre (XSMT) and North (XSMB), and returns one row per province draw or one row per drawn number, ready for JSON, CSV or Excel.

Set the mode to `latest` and the Actor returns the most recent complete draw of each region, with every prize, the two-digit "lô tô" list and, for the North, the special-prize codes. Set it to `dateRange` with two dates and you get every draw in between, up to 366 days per run, in a stable order.

### What is Vietnam Lottery Results Scraper?

The Vietnamese lotteries run daily draws. The South and the Centre each draw several provinces a day, the North draws once a day under the code `mien-bac`. Vietnam Lottery Results Scraper reads the result page of each region and date, checks that the page is complete, and turns it into structured rows. No API key is needed.

#### What data can I extract with it?

- **Draw rows** (`outputFormat: draw`): date, ISO weekday, region, province name and code, all prizes grouped by tier, the North special-prize codes, the lô tô list (last two digits of every number), the number count (18 for the South and Centre, 27 for the North), the source URL and the scrape time.
- **Number rows** (`outputFormat: number`): date, region, province, tier, position in the tier and the number. One row per drawn number, 18 or 27 rows per draw, for databases and spreadsheets.

Numbers are text, so leading zeros are kept.

#### How can I use the results?

- Build a KQXS archive or a results website without copying pages by hand.
- Research draw history by date, region and province, using `outputFormat: number` rows in databases and spreadsheets, whether you are an analyst or a researcher.
- Feed a chatbot, a notification service or a spreadsheet with the latest XSMN, XSMT or XSMB draw.
- Check a published result for analysis by comparing a stored row with the result for one day and province, using `sourceUrl` to return to its result page.

### How to use it

1. Open the Actor in Apify Console and choose the regions.
2. Pick `latest` for the newest draw, or `dateRange` and fill `dateFrom` and `dateTo`.
3. Optionally list province codes such as `hcm` or `dng` to keep only those provinces. Every code must be valid for the regions you chose (see [Valid province codes](#valid-province-codes)).
4. Choose the output format and start the run. Rows appear in the dataset as they are delivered.

### Input

| Field | Meaning | Default |
|---|---|---|
| `mode` | `latest` or `dateRange` | `latest` |
| `regions` | `south`, `central`, `north` | all three (the Console form pre-selects `south`) |
| `dateFrom` | First day of the range, `YYYY-MM-DD`, `dateRange` only | empty |
| `dateTo` | Last day of the range, `YYYY-MM-DD`. Empty or in the future means today in Vietnam (UTC+7) | empty |
| `provinces` | Province codes in lowercase, for example `hcm`, `dl`, `dng`. The North is `mien-bac`. An unknown code, or a code outside the selected regions, stops the run with a `BAD_INPUT` row | empty (all provinces) |
| `outputFormat` | `draw` or `number` | `draw` |
| `maxDraws` | Hard cap on province draws per run, in both formats | 1000 |

Example input for one day of the three regions:

```json
{
  "mode": "dateRange",
  "dateFrom": "2026-10-24",
  "dateTo": "2026-10-24",
  "regions": ["south", "central", "north"],
  "outputFormat": "draw"
}
```

How many rows to expect from a day: on a Monday the South draws 3 provinces (`hcm`, `dt`, `cm`), so one South day in `number` format gives 54 rows (3 draws of 18 numbers). On a Saturday the South draws 4 provinces. The provinces that draw each day rotate, so the count changes with the weekday.

Invalid input ends the run successfully with one `BAD_INPUT` row in the `errors` dataset and no draw, and no page is requested. It covers a missing `dateFrom` in `dateRange` mode, a date that does not exist, `dateFrom` after `dateTo`, more than 366 days, an unknown province code, and a province code outside the selected regions. The platform still bills the `apify-actor-start` event of the run, even when the input is invalid. Only draws are billed by the Actor itself.

#### Valid province codes

A province code must exist and belong to one of the regions you selected. Otherwise the run stops with one `BAD_INPUT` row. Its `details` object holds:

- `problems`: the list of messages.
- `unknownProvinces`: the codes that do not exist. Present only when such a code is in the input.
- `validCodes`: the codes valid for the selected regions, sorted. Present together with `unknownProvinces`, not otherwise.
- `mismatchedProvinces`: the known codes that belong to a region you did not select, each with its region. This key is present only when such a code is in the input, and absent otherwise.

For example, `["hcm"]` with `regions: ["north"]` gives a `details` object with `problems` and `mismatchedProvinces` (an entry for `hcm`, South) only. The `xyz` code gives `problems`, `unknownProvinces: ["xyz"]` and `validCodes`.

The valid codes by region:

- South (21): `hcm`, `tg`, `kg`, `dl`, `la`, `hg`, `bp`, `vl`, `tv`, `bd`, `tn`, `bth`, `ag`, `st`, `dn`, `ct`, `vt`, `bt`, `bl`, `dt`, `cm`.
- Centre (14): `tth`, `kt`, `kh`, `qng`, `dno`, `dng`, `nt`, `gl`, `qt`, `qb`, `bdi`, `qnm`, `dlk`, `py`.
- North (1): `mien-bac`.

### Output

Draws go to the default dataset. Problems go to a separate `errors` dataset, and these rows are never billed. The `OUTPUT` record of the key-value store summarizes the run.

This is one real row, the Ho Chi Minh City draw of 2026-10-24 (`hcm`), as the Actor builds it from the page:

```json
{
  "drawDate": "2026-10-24",
  "weekday": 6,
  "region": "south",
  "province": "TP HCM",
  "provinceCode": "hcm",
  "prizes": {
    "eighth": [
      "51"
    ],
    "seventh": [
      "554"
    ],
    "sixth": [
      "6781",
      "3056",
      "6237"
    ],
    "fifth": [
      "1148"
    ],
    "fourth": [
      "97890",
      "29567",
      "19053",
      "13566",
      "97760",
      "36035",
      "71847"
    ],
    "third": [
      "90169",
      "37660"
    ],
    "second": [
      "28385"
    ],
    "first": [
      "28505"
    ],
    "special": [
      "698440"
    ]
  },
  "specialCodes": null,
  "loto": [
    "05",
    "35",
    "37",
    "40",
    "47",
    "48",
    "51",
    "53",
    "54",
    "56",
    "60",
    "60",
    "66",
    "67",
    "69",
    "81",
    "85",
    "90"
  ],
  "numberCount": 18,
  "sourceUrl": "https://xsmn.mobi/xsmn-24-10-2026.html",
  "scrapedAt": "2026-10-26T09:38:00.000Z"
}
```

Field notes:

- `prizes` lists the tiers in page order. The South and Centre go from `eighth` to `special`, the North goes from `special` to `seventh` and has no `eighth`.
- `specialCodes` is `null` for the South and Centre and an array of codes (such as `7KE`) for the North. Some old North pages have no code block at all (for example 2008-01-05): `specialCodes` is then `[]`.
- `loto` holds the last two digits of every number, sorted, duplicates kept. Its length equals `numberCount`.
- The North row has `province` set to `Miền Bắc` and `provinceCode` set to `mien-bac`.
- In `number` format each row has `drawDate`, `region`, `province`, `provinceCode`, `tier`, `index` (from 0, in page order) and `number`.

Rows come in plan order: ascending date, then South, Centre, North, then the columns of the page. The order is the same on every run.

### Coverage and history

- The North is available from 2008-01-01. The South and the Centre are available from 2009-01-01.
- A `dateFrom` before those dates is moved to them, with a warning in the log.
- The length of the special prize (ĐB) varies by region and year. Older draws can have 5 or 6 digits (on 2010-03-10, the South shows 6 digits and the Centre 5). The Actor returns them as they appear on the page.
- The North has no draw during Tết 2026, from 2026-02-16 to 2026-02-19. Those days are listed in `noDraw` in the `OUTPUT` record, with no row and no charge. The South draws during Tết.

### Latest mode and draw times

In `latest` mode the Actor tries today's page for each region (day in Vietnam time, UTC+7). If the draw is not complete, it steps back one day at a time, for up to 7 days.

Draws finish at about 16:30 for the South, 17:30 for the Centre and 18:30 for the North (the site announces 18:10 for the North). These times are approximate, the South and Centre times are not published on the site. Before a draw ends you get the previous day's draw. For a daily schedule, start the run after 19:00 Vietnam time (12:00 UTC). The `latestFallbacks` list of the `OUTPUT` record shows which days were stepped back.

### Days without a draw and pending draws

A day without a draw (for example a day when the site shows an empty column) gives no row and no charge. It is counted in the `noDraw` list of the `OUTPUT` record. A draw of today that is still empty or partial is counted in `pending`. A partial page for a past date gives a `DRAW_INCOMPLETE` row in the `errors` dataset, which is never billed. A page that does not exist (HTTP 404) is counted in `pagesByStatus` and is not an error.

### Limits

- `maxDraws` counts province draws in both formats. The default is 1000. A full year of the three regions is about 2,400 draws, so raise `maxDraws` for long ranges.
- Speed: a full year of the three regions (1,095 pages, about 2,400 draws) takes about 20 minutes at the default 512 MB (about 33 minutes at 256 MB). The limit is the response time of the site, not the Actor. Fewer regions or shorter ranges run faster.
- A run covers 366 days at most. Split longer periods into several runs.
- Each run is a snapshot of what the site shows at that moment.
- The platform refuses a maximum charge per run below 0.02 USD.

### Billing

One event is billed per delivered draw, in both formats. In `number` format a draw of 18 or 27 rows is still one event. Errors, days without a draw and pending draws are never billed. The platform bills the `apify-actor-start` event for every run, including a run that ends on a `BAD_INPUT`. The Pricing tab of the Actor shows the current prices.

If you set a maximum charge for the run, the Actor stops cleanly when the budget is used up (`stoppedBy` is `chargeLimit`) and never delivers an unbilled row. The number of draws delivered under a charge limit depends on your price tier, see the Pricing tab.

If the platform moves or restarts the run while it works, the run picks up where it stopped, with no duplicate row and no draw billed twice. If the restart falls in the instant between the delivery of a page and its billing, the draws of that page (4 at most) stay unbilled.

`OUTPUT.drawsCharged` is the Actor's own count of billed draws. After a platform restart, a draw found already saved in the dataset counts as billed, even if the restart happened just before its charge. The bill shown in the Apify Console can therefore be lower than `drawsCharged` by at most `OUTPUT.reconciledDraws`, and never higher. You are never billed twice for a draw.

### Progress in the run log

A long run writes one line to the log about every minute:

```
Progress: 1048/1095 pages done, 2293 draw(s) emitted, 0 error row(s), ETA 54s.
```

It gives the pages done out of the total, the draws delivered so far, the error rows and an estimated time left. In `latest` mode the unit is regions instead of pages. The estimate is pessimistic in the first minutes of a run (it announced over 32 minutes at the start of a 21-minute run) and gets accurate towards the end.

### Blocked pages and early stops

A page refused with 401, 403 or 429 is requested again through another proxy, up to 3 times. After that it gives a `TARGET_BLOCKED` row and the region stops. After 4 blocked pages in a row the run stops cleanly and ends SUCCEEDED.

`stoppedBy` in the `OUTPUT` record says why a run ended early:

- `null`: all the requested work was done.
- `maxDraws`: the `maxDraws` cap was reached.
- `chargeLimit`: the maximum charge set for the run was reached.
- `deadline`: the run reached its internal time limit.
- `circuitOpen`: too many blocked pages in a row.

After a `deadline` or `circuitOpen` stop, up to 36 pages that were already fetched can still be applied, so a few draws may arrive after the stop.

### Frequently asked questions

#### Why does the North have no province column?

The North draws once a day for the whole region, so the Actor returns a single row with the province code `mien-bac`.

#### What do XSMN, XSMT, XSMB and KQXS mean?

XSMN is xổ số miền Nam (South), XSMT is xổ số miền Trung (Centre), XSMB is xổ số miền Bắc (North), and KQXS stands for kết quả xổ số, the lottery results.

#### Can I use Vietnam Lottery Results Scraper via MCP?

Yes. Any Apify Actor can be called from an MCP client through the Apify MCP server. See the [Apify MCP documentation](https://docs.apify.com/platform/integrations/mcp) for the setup.

#### Your feedback

We're always working on improving the performance of our Actors. So if you've got any technical feedback for Vietnam Lottery Results Scraper or simply found a bug, please create an issue on the Actor's [Issues tab](https://apify.com/mrbridge/vietnam-lottery-results-scraper/issues).

An honest review helps the next users decide. You can also bookmark this Actor, and use the Issues tab for bugs or other problems.

More free tools, scrapers, MCP servers and data studies from the same team: [mr-bridge.com](https://mr-bridge.com).

### Legal & responsible use

xsmn.mobi has its own terms of use, and it may restrict automated access or commercial reuse. Before you rely on the output, in particular for commercial use, confirm that your use is permitted by those terms. You remain responsible for how you use the results and for complying with the source's terms and with the laws that apply to you.

# Changelog

This Actor's version history is a separate document: https://apify.com/mrbridge/vietnam-lottery-results-scraper/changelog.md

# Actor input Schema

## `mode` (type: `string`):

'Latest' returns the most recent complete draw of each selected region (it steps back day by day, up to 7 days, when the draw of the day is not out yet). 'Date range' returns every draw between Date from and Date to.

## `regions` (type: `array`):

Regions to collect: South (xsmn), Centre (xsmt) and North (xsmb). The North has a single draw a day, the South and Centre have several provinces.

## `dateFrom` (type: `string`):

First day of the range, used in Date range mode only. Format YYYY-MM-DD. A date before the start of the archive is moved to it.

## `dateTo` (type: `string`):

Last day of the range, used in Date range mode only. Format YYYY-MM-DD. Empty or in the future means today in Vietnam (UTC+7). A run covers 366 days at most.

## `provinces` (type: `array`):

Optional filter on province codes in lowercase, for example hcm, dl, tth, dng. The North draw has the code mien-bac. Every code must exist and belong to a selected region, otherwise the run stops with one BAD_INPUT error that lists the valid codes. Leave empty to keep every province of the selected regions.

## `outputFormat` (type: `string`):

'Draw' returns one row per province draw with all prizes. 'Number' returns one row per drawn number, for databases and spreadsheets. Both formats are billed per draw.

## `maxDraws` (type: `integer`):

Hard cap on the number of province draws returned (and billed) in one run, in both output formats.

## Actor input object example

```json
{
  "mode": "latest",
  "regions": [
    "south"
  ],
  "provinces": [],
  "outputFormat": "draw",
  "maxDraws": 1000
}
```

# Actor output Schema

## `draws` (type: `string`):

Direct link to all dataset items produced by the run.

## `summary` (type: `string`):

Direct link to the OUTPUT record: pages requested, draws returned and billed, days without a draw, pending draws and errors by kind.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "latest",
    "regions": [
        "south"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("mrbridge/vietnam-lottery-results-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "latest",
    "regions": ["south"],
}

# Run the Actor and wait for it to finish
run = client.actor("mrbridge/vietnam-lottery-results-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "latest",
  "regions": [
    "south"
  ]
}' |
apify call mrbridge/vietnam-lottery-results-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mrbridge/vietnam-lottery-results-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/oIL8cbYJgFgNvno9c/builds/haOUfHTTORaU9TU5a/openapi.json
