KandangKu API

Backend sinkronisasi data kandang, telur harian, dan vaksinasi.

ENV terpasang — cek /api/health untuk koneksi database

Endpoint

Header

# app peternak
x-api-key: <API_KEY>
x-device-id: <id unik perangkat, 6-64 karakter>

# app admin
Authorization: Bearer <access_token Supabase>

Contoh push

curl -X POST https://<domain>/api/sync \
  -H "content-type: application/json" \
  -H "x-api-key: $API_KEY" \
  -H "x-device-id: hp-android-01" \
  -d '{
    "kandang": [{
      "localId": 1,
      "nama": "Kandang A",
      "populasiAwal": 5000,
      "tanggalMasuk": 20695,
      "umurMasukHari": 1,
      "kematianAwal": 0,
      "createdAt": 1796000000000,
      "updatedAt": 1796000000000,
      "deleted": false
    }],
    "inputHarian": [{
      "localId": 1,
      "kandangLocalId": 1,
      "tanggal": 20695,
      "telurUtuh": 4200,
      "telurPecah": 30,
      "telurKotor": 20,
      "pakanKg": 540,
      "mati": 2,
      "alasanMati": "lemas",
      "updatedAt": 1796000000000,
      "deleted": false
    }],
    "vaksinasi": []
  }'

Contoh tarik

curl "https://<domain>/api/sync?since=0" \
  -H "x-api-key: $API_KEY" \
  -H "x-device-id: hp-android-01"

Setiap perangkat hanya melihat datanya sendiri. Baris dengan deleted: true adalah penanda hapus (tombstone) supaya penghapusan ikut tersinkron.