{
  "info": {
    "name": "tadjwid API v2",
    "_postman_id": "tadjwid-api-v2-collection",
    "description": "Public REST API for the Muallim Tajweed Islamic learning platform.\n\nBase URL: https://e-replika.ru/tadjwid/api/v2\n\nAuth modes:\n- **Anonymous** — 100 req/hour per IP, no header\n- **API key** — header `X-API-Key: tk_...` for 10000+ req/hour\n- **Admin (JWT)** — `Authorization: Bearer <token>` for /keys/* management\n\nDocs: https://e-replika.ru/tadjwid/api/v2/docs",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://e-replika.ru/tadjwid/api/v2",
      "type": "string"
    },
    {
      "key": "api_key",
      "value": "tk_REPLACE_ME",
      "type": "string",
      "description": "Optional. Set after creating a key via /keys."
    },
    {
      "key": "admin_token",
      "value": "",
      "type": "string",
      "description": "JWT from POST /admin/api/auth/login. Required for /keys management."
    },
    {
      "key": "admin_password",
      "value": "",
      "type": "string",
      "description": "Admin password — DO NOT commit. Used only by 'Admin login' request."
    }
  ],
  "auth": {
    "type": "apikey",
    "apikey": [
      { "key": "key", "value": "X-API-Key", "type": "string" },
      { "key": "value", "value": "{{api_key}}", "type": "string" },
      { "key": "in", "value": "header", "type": "string" }
    ]
  },
  "item": [
    {
      "name": "Meta",
      "item": [
        {
          "name": "API info / catalogue",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/info",
              "host": ["{{base_url}}"],
              "path": ["info"]
            }
          }
        },
        {
          "name": "Health (root)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "https://e-replika.ru/tadjwid/health",
              "protocol": "https",
              "host": ["e-replika", "ru"],
              "path": ["tadjwid", "health"]
            }
          }
        }
      ]
    },
    {
      "name": "Glossary (582+ terms)",
      "item": [
        {
          "name": "List terms (paginated)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/glossary?per_page=20&page=1",
              "host": ["{{base_url}}"],
              "path": ["glossary"],
              "query": [
                { "key": "per_page", "value": "20" },
                { "key": "page", "value": "1" },
                {
                  "key": "q",
                  "value": "",
                  "disabled": true,
                  "description": "Substring search (term/desc)"
                },
                { "key": "category", "value": "tajweed", "disabled": true },
                {
                  "key": "fields",
                  "value": "term,arabic",
                  "disabled": true,
                  "description": "Projection"
                }
              ]
            }
          }
        },
        {
          "name": "Categories",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/glossary/categories",
              "host": ["{{base_url}}"],
              "path": ["glossary", "categories"]
            }
          }
        },
        {
          "name": "Single term by id",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/glossary/shahada",
              "host": ["{{base_url}}"],
              "path": ["glossary", "shahada"]
            }
          }
        }
      ]
    },
    {
      "name": "Lessons (60 lessons, 61 quizzes)",
      "item": [
        {
          "name": "List lessons",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/lessons?per_page=20",
              "host": ["{{base_url}}"],
              "path": ["lessons"],
              "query": [
                { "key": "per_page", "value": "20" },
                { "key": "category", "value": "alphabet", "disabled": true },
                { "key": "q", "value": "хадис", "disabled": true }
              ]
            }
          }
        },
        {
          "name": "Lesson by category/id",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/lessons/alphabet/01-history",
              "host": ["{{base_url}}"],
              "path": ["lessons", "alphabet", "01-history"]
            }
          }
        },
        {
          "name": "Lesson quizzes only",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/lessons/alphabet/01-history/quizzes",
              "host": ["{{base_url}}"],
              "path": ["lessons", "alphabet", "01-history", "quizzes"]
            }
          }
        },
        {
          "name": "Global quiz pool",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/quizzes",
              "host": ["{{base_url}}"],
              "path": ["quizzes"]
            }
          }
        }
      ]
    },
    {
      "name": "Calligraphy",
      "item": [
        {
          "name": "Styles (11)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/calligraphy/styles",
              "host": ["{{base_url}}"],
              "path": ["calligraphy", "styles"]
            }
          }
        },
        {
          "name": "Style by id",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/calligraphy/styles/sini",
              "host": ["{{base_url}}"],
              "path": ["calligraphy", "styles", "sini"]
            }
          }
        },
        {
          "name": "Calligraphers (14)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/calligraphy/calligraphers",
              "host": ["{{base_url}}"],
              "path": ["calligraphy", "calligraphers"]
            }
          }
        },
        {
          "name": "Calligrapher by id",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/calligraphy/calligraphers/ibn-muqla",
              "host": ["{{base_url}}"],
              "path": ["calligraphy", "calligraphers", "ibn-muqla"]
            }
          }
        },
        {
          "name": "Mosques (33) — JSON",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/calligraphy/mosques",
              "host": ["{{base_url}}"],
              "path": ["calligraphy", "mosques"]
            }
          }
        },
        {
          "name": "Mosques as GeoJSON (for Leaflet/Mapbox)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/calligraphy/mosques?format=geojson",
              "host": ["{{base_url}}"],
              "path": ["calligraphy", "mosques"],
              "query": [{ "key": "format", "value": "geojson" }]
            }
          }
        },
        {
          "name": "Mosque by id",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/calligraphy/mosques/al-haram",
              "host": ["{{base_url}}"],
              "path": ["calligraphy", "mosques", "al-haram"]
            }
          }
        }
      ]
    },
    {
      "name": "Quran metadata",
      "item": [
        {
          "name": "Surahs (114)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/surahs",
              "host": ["{{base_url}}"],
              "path": ["surahs"]
            }
          }
        },
        {
          "name": "Surah by number",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/surahs/55",
              "host": ["{{base_url}}"],
              "path": ["surahs", "55"]
            }
          }
        },
        {
          "name": "Ayah analysis",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/ayah-analysis?surah=1&ayah=1",
              "host": ["{{base_url}}"],
              "path": ["ayah-analysis"],
              "query": [
                { "key": "surah", "value": "1" },
                { "key": "ayah", "value": "1" }
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Tajweed & transliteration",
      "item": [
        {
          "name": "Tajweed rules",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/tajweed/rules",
              "host": ["{{base_url}}"],
              "path": ["tajweed", "rules"]
            }
          }
        },
        {
          "name": "Tajweed rule by id",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/tajweed/rules/idgham",
              "host": ["{{base_url}}"],
              "path": ["tajweed", "rules", "idgham"]
            }
          }
        },
        {
          "name": "Transliterate Arabic → Russian",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"text\": \"بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ\",\n  \"level\": 2,\n  \"teacherStyle\": true\n}"
            },
            "url": {
              "raw": "{{base_url}}/transliteration",
              "host": ["{{base_url}}"],
              "path": ["transliteration"]
            }
          }
        }
      ]
    },
    {
      "name": "Search (FTS5)",
      "item": [
        {
          "name": "Global search",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/search?q=хадис",
              "host": ["{{base_url}}"],
              "path": ["search"],
              "query": [{ "key": "q", "value": "хадис" }]
            }
          }
        }
      ]
    },
    {
      "name": "Assets",
      "item": [
        {
          "name": "Images (filter)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/images?ext=jpg&category=calligraphy",
              "host": ["{{base_url}}"],
              "path": ["images"],
              "query": [
                { "key": "ext", "value": "jpg" },
                { "key": "category", "value": "calligraphy" }
              ]
            }
          }
        },
        {
          "name": "Image categories",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/images/categories",
              "host": ["{{base_url}}"],
              "path": ["images", "categories"]
            }
          }
        },
        {
          "name": "Media (videos / audio)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/media?ext=mp4",
              "host": ["{{base_url}}"],
              "path": ["media"],
              "query": [{ "key": "ext", "value": "mp4" }]
            }
          }
        },
        {
          "name": "Asset stats",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/assets/stats",
              "host": ["{{base_url}}"],
              "path": ["assets", "stats"]
            }
          }
        }
      ]
    },
    {
      "name": "Admin — auth & key management",
      "description": "Manage API keys. Requires admin JWT (Authorization: Bearer <token>).",
      "item": [
        {
          "name": "Admin login",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 200) {",
                  "  pm.collectionVariables.set('admin_token', pm.response.json().token);",
                  "  console.log('admin_token saved to collection variables');",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "auth": { "type": "noauth" },
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"password\": \"{{admin_password}}\"\n}"
            },
            "url": {
              "raw": "https://e-replika.ru/tadjwid/admin/api/auth/login",
              "protocol": "https",
              "host": ["e-replika", "ru"],
              "path": ["tadjwid", "admin", "api", "auth", "login"]
            }
          }
        },
        {
          "name": "Create API key",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 201) {",
                  "  const k = pm.response.json();",
                  "  pm.collectionVariables.set('api_key', k.key);",
                  "  console.log('Saved api_key:', k.key.slice(0,10)+'...');",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                { "key": "token", "value": "{{admin_token}}", "type": "string" }
              ]
            },
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"my-app\",\n  \"scope\": \"read\",\n  \"expires_in_days\": 365\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{base_url}}/keys",
              "host": ["{{base_url}}"],
              "path": ["keys"]
            }
          }
        },
        {
          "name": "List API keys",
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                { "key": "token", "value": "{{admin_token}}", "type": "string" }
              ]
            },
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/keys",
              "host": ["{{base_url}}"],
              "path": ["keys"]
            }
          }
        },
        {
          "name": "Per-key usage stats",
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                { "key": "token", "value": "{{admin_token}}", "type": "string" }
              ]
            },
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/keys/1/usage?days=7",
              "host": ["{{base_url}}"],
              "path": ["keys", "1", "usage"],
              "query": [{ "key": "days", "value": "7" }]
            }
          }
        },
        {
          "name": "Revoke key (soft)",
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                { "key": "token", "value": "{{admin_token}}", "type": "string" }
              ]
            },
            "method": "DELETE",
            "url": {
              "raw": "{{base_url}}/keys/1",
              "host": ["{{base_url}}"],
              "path": ["keys", "1"]
            }
          }
        },
        {
          "name": "Hard delete key",
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                { "key": "token", "value": "{{admin_token}}", "type": "string" }
              ]
            },
            "method": "DELETE",
            "url": {
              "raw": "{{base_url}}/keys/1/permanent",
              "host": ["{{base_url}}"],
              "path": ["keys", "1", "permanent"]
            }
          }
        }
      ]
    }
  ]
}
