# US Lottery Draw Results — Powerball & Mega Millions (`zinin/us-lottery-draw-results`) Actor

Collect dated Powerball and Mega Millions draw observations from New York official feeds. Export numbers, optional multipliers, Double Play, source fields and coverage diagnostics.

- **URL**: https://apify.com/zinin/us-lottery-draw-results.md
- **Developed by:** [Tim Zinin](https://apify.com/zinin) (community)
- **Categories:** Games, Business
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.85 / 1,000 lottery draw delivereds

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

## US Lottery Draw Results — Powerball & Mega Millions

Collect published draw observations from two New York State Gaming Commission datasets. Export numbers, bonus balls, optional multipliers and Double Play fields with the original source values and observation timestamp. Useful for lottery results pages, dataset reconciliation and research pipelines.

Independent tool using public feeds; no regulator or lottery affiliation. Results are not certified tickets, payout records, winning-number predictions or advice on choosing bets. Historical number matrices have changed: validation checks structure and dates, without certifying every historical rule era.

### Quick start

Choose one or both games, set an inclusive date range if needed, and optionally set **Max total charge** under run options to bound paid delivery. In API calls this is `maxTotalChargeUsd`. Allow at least 90 seconds and 512 MB. The form example returns up to five newest observations per game:

```json
{
  "games": ["powerball", "megamillions"],
  "maxDrawsPerGame": 5
}
```

With no INPUT record or `{}`, both games are selected, dates run from 30 calendar dates before today UTC through today, inclusive, and the maximum is 100 per game. This is a date query, not a promise that a draw occurred on every date. Future date bounds do not produce predictions.

| Input | Meaning |
|---|---|
| `games` | `powerball`, `megamillions`, or both; no duplicate values |
| `dateFrom` | Inclusive `YYYY-MM-DD`; default is today minus 30 calendar days in UTC |
| `dateTo` | Inclusive `YYYY-MM-DD`; default is today UTC |
| `maxDrawsPerGame` | Integer 1–1000; default 100, form example 5 |

Powerball's feed starts on 2010-02-03 and Mega Millions on 2002-05-17. A selected range must not begin before the history of any selected game. Both games use the same range. To retrieve older Mega Millions history, select that game alone. Unknown input fields and invalid dates are rejected.

### Results

The default Dataset contains two record types. Filter `recordType=lottery_draw` for billable observations. `recordType=diagnostic` describes source or budget limitations and requests no result event.

| Draw field | Meaning |
|---|---|
| `id`, `game`, `drawDate` | Stable game/date identity and the source's draw date |
| `numbers`, `bonusBall` | Five main numbers in source order and the separate bonus ball |
| `multiplier` | Optional published multiplier; `null` when not supplied |
| `doublePlayNumbers`, `doublePlayBonusBall` | Optional Powerball Double Play values; `null` when not supplied |
| `contentDigest` | SHA-256 of normalized facts; excludes observation time, so feed revisions can be detected |
| `validation` | `structural_not_rules_era_certification` |
| `source` | Dataset ID, publisher, exact draw-query URL, observation time and raw date/number fields |
| `billing` | Whether this row requested a result event; settlement is unconfirmed at the instant of writing |

`source` includes `rawDrawDate`, `rawWinningNumbers`, `rawBonusBall`, `rawMultiplier` and `rawDoublePlayWinningNumbers`. Missing optional fields remain `null`. The digest is a consistency key, not an authenticity signature. Save the Dataset in your own workflow if you want a historical archive or comparisons; this version does not maintain cross-run state.

Rows are grouped by game alphabetically (`megamillions` then `powerball`), with newest draws first within each game. Under a tight run budget the earlier game can consume the allowance first. Run the games separately when you need independent budgets.

`OUTPUT` in the default key-value store is a summary containing counts, configuration and per-game coverage. It contains no draw records. When present, check these fields:

- `sourceComplete`: all selected queries returned successfully without hitting the result cap. It does **not** prove that every scheduled draw is present in the publisher's dataset.
- `deliveryComplete`: all collected observations were delivered and their result events verified. Source completeness is separate.
- `coverage[].rangeComplete` and `hasMore`: whether one lookahead row showed truncation; older draws are omitted when truncated.
- `coverage[].status`: `read` or `failed`. A successful empty date query is distinct from a failed source.

`confirmedResultEvents` counts events confirmed by this process; compare with the settled run counters during recovery. `datasetWritesAcknowledged` includes acknowledged diagnostic writes as well as draw rows. `deliveryUncertain` flags a write/charge uncertainty when available; a failed run may have no saved summary. A successful source response truncated by the configured maximum is reported as `SOURCE_TRUNCATED`; `SOURCE_PARTIAL` means at least one selected source failed.

One failed game does not discard valid observations from the other. Duplicate, out-of-range, malformed or unordered records reject that game's response atomically. If no usable observations are obtained and any source fails, the run fails with `SOURCE_UNAVAILABLE`. A valid empty query succeeds with zero result events. Truncated or partly unavailable output ends with a visible partial status.

### Pricing and recovery

The active price shown in Apify applies. One `result-found` event is requested per delivered draw, including repeated observations in later runs and valid observations from a partial run. A platform start charge may also apply. Diagnostics do not request result events; this does not eliminate the start charge. No separate default-Dataset-item fee is supported by this version.

Optionally set **Max total charge** to bound paid delivery. A verified unset limit permits delivery within the source and size bounds. An explicit zero prevents paid rows. Unreadable or inconsistent run-limit settings stop before paid delivery with `BUDGET_UNREADABLE`. An insufficient finite limit yields `budget_stopped` and no further paid rows. The program uses exact decimal comparisons and verifies the named event count after each delivery.

A failed write or uncertain charge is not automatically retried. Inspect the Dataset and settled run counters before starting another run: delivered rows or charges can exist even if `OUTPUT` is missing after a late failure. The Dataset's `unconfirmed_at_write` label is intentional; it is not the final settlement receipt. A durable same-run claim prevents automatic replay after a restarted container; this version does not resume interrupted work or claim migration recovery. A new run can legitimately retrieve and charge for the same observations again.

### Sources and limits

- [Official Powerball draw feed](https://data.ny.gov/resource/d6yy-54nr.json)
- [Official Mega Millions draw feed](https://data.ny.gov/resource/5xaw-6ayf.json)

Fixed public HTTPS sources only, no credentials, caller URLs or redirects. Each request has a 20-second timeout and a 2 MiB decoded response limit. Up to 1001 source records per game are read to return at most 1000. There are no automatic source retries. The full collector result and summary each have a local 4 MiB limit; this is a product limit, not a statement about Apify's storage capacity.

Feed publication delays, corrections or source outages are possible. A successful query is not an independently certified draw calendar, payout or jackpot record. No probability estimates, odds optimization or jackpot amount is supplied.

# Actor input Schema

## `games` (type: `array`):

Powerball and/or Mega Millions. Each game is fetched independently; output is grouped alphabetically by game, then newest draw first.

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

YYYY-MM-DD. Omit to start 30 calendar dates before today UTC. Powerball starts 2010-02-03; Mega Millions starts 2002-05-17.

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

YYYY-MM-DD. Omit for today UTC. A future date does not forecast future draws.

## `maxDrawsPerGame` (type: `integer`):

1–1000 per game, default 100. One extra row detects truncation; when truncated, newest draws are retained.

## Actor input object example

```json
{
  "games": [
    "powerball",
    "megamillions"
  ],
  "maxDrawsPerGame": 5
}
```

# Actor output Schema

## `results` (type: `string`):

Filter recordType=lottery\_draw for observations. Diagnostic rows are not draw results and request no result event.

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

When present, inspect sourceComplete, deliveryComplete and per-game coverage. OUTPUT can be absent after a late failed run even if Dataset rows were delivered or charged; inspect Dataset and settled run counters.

# 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 = {
    "games": [
        "powerball",
        "megamillions"
    ],
    "maxDrawsPerGame": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("zinin/us-lottery-draw-results").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 = {
    "games": [
        "powerball",
        "megamillions",
    ],
    "maxDrawsPerGame": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("zinin/us-lottery-draw-results").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 '{
  "games": [
    "powerball",
    "megamillions"
  ],
  "maxDrawsPerGame": 5
}' |
apify call zinin/us-lottery-draw-results --silent --output-dataset

```

## MCP server setup

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

```

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/GpJeACqLmhEkrl2dX/builds/SMF2DV7JJpffaPeAB/openapi.json
