Skip to content
API documentation

Lottery API Quickstart: Make Your First Request

Try a sandbox request, authenticate with an API key and query lottery draw results. Follow practical request examples and error-handling guidance.

On this page

1. Choose the base URL

Use the versioned /v1 API namespace below. Start with the sandbox request on this page to test fixed sample data, then create an API key in your account for live requests. Sandbox fixtures do not demonstrate live result freshness.

https://api.lotteryfeedapi.com/v1

2. Send a bearer token

Every production request should include Authorization: Bearer <token>. Create and rotate live tokens from the authenticated API keys page, and keep them in server-side secret storage.

curl -sS "https://api.lotteryfeedapi.com/v1/results/latest?state=MD&ball_count=3&short=1&limit=25" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY"

Test from your account

Open Account -> API keys and choose an endpoint preset next to a key. The playground preselects the safe key prefix, lets you paste the raw token only in your browser session, runs latest/history/catalog/status/checker endpoints, and generates cURL, Node.js, PHP, and Python snippets for the same request. Snippets use an environment variable by default; inline-token snippets require an explicit browser-only toggle.

https://lotteryfeedapi.com/account/api-keys
https://lotteryfeedapi.com/api-docs/playground?endpoint=latest&state=MD&ball_count=3&limit=25&key_prefix=lf_live_...&short=1

Check integration health after sign-in

Use the private account integration center after the first request. It groups active keys, daily usage, webhook delivery status, plan freshness, and one next recommended action. Public docs link to this flow for handoff, but account pages stay noindex and never expose raw bearer tokens, request bodies, private request logs, or webhook secrets to crawlers.

https://lotteryfeedapi.com/account
https://lotteryfeedapi.com/account/api-keys
https://lotteryfeedapi.com/account/webhooks#delivery-log

Sandbox request

Use a reserved lf_sandbox_* bearer token when you need deterministic sample data without waiting for a live draw. The documented legacy demo token is lf_test_demo_sandbox; other lf_test_* values are not sandbox credentials. Sandbox requests return fixed fixtures, include x-lottery-feed-access: sandbox, do not read the live feed, and do not count as production usage. Use lf_live_* keys for real customer data and lf_dev_* for persisted development keys.

curl -sS "https://api.lotteryfeedapi.com/v1/results/latest?state=MD&ball_count=3&short=1&limit=25" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer lf_test_demo_sandbox"

Latest response

`generated_at` is the feed response timestamp. `draw_date` is the lottery result date customers should display and store. Store `numbers_formatted`, `source_confidence.level`, `provenance.role`, and the returned links instead of scraping public pages.

{
  "generated_at": "2026-06-03T17:20:00.000Z",
  "filters": {
    "state": "MD",
    "ball_count": "3"
  },
  "count": 1,
  "returned_count": 1,
  "total_count": 1,
  "limit": 25,
  "has_more": false,
  "data": [
    {
      "game_code": "md-pick3-midday",
      "name": "Maryland Pick 3 Midday",
      "state": "Maryland",
      "state_code": "MD",
      "ball_count": 3,
      "draw_date": "2026-06-03",
      "numbers": ["2", "3", "6"],
      "numbers_formatted": "2-3-6",
      "numbers_string": "2-3-6",
      "status": "official",
      "source_confidence": {
        "level": "official",
        "label": "Official source",
        "policy": "Numbers were published from the official or canonical lottery source path."
      },
      "provenance": {
        "label": "mdlottery.com",
        "role": "official",
        "provider": "mdlottery.com",
        "display": "mdlottery.com published this result."
      },
      "links": {
        "canonical": "/results/md-pick3-midday/2026-06-03",
        "lottery": "/lotteries/md-pick3-midday",
        "api": "/v1/results/latest/md-pick3-midday",
        "api_docs": "/api-docs/results",
        "api_integration": "/lotteries/md-pick3-midday/api-integration",
        "schedule_api": "/v1/schedules?game_code=md-pick3-midday&date=2026-06-03",
        "history": "/v1/results/history?date=2026-06-03&game_code=md-pick3-midday",
        "history_page": "/results/md-pick3-midday/2026-06-03"
      }
    }
  ]
}

JavaScript fetch

Use a server-side environment variable for the API key. Do not ship customer bearer tokens into browser bundles.

const response = await fetch('https://api.lotteryfeedapi.com/v1/results/latest?state=MD&ball_count=3&short=1&limit=25', {
  headers: {
    accept: 'application/json',
    authorization: `Bearer ${process.env.LOTTERY_FEED_API_KEY}`
  }
});

if (!response.ok) throw new Error(`Lottery Feed API failed: ${response.status}`);
const payload = await response.json();

Python

Keep timeouts explicit so customer jobs fail fast and can retry cleanly.

import os
import requests

response = requests.get(
    'https://api.lotteryfeedapi.com/v1/results/latest',
    params={'state': 'MD', 'ball_count': 3, 'limit': 25},
    headers={'Authorization': f"Bearer {os.environ['LOTTERY_FEED_API_KEY']}"},
    timeout=10,
)
response.raise_for_status()
payload = response.json()

PHP

The endpoint returns compact JSON read models, so clients can decode directly into arrays or DTOs.

$token = getenv('LOTTERY_FEED_API_KEY');
$url = 'https://api.lotteryfeedapi.com/v1/results/latest?state=MD&ball_count=3&short=1&limit=25';

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Accept: application/json',
        'Authorization: Bearer ' . $token,
    ],
    CURLOPT_TIMEOUT => 10,
]);

$payload = json_decode(curl_exec($ch), true, flags: JSON_THROW_ON_ERROR);
curl_close($ch);

Ruby

Use HTTPS, short read timeouts, and retry only idempotent GET requests.

require 'json'
require 'net/http'
require 'uri'

uri = URI('https://api.lotteryfeedapi.com/v1/results/latest')
uri.query = URI.encode_www_form(state: 'MD', ball_count: 3, limit: 25)

request = Net::HTTP::Get.new(uri)
request['Accept'] = 'application/json'
request['Authorization'] = "Bearer #{ENV.fetch('LOTTERY_FEED_API_KEY')}"

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 10) do |http|
  http.request(request)
end

payload = JSON.parse(response.body)

Expected response

The latest endpoint returns bounded customer-facing rows. `draw_date` is the lottery result date and source confidence uses reviewed public labels.

{
  "generated_at": "2026-06-03T17:20:00.000Z",
  "filters": {
    "state": "MD",
    "ball_count": "3"
  },
  "count": 1,
  "data": [
    {
      "game_code": "md-pick3-midday",
      "name": "Maryland Pick 3 Midday",
      "state": "Maryland",
      "state_code": "MD",
      "ball_count": 3,
      "draw_date": "2026-06-03",
      "numbers": ["2", "3", "6"],
      "numbers_formatted": "2-3-6",
      "status": "official"
    }
  ]
}

Next: Polling and integration