# QR Code Generator

QR Code Generator API APIPedia: Buat QR code untuk URL, teks, vCard, dan Wi-Fi, lalu baca kembali isi QR dari gambar dengan encoding universal. Panggil dengan satu token API di `https://api.apipedia.id/v1/qr`.

Hasilkan QR code PNG untuk URL, teks, kontak vCard, atau kredensial Wi-Fi dengan ukuran dan tingkat koreksi galat yang bisa diatur. Endpoint decode membaca QR, Micro QR, dan rMQR dari gambar (PNG, JPEG, WebP, GIF, BMP): teks dibaca mengikuti penanda ECI di simbol, byte mentahnya selalu dikembalikan dalam base64 dan hex sehingga encoding apa pun - termasuk data biner - bisa dipulihkan utuh, dan charset bisa dipaksa (mis. shift_jis, gbk). Isi yang dikenali (URL, Wi-Fi, vCard, QRIS, email, telepon, lokasi) ikut diuraikan.

- Base URL: `https://api.apipedia.id/v1/qr`
- Autentikasi: `Authorization: Bearer apk_…` (token dari console.apipedia.id)
- Kategori: Produktivitas
- Halaman: https://apipedia.id/docs/qr-code-generator
- OpenAPI: https://console.apipedia.id/openapi/qr-code-generator.yaml

Semua respons memakai amplop `{ "is_success", "message", "data" }` kecuali disebutkan lain. Kode error umum: lihat https://apipedia.id/docs#kode-status-error.

## Endpoint (2)

- `POST /decode`: Baca QR code (QR, Micro QR, rMQR) dari gambar
- `POST /generate`: Buat QR code dari teks, URL, atau konten terstruktur

### Baca QR code (QR, Micro QR, rMQR) dari gambar

`POST https://api.apipedia.id/v1/qr/decode`

Sama seperti `POST /barcode/decode`, tetapi pencarian dibatasi ke QR Code, Micro QR, dan rMQR (field `formats` diabaikan). Body: `image_base64` wajib (base64 mentah atau data URL; PNG, JPEG, WebP, GIF, atau BMP; maksimal 8 MB), `try_harder` (default true), `max_symbols` 1-50 (default 10), dan `charset` opsional (label WHATWG apa pun, mis. shift_jis) untuk memaksa encoding saat mendekode byte.

Setiap simbol membawa `text` sekaligus byte mentahnya (`bytes_hex`, `bytes_base64`), jadi isi berencoding apa pun - termasuk biner - bisa dipulihkan utuh. ECI di simbol dihormati otomatis (`encoding_source: "eci"`); tanpa ECI charset ditebak (`guessed`); `charset` dari pemanggil selalu menang (`request`). `parsed` mengklasifikasi isi: url (lengkap dengan hasil /url/parse), wifi, vcard, mecard, email, tel, sms, geo, qris, binary, atau text.

Gambar tanpa QR dijawab 200 dengan `count: 0`, `symbols: []`, dan `hint`, bukan error. Error 400 hanya untuk gambar/base64 rusak, format gambar tak didukung, ukuran berlebih, `max_symbols` di luar rentang, atau charset tidak dikenal. Di-cache 24 jam (header `X-Cache`).

Body (`application/json`, wajib):

```json
{
  "image_base64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0AQAAAAAVtjufAAABXElEQVR42u2XMZKcQAxFn4apGjL2Bs1NNDfxSbw0PlnvTeAGTcZUMXwHjO1kbYeiylYmRb9Q9+uHic9qufB5/XvzxczMnmZDO99f3SnzJ0kFvFl6wCXl2Jyj9cDHs4WfXfR3a6RMGq/R+/oR4Hll0PxlW4LzoJokFamYJld1SVn1bOccVQC2rrzfJm/qaxiXs5MkNRVberajC+VVLzOzN7c2jfbGt0ckr1Dl/Ta5qu/H2oAhdl+Xhx8ASOW63LnphDxHlWFNkjSuSeB76DlHFZMKnTJJTWUI54PaeVD90DobnS7MiuZSKqqeSaWRcjCXfu8JGfwKpskfZjspR787E6ouTQC2RvIBHbV1yuCNNK6xvHoZ53I3qXACXh2e2ZWv7Wx0hdB793f/hEfP0yyTzsF50wT4zpxP4MPzXS0ulVg//+WfkibfwNbo9+7wTGnFwffbGX3Y/v+//3H+HcDI5pRtrf/UAAAAAElFTkSuQmCC",
  "try_harder": true,
  "max_symbols": 10
}
```

Contoh request:

```bash
curl -X POST "https://api.apipedia.id/v1/qr/decode" \
  -H "Authorization: Bearer apk_xxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"image_base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0AQAAAAAVtjufAAABXElEQVR42u2XMZKcQAxFn4apGjL2Bs1NNDfxSbw0PlnvTeAGTcZUMXwHjO1kbYeiylYmRb9Q9+uHic9qufB5/XvzxczMnmZDO99f3SnzJ0kFvFl6wCXl2Jyj9cDHs4WfXfR3a6RMGq/R+/oR4Hll0PxlW4LzoJokFamYJld1SVn1bOccVQC2rrzfJm/qaxiXs5MkNRVberajC+VVLzOzN7c2jfbGt0ckr1Dl/Ta5qu/H2oAhdl+Xhx8ASOW63LnphDxHlWFNkjSuSeB76DlHFZMKnTJJTWUI54PaeVD90DobnS7MiuZSKqqeSaWRcjCXfu8JGfwKpskfZjspR787E6ouTQC2RvIBHbV1yuCNNK6xvHoZ53I3qXACXh2e2ZWv7Wx0hdB793f/hEfP0yyTzsF50wT4zpxP4MPzXS0ulVg//+WfkibfwNbo9+7wTGnFwffbGX3Y/v+//3H+HcDI5pRtrf/UAAAAAElFTkSuQmCC","try_harder":true,"max_symbols":10}'
```

Contoh respons (200):

```json
{
  "is_success": true,
  "message": "1 barcode(s) read",
  "data": {
    "count": 1,
    "symbols": [
      {
        "format": "QRCode",
        "format_label": "QR Code",
        "symbology": "QRCode",
        "text": "https://apipedia.id/blog?utm_source=qr",
        "content_type": "Text",
        "encoding": "ascii",
        "encoding_source": "guessed",
        "has_eci": false,
        "eci": null,
        "text_is_binary": false,
        "bytes_length": 38,
        "bytes_base64": "aHR0cHM6Ly9hcGlwZWRpYS5pZC9ibG9nP3V0bV9zb3VyY2U9cXI=",
        "bytes_hex": "68747470733a2f2f61706970656469612e69642f626c6f673f75746d5f736f757263653d7172",
        "position": {
          "topLeft": {
            "x": 30,
            "y": 30
          },
          "topRight": {
            "x": 204,
            "y": 30
          },
          "bottomRight": {
            "x": 204,
            "y": 204
          },
          "bottomLeft": {
            "x": 30,
            "y": 204
          }
        },
        "orientation": 0,
        "is_mirrored": false,
        "is_inverted": false,
        "symbology_identifier": "]Q1",
        "parsed": {
          "type": "url",
          "valid": true,
          "input": "https://apipedia.id/blog?utm_source=qr",
          "assumed_scheme": false,
          "normalized": "https://apipedia.id/blog?utm_source=qr",
          "protocol": "https:",
          "scheme": "https",
          "username": null,
          "has_password": false,
          "hostname": "apipedia.id",
          "hostname_unicode": "apipedia.id",
          "port": null,
          "default_port": 443,
          "effective_port": 443,
          "origin": "https://apipedia.id",
          "pathname": "/blog",
          "path_segments": [
            "blog"
          ],
          "search": "?utm_source=qr",
          "query": {
            "utm_source": "qr"
          },
          "hash": "",
          "fragment": null,
          "is_ip": false,
          "ip_version": null,
          "tld": "id",
          "domain": "apipedia.id",
          "subdomain": null,
          "is_icann": true,
          "is_private_suffix": false
        }
      }
    ],
    "formats_searched": [
      "QRCode",
      "MicroQRCode",
      "RMQRCode"
    ],
    "image": {
      "mime": "image/png",
      "bytes": 2391
    }
  }
}
```

### Buat QR code dari teks, URL, atau konten terstruktur

`POST https://api.apipedia.id/v1/qr/generate`

Gambar PNG dikembalikan langsung sebagai data URL (`image_data_url`), bukan tautan CDN.

`content_type` menentukan cara isi dirakit: "wifi" butuh `ssid` (plus `password` dan `security`, default WPA) dan menghasilkan format WIFI:T:...;S:...;P:...;; yang dikenali pemindai; "vcard" butuh `name` (plus `phone`, `email`, `org` opsional) dan menghasilkan vCard 3.0; nilai lain ("text", "url", termasuk payload QRIS) memakai `text` apa adanya. `size` 64-2048 piksel (default 512). `error_correction` L, M (default), Q, atau H. Isi yang melebihi kapasitas QR (~2.900 karakter) dijawab 400.

Body (`application/json`, wajib):

```json
{
  "content_type": "url",
  "text": "https://apipedia.id",
  "size": 512,
  "error_correction": "M"
}
```

Contoh request:

```bash
curl -X POST "https://api.apipedia.id/v1/qr/generate" \
  -H "Authorization: Bearer apk_xxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"content_type":"url","text":"https://apipedia.id","size":512,"error_correction":"M"}'
```

Contoh respons (200):

```json
{
  "is_success": true,
  "message": "QR code created",
  "data": {
    "content_type": "url",
    "format": "png",
    "size": 512,
    "error_correction": "M",
    "image_data_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..."
  }
}
```
