prepare("SELECT api_key FROM users WHERE id = ?"); $stmt->execute([$_SESSION['user_id']]); $user = $stmt->fetch(PDO::FETCH_ASSOC); } catch(PDOException $e) { $user = ['api_key' => null]; } ?> <?php echo t('api_docs'); ?> - <?php echo SITE_NAME; ?>

1.

POST /api/upload.php

//
Content-Type: multipart/form-data

//
api_key = string ()
image = file ()
title = string ()
tags = string ()
is_public = integer ()

//
{
  "success": true,
  "data": {
    "id": 123,
    "title": "",
    "url": "/view-image.php?id=123",
    "direct_url": "/uploads/filename.jpg",
    "tags": ["", ""]
  }
}

2.

GET /api/images.php?api_key=&page=1&limit=20

//
api_key = string ()
page = integer ()
limit = integer ()

//
{
  "success": true,
  "data": [
    {
      "id": 123,
      "title": "",
      "url": "/view-image.php?id=123",
      "direct_url": "/uploads/filename.jpg",
      "is_public": 1,
      "views": 45,
      "file_size_formatted": "2.5 MB"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "pages": 8
  }
}

3.

#
curl -X POST \
  -F "api_key=" \
  -F "title=" \
  -F "is_public=1" \
  -F "image=@/path/to/your/image.jpg" \
  "/api/upload.php"
#
curl "/api/images.php?api_key=&page=1&limit=10"