# New York Win 4 Results Scraper (`automation-lab/new-york-win-4-draw-history`) Actor

Export official New York Win 4 midday and evening winning numbers, draw IDs, prize totals, winner counts, and booster fields by date range.

- **URL**: https://apify.com/automation-lab/new-york-win-4-draw-history.md
- **Developed by:** [Stas Persiianenko](https://apify.com/automation-lab) (community)
- **Categories:** Games
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.80 / 1,000 item extracteds

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## New York Win 4 Results Scraper

Export official **New York Win 4 results** into a clean dataset, grouped by draw date.
Each row can include the Midday and Evening four-digit numbers, official draw IDs,
draw numbers, prize totals, winner counts, and source-provided booster fields.

Use the Actor for one-time analysis, scheduled archive refreshes, spreadsheets,
dashboards, or downstream lottery-data pipelines. It reads the public New York
Lottery data surface directly and does not require a lottery account or browser.

### What does this Actor do?

The Actor accepts an inclusive date range and requests official Win 4 draw records.
It normalizes the two daily draw periods into one stable row per calendar date.

You can:

- collect both Midday and Evening results;
- request Midday-only or Evening-only records;
- limit the number of newest date rows saved;
- preserve individual digits as well as the joined four-digit number;
- retain official identifiers and result provenance;
- schedule the same input for recurring archive refreshes.

### Who is it for?

- Lottery-data publishers maintaining result archives
- Analysts studying historical number sequences
- Spreadsheet users who need typed, repeatable exports
- Developers feeding dashboards, databases, or APIs
- Automation teams comparing successive scheduled datasets

This Actor reports historical results. It does not predict future winning numbers,
check tickets, calculate odds, or place wagers.

### Why use it?

The official website is designed for interactive lookup. This Actor provides a
repeatable machine-readable contract instead:

1. inclusive date filtering;
2. bounded pagination;
3. one predictable record per draw date;
4. separate Midday and Evening objects;
5. direct dataset, API, webhook, and integration access.

No proxy is enabled by default because the official JSON route currently works
directly. Transient network, rate-limit, and server failures receive bounded retries.
Invalid inputs and unexpected upstream response shapes fail clearly rather than
silently producing misleading empty results.

### Getting started

1. Open the Actor input page.
2. Enter `startDate` and `endDate` in `YYYY-MM-DD` format.
3. Choose both draws, Midday only, or Evening only.
4. Set `maxItems` to the maximum number of date rows you need.
5. Click **Start**.
6. Open the default dataset or download JSON, CSV, Excel, XML, RSS, or JSONL.

A small recent range is best for your first run.

### Input parameters

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `startDate` | string | 6 days ago | First included official draw date, `YYYY-MM-DD` |
| `endDate` | string | current UTC date | Last included official draw date, `YYYY-MM-DD` |
| `drawTime` | string | `all` | `all`, `midday`, or `evening` |
| `maxItems` | integer | `100` | Maximum date rows, from 1 to 1,000 |

The inclusive range may span at most 367 calendar dates because the official source
currently exposes approximately one year of Win 4 history. A range outside available
history can correctly return no rows.

### Example input

```json
{
  "startDate": "2026-09-01",
  "endDate": "2026-09-05",
  "drawTime": "all",
  "maxItems": 5
}
```

To collect only the evening period, set `drawTime` to `evening`. The resulting
rows keep `midday` as `null`, making period filtering explicit to downstream code.

### Extracted data

| Field | Meaning |
| --- | --- |
| `drawDate` | Official draw date |
| `game` | Stable game label, `Win 4` |
| `midday` | Midday draw details or `null` |
| `evening` | Evening draw details or `null` |
| `winningNumber` | Joined four-digit result; leading zero is preserved |
| `winningNumbers` | Four individual digit strings |
| `drawId` | Official source record ID |
| `drawNumber` | Official sequence number |
| `boosterNumber` | Source bonus/booster field, or `null` when not supplied |
| `multiplier` | Source multiplier field, or `null` when not supplied |
| `totalPrizesUsd` | Reported total prize amount, or `null` |
| `straightPlayWinners` | Reported Straight Play winner count |
| `boxPlayWinners` | Reported Box Play winner count |
| `sourceUrl` | Official New York Lottery page |
| `retrievedAt` | Collection timestamp in UTC |

Booster and multiplier fields are retained for schema stability but are usually null
for Win 4 because the official source currently returns them empty.

### Example output

```json
{
  "drawDate": "2026-09-05",
  "game": "Win 4",
  "midday": {
    "drawId": "5039236",
    "drawNumber": "23324",
    "winningNumber": "1349",
    "winningNumbers": ["1", "3", "4", "9"],
    "boosterNumber": null,
    "multiplier": null,
    "totalPrizesUsd": 509100,
    "straightPlayWinners": 92,
    "boxPlayWinners": 2728
  },
  "evening": {
    "drawId": "5040416",
    "drawNumber": "23325",
    "winningNumber": "8171",
    "winningNumbers": ["8", "1", "7", "1"],
    "boosterNumber": null,
    "multiplier": null,
    "totalPrizesUsd": 552600,
    "straightPlayWinners": 99,
    "boxPlayWinners": 1497
  },
  "sourceUrl": "https://nylottery.ny.gov/draw-game?game=win4",
  "retrievedAt": "2026-09-13T14:45:00.000Z"
}
```

Official values can be corrected after publication. For auditable pipelines, retain
both `drawId` and `retrievedAt` and compare repeated exports by `drawDate`.

### How much does it cost to export New York Win 4 results?

The Actor uses pay-per-event pricing:

- **$0.005** once per run;
- on the Bronze tier, **$0.008 per saved draw-date row**;
- lower item rates apply on Silver and Gold tiers.

A row can contain both Midday and Evening results; they are not charged separately.
At Bronze pricing, 5 rows cost about **$0.045**, 25 rows about **$0.205**, and
100 rows about **$0.805**, including the run start. Check the live Actor pricing
panel for the tier applicable to your account.

### Scheduling archive refreshes

Create an Apify Schedule with a short rolling date range, such as the previous seven
days. Send the completed dataset to a webhook, Google Sheets, Make, Zapier, or your
own database. Upsert using `drawDate`; compare nested draw IDs or winning numbers to
detect source corrections.

A rolling range is more efficient than downloading the whole available archive on
every schedule. The Actor itself does not retain state between runs.

### Data exports and integrations

The default dataset works with:

- JSON, CSV, Excel, XML, RSS, and JSONL downloads;
- Apify webhooks for completed or failed runs;
- Google Sheets and cloud-storage integrations;
- Make and Zapier workflows;
- Apify API clients for JavaScript and Python.

Nested `midday` and `evening` objects are preserved in JSON. CSV exporters may
flatten or serialize nested values depending on selected dataset fields.

### Run with the Apify API

Replace `YOUR_TOKEN` with an Apify API token.

#### cURL API setup

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/automation-lab~new-york-win-4-draw-history/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"startDate":"2026-09-01","endDate":"2026-09-05","drawTime":"all","maxItems":5}'
```

#### JavaScript API setup

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

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('automation-lab/new-york-win-4-draw-history').call({
  startDate: '2026-09-01',
  endDate: '2026-09-05',
  drawTime: 'all',
  maxItems: 5,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

#### Python API setup

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_TOKEN")
run = client.actor("automation-lab/new-york-win-4-draw-history").call(run_input={
    "startDate": "2026-09-01",
    "endDate": "2026-09-05",
    "drawTime": "all",
    "maxItems": 5,
})
items = client.dataset(run["defaultDatasetId"]).list_items().items
print(items)
```

### Use with MCP and AI assistants

Add this Actor to Claude Code through Apify MCP:

```bash
claude mcp add --transport http apify \
  "https://mcp.apify.com?tools=automation-lab/new-york-win-4-draw-history"
```

#### Claude Desktop, Cursor, and VS Code setup

Use this MCP server configuration in Claude Desktop, Cursor, or VS Code:

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com?tools=automation-lab/new-york-win-4-draw-history"
    }
  }
}
```

Example prompts:

- “Export both New York Win 4 draws from September 1 through September 5, 2026.”
- “Get only midday Win 4 results for the last seven available dates.”
- “Return a JSON dataset I can compare with last week's archive.”

### Reliability and retries

Requests use a 30-second timeout and up to three attempts for temporary network,
HTTP 429, and server failures. Retries use bounded backoff. Stable client errors,
invalid JSON, changed API shapes, and malformed official draw numbers fail the run.

The Actor fetches pages sequentially to avoid unnecessary load and stops once the
requested date-row limit is reached. It does not use residential proxies or launch
a browser in its normal route.

### Limitations

- The official API currently exposes approximately one year of Win 4 results.
- Prize and winner fields depend on what the official source provides.
- Booster and multiplier values are commonly absent for this game.
- Very recent Evening data may not exist yet when a run occurs before publication.
- Scheduled runs can observe later official corrections to prior records.
- This Actor covers New York Win 4 only, not Numbers, Take 5, Lotto, Powerball, or
  Mega Millions.

### Troubleshooting

**Why did the dataset contain no rows?**

Confirm the range is within the source's available history and includes completed
draws. Future dates and older unavailable dates naturally return no results.

**Why is one period null?**

You may have selected one draw period, or the official source may not yet have
published the other draw. Inspect `drawTime` and the run time.

**Why did the run fail after retries?**

Check the log for an official API HTTP status or response-shape message. Retry later
for a temporary upstream outage; do not widen the date range until a small request
works.

**Are leading zeroes preserved?**

Yes. `winningNumber` and every element of `winningNumbers` are strings.

### Responsible use and legality

The Actor collects public factual lottery results from the official New York Lottery
website. Follow applicable source terms, platform rules, and laws. Do not present
historical data as a prediction, guarantee, or gambling recommendation. Verify any
number used to claim a prize against the official New York Lottery source. This
Actor is an independent automation tool and is not endorsed by New York Lottery.

### Related Automation Lab Actors

- [Powerball Winning Numbers Scraper](https://apify.com/automation-lab/powerball-historical-winning-numbers)
- [EuroMillions Results Scraper](https://apify.com/automation-lab/euromillions-results-scraper)

Use those Actors for their respective games. This Actor remains intentionally scoped
to the twice-daily New York Win 4 result archive.

### FAQ

**Does it need a New York Lottery account?**\
No. It reads publicly available official results.

**Can I export one draw period only?**\
Yes. Set `drawTime` to `midday` or `evening`.

**Does `maxItems` count draws or dates?**\
It counts date rows. With `drawTime: all`, one charged row can contain two draws.

**Can it monitor changes?**\
Use an Apify Schedule and compare datasets in your storage or integration. The Actor
produces stable identifiers but does not send change alerts by itself.

**Does it predict likely numbers?**\
No. It exports historical official records only.

# Actor input Schema

## `startDate` (type: `string`):

First draw date to include (YYYY-MM-DD). Defaults to six days before the run.

## `endDate` (type: `string`):

Last draw date to include (YYYY-MM-DD). Defaults to the current UTC date.

## `drawTime` (type: `string`):

Return both draw periods in each date row, or only the selected period.

## `maxItems` (type: `integer`):

Maximum draw-date records saved to the dataset, newest first.

## Actor input object example

```json
{
  "startDate": "2026-09-01",
  "endDate": "2026-09-05",
  "drawTime": "all",
  "maxItems": 20
}
```

# Actor output Schema

## `overview` (type: `string`):

Open normalized draw dates with Midday and Evening winning numbers and draw details.

# 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 = {
    "startDate": "2026-09-01",
    "endDate": "2026-09-05",
    "drawTime": "all",
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("automation-lab/new-york-win-4-draw-history").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 = {
    "startDate": "2026-09-01",
    "endDate": "2026-09-05",
    "drawTime": "all",
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("automation-lab/new-york-win-4-draw-history").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 '{
  "startDate": "2026-09-01",
  "endDate": "2026-09-05",
  "drawTime": "all",
  "maxItems": 20
}' |
apify call automation-lab/new-york-win-4-draw-history --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,automation-lab/new-york-win-4-draw-history"
        }
    }
}
```

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/aFfTYmvunUYvvnpvz/builds/LBhkYwhM7U5ZExw24/openapi.json
