diff --git a/docs/API.md b/docs/API.md new file mode 100644 index 0000000..cf37f9d --- /dev/null +++ b/docs/API.md @@ -0,0 +1,391 @@ +# BZOD REST API + +> Programmatic access to URLs, Landing Pages, QR Codes, Analytics, and Audit Logs. + +## Overview + +The BZOD REST API allows automation and integration with external systems such as: + +* Home Assistant +* Shell Scripts +* CI/CD Pipelines +* Monitoring Systems +* Internal Applications +* Self-hosted Services + +All API endpoints require authentication using an API Token generated from: + +```text +Admin Dashboard → Settings → REST API Tokens +``` + +--- + +# Authentication + +Generate an API token from the Admin Dashboard. + +Example token: + +```text +bzo_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +``` + +Pass the token using the `Authorization` header. + +## Example + +```bash +curl \ + -H "Authorization: bzo_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \ + https://your-domain.com/api/v1/stats +``` + +--- + +# Base URL + +```text +https://your-domain.com/api/v1 +``` + +Example: + +```text +https://bzo.in/api/v1 +``` + +--- + +# Response Format + +Successful responses: + +```json +{ + "success": true, + "data": {} +} +``` + +Error responses: + +```json +{ + "success": false, + "error": "Invalid API token" +} +``` + +--- + +# URL Management + +## List URLs + +```http +GET /api/v1/urls +``` + +### Example + +```bash +curl \ + -H "Authorization: TOKEN" \ + https://your-domain.com/api/v1/urls +``` + +--- + +## Create URL + +```http +POST /api/v1/urls +``` + +### Request + +```json +{ + "code": "rust", + "target_url": "https://www.rust-lang.org", + "description": "Rust Language" +} +``` + +### Example + +```bash +curl \ + -X POST \ + -H "Authorization: TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "code":"rust", + "target_url":"https://www.rust-lang.org" + }' \ + https://your-domain.com/api/v1/urls +``` + +--- + +## Get URL + +```http +GET /api/v1/urls/{uuid} +``` + +Example: + +```http +GET /api/v1/urls/5d4d9e98-7cb7-4c97-9a0a-123456789abc +``` + +--- + +## Update URL + +```http +PUT /api/v1/urls/{uuid} +``` + +--- + +## Delete URL + +```http +DELETE /api/v1/urls/{uuid} +``` + +--- + +## URL Preview + +```http +GET /api/v1/urls/{uuid}/preview +``` + +Returns rendered metadata used by preview cards. + +--- + +# Landing Pages + +## List Pages + +```http +GET /api/v1/pages +``` + +--- + +## Create Page + +```http +POST /api/v1/pages +``` + +### Example Request + +```json +{ + "title": "My Product", + "slug": "product", + "description": "Product Landing Page", + "content": "
- Beautiful, private, and powerful URL shortener with rich landing pages, QR codes, analytics, and full CLI control. -
- - - -
- ~18 MB Rust binary.
- No runtime required.
-
- Zero configuration.
- WAL mode enabled.
-
+ Beautiful, private, and powerful URL shortener with rich + landing pages, QR codes, analytics, and full CLI control. +
+ + - -
- Full automation.
- JSON everywhere.
-
- Your links.
- Your infrastructure.
-
- Open source.
- Commercial friendly.
-
~18 MB single Rust binary. Starts instantly. Uses SQLite with WAL mode. Minimal resource usage.
-No telemetry. No third-party services. Everything runs on your server. Strong password hashing & audit logs.
-Rich custom landing pages with title, description, OG metadata, and branded preview.
+
+ ~18 MB Rust binary.
+ No runtime required.
+
Generate PNG & SVG QR codes. Track scans separately in analytics.
+ +
+ Zero configuration.
+ WAL mode enabled.
+
+ Full automation.
+ JSON everywhere.
+
+ Your links.
+ Your infrastructure.
+
+ Open source.
+ Commercial friendly.
+
backup, restore, doctor, stats, validate, create-admin — everything from terminal.
-Password protection • Expiry • Access limits • Tags • REST API • Bulk QR export
-- Deploy on any Debian/Ubuntu VPS, homelab, mini-PC, or Raspberry Pi. -
- -+ ~18 MB single Rust binary. Starts instantly. Uses + SQLite with WAL mode. Minimal resource usage. +
++ No telemetry. No third-party services. Everything + runs on your server. Strong password hashing & audit + logs. +
++ Rich custom landing pages with title, description, + OG metadata, and branded preview. +
+curl -fsSL https://bzo.in/deploy.sh | sudo bash
+ + Generate PNG & SVG QR codes. Track scans separately + in analytics. +
++ backup, restore, doctor, stats, validate, + create-admin — everything from terminal. +
++ Password protection • Expiry • Access limits • Tags + • REST API • Bulk QR export +
+- Downloads the latest release and installs BZOD as a systemd service. -
-Self-host BZOD in under 5 minutes on any VPS, homelab, or even a Raspberry Pi.
- -+ Downloads the latest release and installs BZOD as a systemd + service. +
+ Self-host BZOD in under 5 minutes on any VPS, homelab, or + even a Raspberry Pi. +
+ + +