API tạo mã QR
VietQR.IO (v2/generate)
Tạo mã QR
API này cho phép tạo mã QR dựa vào thông tin tài khoản nhận tiền
Authorizations:
(x-client-idx-api-key)
header Parameters
x-client-id required | string Client Id để chứng thực. Truy cập My VietQR để lấy Client Id |
x-api-key required | string API key để chứng thực. Truy cập My VietQR để lấy API Key |
Request Body schema: application/json
accountNo required | string [ 6 .. 19 ] characters Số tài khoản ngân hàng thụ hưởng. Chỉ nhập số, tối thiểu 6 ký tự, tối đa 19 kí tự |
accountName | string [ 5 .. 50 ] characters Tên tài khoản ngân hàng. Nhập tiếng Việt không dấu, viết hoa, tối thiểu 5 ký tự, tối đa 50 kí tự, không chứa các ký tự đặc biệt. |
acqId required | integer Mã định danh ngân hàng (thường gọi là BIN) 6 chữ số, quy đinh bởi ngân hàng nước |
amount | integer <= 13 characters Số tiền chuyển. Chỉ nhập số, tối đa 13 kí tự |
addInfo | string <= 25 characters Nội dung chuyển tiền. Nhập tiếng Việt không dấu, tối đa 25 ký tự. Không chứa các ký tự đặc biệt |
format | string Định dạng VietQR trả về |
template | string Mẫu VietQR trả về |
Responses
Request samples
- Payload
Content type
application/json
{- "accountNo": 113366668888,
- "accountName": "QUY VAC XIN PHONG CHONG COVID",
- "acqId": 970415,
- "amount": 79000,
- "addInfo": "Ung Ho Quy Vac Xin",
- "format": "text",
- "template": "compact"
}
Response samples
- 200
Content type
application/json
Example
Thành công
{- "code": "00",
- "desc": "Gen VietQR successful!",
- "data": {
- "acpId": 970415,
- "accountName": "QUY VAC XIN PHONG CHONG COVID 19",
- "qrCode": "00020101021238560010A0000007270126000697041501121133666688880208QRIBFTTA53037045405790005802VN62220818Ung Ho Quy Vac Xin63043ACF",
- "qrDataURL": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgCAYAAAB91L6VAAAAAklEQVR4AewaftIAAA7OSURBVO3BwZEcuoIDMFLl/FPmvgy+Dj3qHRtA958AAE+dAADPnQAAz50AAM+dAADPnQAAz50AAM+dAADPn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re25dO25Vbb3NqW3+AEAHjuBAB47gQAeO4EAHjuBAB47gQAeO4EAHjuBAB47gQAeO5P/nHb8i/bllttc6ttbmzLrW35tLa5tS23tuVG2/yEtrmxLbfa5ta2fFPb/AbbcqttbrXNjW251Ta3tuXTtuVvcwIAPHcCADx3AgA8dwIAPHcCADx3AgA8dwIAPHcCADx3AgA8dwIAPPcnf6m24X9rm1vbcqttPq1tbm3LN7XNp7XNp7XNrW251TY3tuVW23zatvwW2/JN2/JNbXNrW36DEwDguRMA4LkTAOC5EwDguRMA4LkTAOC5EwDguRMA4LkTAOC5EwDgue4/AQCeOgEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ47AQCeOwEAnjsBAJ77P8/kBODDmcr6AAAAAElFTkSuQmCC"
}
}
Demo sử dụng
curl --location --request POST 'https://api.vietqr.io/v2/generate' \
--header 'x-client-id: <CLIENT_ID_HERE>' \
--header 'x-api-key: <API_KEY_HERE>' \
--header 'Content-Type: application/json' \
--data-raw '{
"accountNo": "113366668888",
"accountName": "QUY VAC XIN PHONG CHONG COVID",
"acqId": "970415",
"addInfo": "Ung Ho Quy Vac Xin",
"amount": "79000",
"template": "compact"
}'
Các loại định dạng trả về
Trường template
trong request body sẽ có thể chọn 1 trong các tùy chọn sau
Giá trị | Size | Ghi chú |
---|---|---|
compact2 | 540x640 | Bao gồm : Mã QR, các logo , thông tin chuyển khoản |
compact | 540x540 | QR kèm logo VietQR, Napas, ngân hàng |
qr_only | 480x480 | Trả về ảnh QR đơn giản, chỉ bao gồm QR |
600x776 | Bao gồm : Mã QR, các logo và đầy đủ thông tin chuyển khoản |
accountNo | Số tài khoản |
---|---|
accountName | Tên tài khoản |
accId | Mã bin được lấy từ Api bank theo từng ngân hàng |
addInfo | Nội dung chuyển khoản |
Ý nghĩa các trường trong Response
Trường dữ liệu | Ý nghĩa |
---|---|
qrCode | Mã QR dạng văn bản |
qrDataURL | Ảnh QR dưới định dạng Data URI, có thể dùng Data URI để nhúng hình ảnh vào website hoặc hiện thị lên trình duyệt. Tìm hiểu thêm về Data URI |