로또 당첨번호 조회 API 테스트
🛠 만들었어요

로또 당첨번호 조회 API 테스트

이서이준아빠
· · 조회 463 · 댓글 2

[로또 당첨번호 조회 API 테스트 안내]

로또 당첨번호 조회 API를 외부 테스트용으로 공개합니다.
테스트를 원하시는 분은 이메일로 토큰을 요청하신 뒤 아래 방식으로 호출해 주세요.

파이썬으로 최근 3년간 로또 당첨 번호 스크래핑-DB저장-매주 토요일 오후 9시30분에 당첨번호 자동 수집

 

최근 3년간 로또당첨 번호만 조회가 가능하면 매주 토요일 9시 30분 이후 수집이 됩니다.

로또 당첨번호 데이터를 직접 수집하고 정리할 필요 없이,
API 호출만으로 최신 회차와 과거 회차 데이터를 가져와
각자 원하는 방식의 통계, 분석, 추천번호 생성기를 만들 수 있습니다.

 

이 API로 할 수 있는 것

- 내 사이트에 최신 로또 당첨번호 표시
- 특정 회차 또는 기간별 당첨번호 조회
- 최근 3개월/1년/3년 기준 통계 분석
- 번호별 출현 빈도, 홀짝 비율, 고저 번호 비율 분석
- 과거 데이터를 활용한 나만의 추천번호 생성기 제작
- 블로그/커뮤니티/게시판용 로또 위젯 제작
- PHP, JavaScript, Python 등에서 JSON 데이터 연동
- 매주 수동 입력 없이 자동 수집 데이터 활용


 

아래링크는 구현 예시 페이지입니다.

https://smartboard.dothome.co.kr/lotto/


API 주소(토큰없이 링크 누르시면 에러발생합니다.) - 아래 메일로 요청해 주세요
https://smartboard.dothome.co.kr/api/lotto_results.php

인증 방식
요청 헤더에 아래 값을 넣어야 합니다.

X-LOTTO-TOKEN: 전달받은_토큰


토큰 요청
테스트용 토큰이 필요하신 분은 아래 정보를 포함해 이메일로 요청해 주세요.

이메일: [email protected]

요청 양식
이름 또는 닉네임:
사용 목적:
연락 가능한 이메일:

지원 파라미터
limit     조회 개수 예: limit=100
round_no  특정 회차 조회 예: round_no=1226
from      조회 시작일 예: from=2024-01-01
to        조회 종료일 예: to=2026-06-04

요청 예시

최근 100개 조회:
curl -H "X-LOTTO-TOKEN: 전달받은_토큰" "https://smartboard.dothome.co.kr/api/lotto_results.php?limit=100"

특정 회차 조회:
curl -H "X-LOTTO-TOKEN: 전달받은_토큰" "https://smartboard.dothome.co.kr/api/lotto_results.php?round_no=1226"

기간 조회:
curl -H "X-LOTTO-TOKEN: 전달받은_토큰" "https://smartboard.dothome.co.kr/api/lotto_results.php?from=2024-01-01&to=2026-06-04"

PHP 사용 예시

<?php
$apiUrl = 'https://smartboard.dothome.co.kr/api/lotto_results.php?limit=10';
$token = '전달받은_토큰';

$ch = curl_init($apiUrl);
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-LOTTO-TOKEN: ' . $token,
        'Accept: application/json',
    ],
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
print_r($data);
?>

응답 예시

{
  "success": true,
  "rows": [
    {
      "round_no": 1226,
      "draw_date": "2026-05-30",
      "numbers": [4, 6, 13, 17, 26, 28],
      "bonus": 41
    }
  ]
}

참고사항
- 브라우저 주소창에 API 주소만 입력하면 인증 헤더를 넣을 수 없어 정상 조회되지 않을 수 있습니다.
- curl, PHP curl, Postman, JavaScript fetch, Python requests 등으로 테스트해 주세요.
- 테스트용 단일 토큰 방식입니다.
- 토큰은 외부에 공개하지 말아 주세요.
- 과도한 반복 요청은 제한될 수 있습니다.
- 데이터는 수집 시점 기준이며 공식 보증 데이터는 아닙니다.




파일 첨부하는곳이 없어 아래 코드를 그대로 복사후 토큰입력 후 서버에 올려 테스트 해 보세요

<?php
// lotto_api_test.php

$apiUrl = 'https://smartboard.dothome.co.kr/api/lotto_results.php';
$apiToken = 'YOUR_LOTTO_TOKEN_HERE';

$limit = isset($_GET['limit']) ? max(1, min(500, (int)$_GET['limit'])) : 20;
$roundNo = trim((string)($_GET['round_no'] ?? ''));
$from = trim((string)($_GET['from'] ?? ''));
$to = trim((string)($_GET['to'] ?? ''));

$params = [
    'limit' => $limit,
];

if ($roundNo !== '') {
    $params['round_no'] = $roundNo;
}
if ($from !== '') {
    $params['from'] = $from;
}
if ($to !== '') {
    $params['to'] = $to;
}

$requestUrl = $apiUrl . '?' . http_build_query($params);
$responseBody = '';
$errorMessage = '';

$ch = curl_init($requestUrl);
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_HTTPHEADER => [
        'X-LOTTO-TOKEN: ' . $apiToken,
        'Accept: application/json',
    ],
]);

$responseBody = curl_exec($ch);
$statusCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($responseBody === false) {
    $errorMessage = curl_error($ch);
}

curl_close($ch);

$data = null;
if ($responseBody !== false && $responseBody !== '') {
    $data = json_decode($responseBody, true);
}

function h($value): string
{
    return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
}
?>
<!doctype html>
<html lang="ko">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>로또 API 테스트</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
</head>
<body>
  <main class="container py-4">
    <h1 class="h3 mb-3">로또 API 테스트</h1>

    <form method="get" class="row g-2 mb-4">
      <div class="col-12 col-md-2">
        <label class="form-label" for="limit">조회 개수</label>
        <input class="form-control" id="limit" name="limit" type="number" min="1" max="500" value="<?= h($limit) ?>">
      </div>
      <div class="col-12 col-md-2">
        <label class="form-label" for="round_no">회차</label>
        <input class="form-control" id="round_no" name="round_no" value="<?= h($roundNo) ?>" placeholder="1226">
      </div>
      <div class="col-12 col-md-3">
        <label class="form-label" for="from">시작일</label>
        <input class="form-control" id="from" name="from" type="date" value="<?= h($from) ?>">
      </div>
      <div class="col-12 col-md-3">
        <label class="form-label" for="to">종료일</label>
        <input class="form-control" id="to" name="to" type="date" value="<?= h($to) ?>">
      </div>
      <div class="col-12 col-md-2 d-flex align-items-end">
        <button class="btn btn-primary w-100" type="submit">조회</button>
      </div>
    </form>

    <div class="mb-3">
      <strong>요청 URL</strong>
      <pre class="bg-light border rounded p-3"><?= h($requestUrl) ?></pre>
    </div>

    <?php if ($errorMessage !== ''): ?>
      <div class="alert alert-danger">
        API 요청 실패: <?= h($errorMessage) ?>
      </div>
    <?php elseif (!is_array($data)): ?>
      <div class="alert alert-warning">
        JSON 응답을 해석하지 못했습니다.
      </div>
      <pre class="bg-light border rounded p-3"><?= h($responseBody) ?></pre>
    <?php else: ?>
      <div class="alert <?= !empty($data['success']) ? 'alert-success' : 'alert-danger' ?>">
        HTTP <?= h($statusCode) ?> /
        <?= h($data['message'] ?? (!empty($data['success']) ? '조회 성공' : '조회 실패')) ?>
      </div>

      <?php $rows = $data['rows'] ?? []; ?>
      <?php if (is_array($rows) && count($rows) > 0): ?>
        <div class="table-responsive">
          <table class="table table-bordered table-sm align-middle">
            <thead>
              <tr>
                <th>회차</th>
                <th>추첨일</th>
                <th>번호</th>
                <th>보너스</th>
              </tr>
            </thead>
            <tbody>
              <?php foreach ($rows as $row): ?>
                <tr>
                  <td><?= h($row['round_no'] ?? '') ?></td>
                  <td><?= h($row['draw_date'] ?? '') ?></td>
                  <td>
                    <?php
                    $numbers = $row['numbers'] ?? [];
                    echo h(is_array($numbers) ? implode(', ', $numbers) : '');
                    ?>
                  </td>
                  <td><?= h($row['bonus'] ?? '') ?></td>
                </tr>
              <?php endforeach; ?>
            </tbody>
          </table>
        </div>
      <?php else: ?>
        <p class="text-muted">조회 결과가 없습니다.</p>
      <?php endif; ?>

      <h2 class="h5 mt-4">원본 JSON</h2>
      <pre class="bg-light border rounded p-3"><?= h(json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)) ?></pre>
    <?php endif; ?>
  </main>
</body>
</html>

원하는 반응: 그냥 구경만 냉정한 평가 테스트 참여 버그 제보
마감 2026.06.30 마감됨

댓글 (2)

로그인 후 댓글을 남길 수 있습니다.
이서이준아빠

아이디어를 주시면 적극 반영해 보도록 해 보겠습니다.

t

로또 번호 APi도 좋은데. 로또가 되면 더 좋겠네요.