Lewati ke konten utama

Mulai Cepat

Buat panggilan API pertama Anda dalam waktu kurang dari 5 menit.

Prasyarat

  • Akun GoValid (Daftar gratis)
  • API key atau kredensial pengguna
  • curl atau HTTP client apapun

Langkah 1: Dapatkan API Key Anda

  1. Masuk ke my.govalid.org
  2. Buka AkunAPI Keys
  3. Klik Create New Key
  4. 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

TipeDeskripsiContoh Konten
urlTautan websitehttps://example.com
textTeks biasaHello World
emailAlamat email[email protected]
phoneNomor telepon+1234567890
vcardKartu kontakJSON dengan detail kontak
documentVerifikasi dokumenMetadata 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