Green/Red/Flagger
DOCUMENTACIÓN DE LA API

API pública.

API REST de solo lectura. Respuesta JSON, CORS abierto, 60 peticiones por minuto (por clave). Para crear una clave, ve a Ajustes → Claves de API.

Autenticación

Todas las peticiones requieren un header Authorization.

Authorization: Bearer grf_xxxxxxxxxxxxxxxxxxxxxx

Rate limit + CORS

Endpoints

GEThttps://greenredflagger.com/api/public/flags

Listar banderas aprobadas, filtrar y ordenar.

Parámetros de consulta
sort - 'net' (predeterminado), 'total', 'controversial', 'newest'
category - CHARACTER, BEHAVIORAL, CULTURAL, RELATIONSHIP, ...
region - 'world' (region NULL), o código ISO (TR, US, DE, ...)
dominant - 'red', 'green', 'yellow' (aviso: post-filtro)
limit - predeterminado 20, máx 100
offset - paginación, predeterminado 0
Ejemplo
curl -H "Authorization: Bearer grf_xxx..." \
  "https://greenredflagger.com/api/public/flags?sort=net&category=CHARACTER&limit=10"

{
  "count": 10,
  "sort": "net",
  "limit": 10,
  "offset": 0,
  "data": [
    {
      "id": "cln...",
      "slug": "yaslilara-saygi-gosteriyor",
      "category": "CHARACTER",
      "region": null,
      "text": {
        "tr": "Yaslilara saygi gosteriyor",
        "en": "Respects the elderly",
        "de": "Respektiert altere Menschen",
        "es": "Respeta a los mayores"
      },
      "votes": {
        "red": 4200,
        "green": 198400,
        "total": 202600,
        "net": -194200
      },
      "dominant": "green",
      "createdAt": "2026-05-25T..."
    }
  ]
}
GEThttps://greenredflagger.com/api/public/flag/[slug]

Una sola bandera, incluyendo descripción + contextos.

Ejemplo
curl -H "Authorization: Bearer grf_xxx..." \
  "https://greenredflagger.com/api/public/flag/yaslilara-saygi-gosteriyor"

{
  "id": "cln...",
  "slug": "yaslilara-saygi-gosteriyor",
  "category": "CHARACTER",
  "region": null,
  "contexts": ["ROMANTIC", "FRIEND", "FAMILY"],
  "text": { "tr": "...", "en": "...", "de": "...", "es": "..." },
  "description": { "tr": null, "en": null, "de": null, "es": null },
  "votes": { "red": 4200, "green": 198400, "total": 202600, "net": -194200 },
  "dominant": "green",
  "createdAt": "2026-05-25T..."
}
GEThttps://greenredflagger.com/api/public/flag/[slug]/trend

Serie temporal de snapshots de votos diarios de la bandera (rojo/verde/neto en el tiempo). Para dibujar un gráfico de tendencia.

Parámetros de consulta
days - número de días atrás, predeterminado 30, máx 90
Ejemplo
curl -H "Authorization: Bearer grf_xxx..." \
  "https://greenredflagger.com/api/public/flag/sigara-iciyor/trend?days=14"

{
  "slug": "sigara-iciyor",
  "days": 14,
  "count": 14,
  "current": { "red": 18000, "green": 2000, "total": 20000, "net": 16000 },
  "snapshots": [
    {
      "at": "2026-05-15T00:00:00.000Z",
      "red": 17200,
      "green": 1850,
      "total": 19050,
      "net": 15350
    },
    ...
  ]
}
GEThttps://greenredflagger.com/api/public/categories

Todas las categorías + número de banderas aprobadas.

Ejemplo
curl -H "Authorization: Bearer grf_xxx..." \
  "https://greenredflagger.com/api/public/categories"

{
  "count": 8,
  "data": [
    { "slug": "character", "enum": "CHARACTER", "count": 73 },
    { "slug": "behavioral", "enum": "BEHAVIORAL", "count": 45 },
    ...
  ]
}
GEThttps://greenredflagger.com/api/public/regions

Todas las regiones + número de banderas aprobadas. region NULL = 'world'.

Ejemplo
curl -H "Authorization: Bearer grf_xxx..." \
  "https://greenredflagger.com/api/public/regions"

{
  "count": 12,
  "data": [
    { "code": null, "label": "world", "count": 240 },
    { "code": "TR", "label": "TR", "count": 32 },
    { "code": "DE", "label": "DE", "count": 12 },
    ...
  ]
}
GEThttps://greenredflagger.com/api/public/stats

Estadística global: número de flag/user/vote, actividad 24h/7d/30d, top 5 categorías.

Ejemplo
curl -H "Authorization: Bearer grf_xxx..." \
  "https://greenredflagger.com/api/public/stats"

{
  "flags": {
    "total": 294,
    "redDominant": 115,
    "greenDominant": 179,
    "mixed": 0,
    "addedLast24h": 5
  },
  "users": { "total": 142 },
  "votes": {
    "total": 12450,
    "last24h": 240,
    "last7d": 1820,
    "last30d": 8200
  },
  "topCategories": [
    { "slug": "character", "enum": "CHARACTER", "count": 73 },
    ...
  ],
  "generatedAt": "2026-05-28T..."
}
GEThttps://greenredflagger.com/api/public/search

Búsqueda de texto completo (Postgres tsvector, 4 idiomas). 2+ caracteres, prefix-match.

Parámetros de consulta
qrequired - Consulta de búsqueda, al menos 2 caracteres
limit - predeterminado 20, máx 50
Ejemplo
curl -H "Authorization: Bearer grf_xxx..." \
  "https://greenredflagger.com/api/public/search?q=sigara&limit=5"

{
  "count": 3,
  "q": "sigara",
  "data": [
    {
      "id": "cln...",
      "slug": "sigara-iciyor",
      "category": "BEHAVIORAL",
      "region": null,
      "text": { "tr": "Sigara iciyor", "en": "Smokes", ... },
      "votes": { "red": 18000, "green": 2000, "total": 20000, "net": 16000 },
      "dominant": "red",
      "rank": 0.0759
    }
  ]
}

Códigos de error

Esta API ofrece datos de la comunidad votados por usuarios. El contenido devuelto es para entretenimiento, no datos científicos. Se anima a usarlo con atribución; las claves pueden revocarse en caso de abuso.