Mulai Cepat
Buat panggilan API pertama Anda dalam waktu kurang dari 5 menit.
Prasyarat
- Akun GoValid (Daftar gratis)
- API key atau kredensial pengguna
curlatau HTTP client apapun
Langkah 1: Dapatkan API Key Anda
- Masuk ke my.govalid.org
- Buka Akun → API Keys
- Klik Create New Key
- Salin key Anda
Langkah 2: Uji Koneksi
Verifikasi API key Anda berfungsi:
curl https://api.govalid.org/api/v1/health/ \
-H "Authorization: Bearer YOUR_API_KEY"
Respons yang diharapkan:
{
"status": "healthy",
"version": "1.1.0"
}
Langkah 3: Buat QR Code Pertama Anda
curl -X POST https://api.govalid.org/api/v1/qr/ \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "QR Code Pertama Saya",
"qr_type": "url",
"content": "https://example.com"
}'
Respons:
{
"id": "abc123",
"title": "QR Code Pertama Saya",
"qr_type": "url",
"content": "https://example.com",
"qr_image": "https://api.govalid.org/media/qr/abc123.png",
"short_url": "https://govalid.org/q/abc123",
"created_at": "2025-01-29T12:00:00Z"
}
Langkah 4: Ambil Daftar QR Code Anda
curl https://api.govalid.org/api/v1/qr/ \
-H "Authorization: Bearer YOUR_API_KEY"
Respons:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": "abc123",
"title": "QR Code Pertama Saya",
"qr_type": "url",
"scan_count": 0,
"created_at": "2025-01-29T12:00:00Z"
}
]
}
Tipe QR Umum
| Tipe | Deskripsi | Contoh Konten |
|---|---|---|
url | Tautan website | https://example.com |
text | Teks biasa | Hello World |
email | Alamat email | [email protected] |
phone | Nomor telepon | +1234567890 |
vcard | Kartu kontak | JSON dengan detail kontak |
document | Verifikasi dokumen | Metadata dokumen |
Contoh Kode
Python
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.govalid.org/api/v1"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# Buat QR code
response = requests.post(
f"{BASE_URL}/qr/",
headers=headers,
json={
"title": "QR Code Saya",
"qr_type": "url",
"content": "https://example.com"
}
)
print(response.json())
JavaScript (Node.js)
const axios = require('axios');
const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'https://api.govalid.org/api/v1';
const headers = {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
};
// Buat QR code
axios.post(`${BASE_URL}/qr/`, {
title: 'QR Code Saya',
qr_type: 'url',
content: 'https://example.com'
}, { headers })
.then(response => console.log(response.data))
.catch(error => console.error(error));
PHP
<?php
$apiKey = 'YOUR_API_KEY';
$baseUrl = 'https://api.govalid.org/api/v1';
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => "$baseUrl/qr/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $apiKey",
"Content-Type: application/json"
],
CURLOPT_POSTFIELDS => json_encode([
'title' => 'QR Code Saya',
'qr_type' => 'url',
'content' => 'https://example.com'
])
]);
$response = curl_exec($ch);
curl_close($ch);
print_r(json_decode($response, true));
Langkah Selanjutnya
- Referensi API - Dokumentasi endpoint lengkap
- Contoh Kode - Lebih banyak kasus penggunaan
- Autentikasi - Opsi autentikasi lanjutan