Dokumentasi API

Endpoint publik Yann CDN. Semua respons JSON. Silakan dipakai untuk integrasi bot, script, atau aplikasi.

POST /api/v1/media/upload

Upload file (multipart) atau ambil file dari URL (JSON).

Multipart — upload file dari perangkat

curl -F "file=@foto.jpg" -F "expire=30d" \
  https://{host}/api/v1/media/upload

JSON — upload via URL eksternal

curl -X POST https://{host}/api/v1/media/upload \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/video.mp4","expire":"7d"}'

Parameter

FieldTypeWajibKeterangan
filebinarymultipart · yaBerkas yang diupload (field name file)
urlstringJSON · yaURL eksternal untuk diambil server. IP private diblokir.
expirestringtidak12h · 1d · 7d · 30d · 7w · forever (default 1d). Nilai lain ditolak dengan 400.

Respons sukses

{ "status": true, "code": 200, "creator": "yanncdn",
  "result": { "media": {
    "id": "m_4f2c0e1d9a8b7c6d",
    "url": "https://{host}/m/m_4f2c0e1d9a8b7c6d.png",
    "mime": "image/png",
    "type": "image",
    "size": 184320,
    "checksum": "sha256-hex",
    "created_at": "2026-01-01T00:00:00.000Z",
    "expires_at": null,
    "downloads": 0,
    "cached": false
  } } }

Error umum

KodeKondisi
400Body salah / tidak ada file / Content-Type tidak didukung
403URL eksternal mengarah ke IP internal
413File melebihi batas (200 MB)
415Isi file rusak/tidak dikenali
429Terlalu banyak request / kuota harian

GET /m/{id}.{ext}

Serve file asli. Cache publik immutable satu tahun; Accept-Ranges: bytes untuk video/audio.

# Ambil langsung
curl -L https://{host}/m/m_4f2c0e1d9a8b7c6d.png -o hasil.png

File berisiko (HTML/JS/SVG/XML/EXE, dll) otomatis dikirim sebagai attachment dengan X-Content-Type-Options: nosniff.

GET /api/v1/media/{id}

Metadata file (tanpa autentikasi).

curl https://{host}/api/v1/media/m_4f2c0e1d9a8b7c6d

DELETE /api/v1/media/{id}

Hapus file. Wajib header x-api-key (token admin, diatur server-side, tidak pernah dipublikasi).

curl -X DELETE https://{host}/api/v1/media/m_4f2c0e1d9a8b7c6d \
  -H "x-api-key: RAHASIA"

GET /api/health

Healthcheck untuk nginx/pm2/monitoring.

curl https://{host}/api/health

Catatan keamanan

  • SSRF diblokir: URL eksternal tidak boleh mengarah ke IP private/loopback/metadata cloud.
  • Upload dibatasi per IP: 30 request / 15 menit, 300 / hari, kuota 5 GB / hari.
  • Semua file disimpan di server dengan nama acak (id). Nama asli tidak pernah dipakai sebagai path.
  • Header nosniff + Content-Disposition: attachment untuk ekstensi berbahaya.
  • IP pengupload disimpan sebagai hash, bukan plaintext.