# API Folder - PROTOTYPE

This folder contains the shared JSON proxy endpoints used by the app. The app also has a few page-level proxies for older screens, but new API work should prefer this folder.

## Shared Config

- API key: defined in `api/base.php` as `API_KEY`
- API base URL: defined in `api/base.php` as `API_BASE`
- Quota handling: `api_consume_quota()`
- HTTP helper: `api_fetch()`
- Simple endpoint proxy helper: `api_proxy()`

## Files

| File | Category | Main params |
| --- | --- | --- |
| `nik.php` | CID/NIK, BPJS, family card, salary | `nik=`, `no_kk=` |
| `phone.php` | Phone lookup | `phone=` |
| `vehicle.php` | Vehicle lookup | `q=` |
| `name.php` | Name lookup | `name=`, `nama=`, `tempat=` |
| `company.php` | Company lookup | `comname=` |
| `location.php` | Location and vehicle tracking | `q=`, `number=`, `qid=` |
| `base.php` | Shared helper, not a direct endpoint | - |

## Usage

```js
const res = await fetch('api/nik.php?action=cid2data&nik=3201000000000000');
const data = await res.json();
```

## Available Actions

### `api/nik.php`

- `cid2data` - Personal data by CID/NIK
- `cid2full` - Full personal data + photo by CID/NIK
- `cid2phone` - Phone data by CID/NIK
- `cid2mail` - Email data by CID/NIK
- `cid2salary` - Salary by CID/NIK
- `kk2data` - Family data by family card number, uses `no_kk=`
- `nik2email` - Alias for email lookup by CID/NIK
- `bpjstk` - BPJS Ketenagakerjaan by CID/NIK
- `edabu` - BPJS Kesehatan by CID/NIK

### `api/phone.php`

- `phone2cid` - Personal data by phone
- `phone2gc` - Get Contact / contact data by phone
- `phone2bro` - Phone/provider data currently used by gambling history card
- `phone2ewallet` - E-wallet data by phone

### `api/vehicle.php`

- `nopol` - Vehicle data by plate number
- `nopol2foto` - Vehicle data + photo by plate number
- `nosin` - Vehicle data by engine number
- `noka` - Vehicle data by chassis number
- `pemilik` - Vehicle data by CID/NIK, sent as remote `NoKTP`

### `api/name.php`

- `name2data` - Personal data by name
- `name2datav2` - Personal data by name + place

### `api/company.php`

- `company` - Company data by company name, uses `comname=`

### `api/location.php`

- `track_jabodetabek` - Tracking vehicle in Jabodetabek by plate number
- `check_position` - CEK POS / CP2 request by number
- `check_position_result` - CEK POS / CP2 result by queue id
- `check_position_v2` - CEK POS V2 request by number
- `check_position_v2_result` - CEK POS V2 result by queue id
- `check_position_asean` - CEK POS ASEAN request by number
- `check_position_asean_result` - CEK POS ASEAN result by queue id

## Page-Level Proxies Still Present

These screens still contain their own proxy handler because their UI and result flow are tied to the page:

- `get-location.php` - CP2 V1, CP2 V2, ASEAN request/result flow and queue notification
- `check-position-asean-output.php` - ASEAN result rendering
- `snap-location.php` - Single and multi snapshot link generation
- `seeker.php` - LV II profiling by CID/NIK, phone, and nopol
- `darkweb-result.php` - Darkweb query result
- `tracking-vehicle.php` - Tracking vehicle page flow

When adding a new endpoint, prefer adding it to `api/*.php` first, then call it from the page.
