เอกสารการใช้งาน

Thai Lottery API

API Server

Server URL

เรียกใช้งาน thai lottery api ผ่าน https://www.krupreecha.com/api เท่านั้น.

API KEY

ลงทะเบียนเพื่อรับ api key ได้ที่ https://www.krupreecha.com/register .

Params

https://www.krupreecha.com/api/01032564 วัน เดือน ปี ของงวดที่ต้องการรับข้อมูล

Request PHP


// ตัวอย่างการดูหวยงวดวันที่ 1 มีนาคม 2564                                       
$server_url = 'https://www.krupreecha.com/api/01032564';
$api_key = 'api key here';
$header = array(
    "Content-Type: application/json",
    "Accept: application/json",
    "X-API-KEY:".$api_key,
    "domain:".$_SERVER["SERVER_NAME"]
);
$ch = curl_init($server_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
$result = curl_exec($ch);
curl_close($ch);
$json = json_decode($result);

print_r($json);


                                        
Request Ajax


// ตัวอย่างการดูหวยงวดวันที่ 16 กุมภาพันธ์ 2564                                       
var settings = {
  "url": "https://www.krupreecha.com/api/12022564",
  "method": "POST",
  "headers": {
    "Content-Type": "application/json",
    "x-api-key": "api key here",
  },
};

$.ajax(settings).done(function (response) {
  console.log(response);
});


                                        
Request Dart


// ตัวอย่างการดูหวยงวดวันที่ 16 กุมภาพันธ์ 2564                                       
var headers = {
  'Content-Type': 'application/json',
  'x-api-key': 'api key here',
};
var request = http.Request('POST', Uri.parse('https://www.krupreecha.com/api/16022564'));
request.bodyFields = {};
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
  print(await response.stream.bytesToString());
}
else {
  print(response.reasonPhrase);
}


                                        
Request C#


// ตัวอย่างการดูหวยงวดวันที่ 16 กุมภาพันธ์ 2564                                       
var client = new RestClient("https://www.krupreecha.com/api/16022564");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("x-api-key", "api key here");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);


                                        
Request NodeJS (Axios)


// ตัวอย่างการดูหวยงวดวันที่ 16 กุมภาพันธ์ 2564                                       
var axios = require('axios');
var qs = require('qs');
var data = qs.stringify({
  
});
var config = {
  method: 'post',
  url: 'https://www.krupreecha.com/api/16022564',
  headers: { 
    'Content-Type': 'application/json', 
    'x-api-key': 'api key here', 
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});


                                        

JSON Response

Response


{
    "code": "200",
    "drawdate": "1 มีนาคม 2564",
    "result": [
        {
            "id": "lotto_one",
            "name": "รางวัลที่ 1",
            "reword": 6000000,
            "amount": 1,
            "number": "835538"
        },
        {
            "id": "lotto_first_three",
            "name": "เลขหน้า 3 ตัว",
            "reword": 4000,
            "amount": 2,
            "number": [
                "290",
                "838"
            ]
        },
        {
            "id": "lotto_last_three",
            "name": "เลขท้าย 3 ตัว",
            "reword": 4000,
            "amount": 2,
            "number": [
                "051",
                "806"
            ]
        },
        {
            "id": "lotto_last_two",
            "name": "เลขท้าย 2 ตัว",
            "reword": 2000,
            "amount": 1,
            "number": "73"
        },
        {
            "id": "lotto_side_one",
            "name": "รางวัลข้างเคียงรางวัลที่ 1",
            "reword": 2000,
            "amount": 1,
            "number": [
                "835537",
                "835539"
            ]
        },
        {
            "id": "lotto_two",
            "name": "รางวัลที่ 2",
            "reword": 200000,
            "amount": 5,
            "number": [
                "316827",
                "731177",
                "743731",
                "788652",
                "923096"
            ]
        },
        {
            "id": "lotto_three",
            "name": "รางวัลที่ 3",
            "reword": 80000,
            "amount": 10,
            "number": [
                "045942",
                "183440",
                "323456",
                "389816",
                "488050",
                "575910",
                "648700",
                "727081",
                "735004",
                "756048"
            ]
        },
        {
            "id": "lotto_four",
            "name": "รางวัลที่ 4",
            "reword": 40000,
            "amount": 50,
            "number": [
                "942297",
                "529147",
                "469811",
                "679528",
                "000395",
                "712017",
                "484349",
                "970326",
                "099988",
                "826174",
                "649606",
                "552557",
                "082383",
                "806822",
                "488358",
                "871042",
                "817353",
                "054700",
                "669007",
                "438714",
                "516745",
                "104432",
                "825800",
                "588420",
                "542620",
                "105610",
                "759204",
                "904906",
                "343900",
                "487907",
                "150558",
                "894512",
                "314364",
                "948990",
                "760427",
                "374636",
                "531335",
                "834237",
                "494884",
                "814393",
                "410900",
                "126701",
                "301404",
                "183517",
                "058820",
                "906356",
                "053547",
                "612105",
                "258747",
                "221238"
            ]
        },
        {
            "id": "lotto_five",
            "name": "รางวัลที่ 5",
            "reword": 20000,
            "amount": 100,
            "number": [
                "447352",
                "420290",
                "126787",
                "487174",
                "833272",
                "920655",
                "725220",
                "451531",
                "062159",
                "503807",
                "659994",
                "786150",
                "965980",
                "235835",
                "714435",
                "059483",
                "087961",
                "428967",
                "592883",
                "972057",
                "871384",
                "178105",
                "569672",
                "286430",
                "266454",
                "859409",
                "034880",
                "658306",
                "634564",
                "620887",
                "247139",
                "363704",
                "269758",
                "599785",
                "967082",
                "594112",
                "230229",
                "157894",
                "062367",
                "608173",
                "630977",
                "554067",
                "696587",
                "265712",
                "632354",
                "388545",
                "440432",
                "315602",
                "219092",
                "878396",
                "347243",
                "048328",
                "518936",
                "575733",
                "851901",
                "220231",
                "107394",
                "502163",
                "995544",
                "236576",
                "722631",
                "970568",
                "947099",
                "826669",
                "443427",
                "128714",
                "760021",
                "416735",
                "292510",
                "011894",
                "162093",
                "254863",
                "243489",
                "766708",
                "359595",
                "434822",
                "155204",
                "448314",
                "167405",
                "983919",
                "956845",
                "204005",
                "250370",
                "971163",
                "960889",
                "463805",
                "267220",
                "545552",
                "761211",
                "750364",
                "874069",
                "839699",
                "200737",
                "922360",
                "638269",
                "504039",
                "296474",
                "489524",
                "003741",
                "389274"
            ]
        }
    ]
}


                                        

API Request ( แสดงวันหวยออกตั้งแต่อดีตถึงปัจจุบัน )

Method

สำหรับแสดงวันออกฉลากที่ผ่านมาทั้งหมด https://www.krupreecha.com/api/lotteryday เท่านั้น.

API Request ( ตรวจฉลากในแต่ละงวด )

Method

สำหรับตรวจสอบว่า ถูกรางวัลหรือไม่ถูก https://www.krupreecha.com/api/verify เท่านั้น.

Params

https://www.krupreecha.com/api/verify/01032564/835539 server_url/วันเดือนปี/เลขสลาก

Response

{
    "code": "200",
    "winner": true,
    "result": [
        {
            "id": "lotto_side_one",
            "name": "คุณถูก รางวัลใกล้เคียงรางวัลที่ 1",
            "reword": 100000,
            "amount": 2,
            "number": "835539"
        }
    ]
}


                                        

สถิติหวยย้อนหลัง 15 ปี

Method

สำหรับแสดงข้อมูลสถิติหวยย้อนหลัง 15 ปี https://www.krupreecha.com/api/statistics

Request PHP


        // ข้อมูลสถิติหวยย้อนหลัง 15 ปี                            
		$server_url = 'https://www.krupreecha.com/api/statistics';
		$api_key = 'api key here';
		$header = array(
			"Content-Type: application/json",
			"Accept: application/json",
			"X-API-KEY:".$api_key,
			"domain:".$_SERVER["SERVER_NAME"]
		);
		$ch = curl_init($server_url);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt($ch, CURLOPT_POST, 0);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
		$result = curl_exec($ch);
		curl_close($ch);
		$json = json_decode($result);
		
		$number_of_lottery = $json->number_of_lottery; //จำนวนงวดทั้งหมดที่เคยออก ( 15 ปี ++ )
		$last_two_digits = $json->last_two_digits; // สถิติเลขท้าย 2 ตัวที่เคยออก เลขที่ออก และ จำนวนครั้งที่เคยออก
		$ten_unit_digits = $json->ten_unit_digits; // สถิติเลขหลักหน่วยและหลักสิบเมื่อนำมารวมกันที่เคยออก เลขที่ออก และ จำนวนครั้งที่เคยออก
		$ten_digits = $json->ten_digits; // สถิติเลขหลักสิบที่เคยออก เลขที่ออก และ จำนวนครั้งที่เคยออก
		$unit_digits = $json->unit_digits; // สถิติเลขหลักหน่วยที่เคยออก เลขที่ออก และ จำนวนครั้งที่เคยออก


		// ตัวอย่าง loop เพื่อแสดงผลสถิติการออกของเลขท้ายสองตัว
		foreach($last_two_digits as $key => $val){
			echo 'เลขที่ออก '.$key.' จำนวนที่ออก '.$val.' ครั้ง 
'; }