nxeonfixqr

เอกสาร

เอกสาร API

API สาธารณะฟรี — ไม่ต้องมี API key · คืนค่าเป็นรูป PNG โดยตรง

ปลายทาง

GET https://qr.9zahub.com/api/v1/qr

พารามิเตอร์

ชื่อจำเป็นคำอธิบาย
typeใช่phone หรือ national_id
targetใช่เบอร์ 0xxxxxxxxx หรือ เลขบัตรประชาชน 13 หลัก (มี checksum)
amountใช่จำนวนเงิน ทศนิยม 2 ตำแหน่ง · 1.0010,000.00 บาท

การตอบกลับ

  • · 200 image/png รูป QR
  • · 400 — JSON { "error": "..." }
  • · 429 — เกินโควต้า (20 ครั้ง/นาที/IP)

ตัวอย่างโค้ด

URL
https://qr.9zahub.com/api/v1/qr?type=phone&target=0812345678&amount=100.00
curl
curl -o qr.png "https://qr.9zahub.com/api/v1/qr?type=phone&target=0812345678&amount=100.00"
JavaScript
const url = new URL("https://qr.9zahub.com/api/v1/qr");
url.searchParams.set("type", "phone");
url.searchParams.set("target", "0812345678");
url.searchParams.set("amount", "100.00");

const res = await fetch(url);
if (!res.ok) {
  const err = await res.json();
  throw new Error(err.error);
}

const blob = await res.blob();
const imgUrl = URL.createObjectURL(blob);
document.querySelector("#qr").src = imgUrl;
Python
import urllib.request

url = (
  "https://qr.9zahub.com/api/v1/qr"
  "?type=phone&target=0812345678&amount=100.00"
)

urllib.request.urlretrieve(url, "qr.png")
print("saved qr.png")
PHP
<?php
$url = "https://qr.9zahub.com/api/v1/qr?type=phone&target=0812345678&amount=100.00";
$png = file_get_contents($url);

if ($png === false) {
  http_response_code(502);
  echo "Failed to fetch QR";
  exit;
}

header("Content-Type: image/png");
echo $png;
Java
import java.io.InputStream;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;

public class FixQrExample {
  public static void main(String[] args) throws Exception {
    String url =
      "https://qr.9zahub.com/api/v1/qr?type=phone&target=0812345678&amount=100.00";

    try (InputStream in = URI.create(url).toURL().openStream()) {
      Files.copy(in, Path.of("qr.png"));
    }
  }
}

ใช้กับ HTML img

HTML
<img
  src="https://qr.9zahub.com/api/v1/qr?type=phone&target=0812345678&amount=100.00"
  alt="PromptPay QR"
  width="256"
  height="256"
/>