Ir para o texto

Desenvolvedores · Referência

API de horários de Missa

Um diretório mundial de igrejas e dos horários de suas Missas, confissões e adoração. As leituras são abertas a todos; uma correção é uma sugestão que uma pessoa revisa.

Passe isto ao seu agente ember.dpgu.me/llms.txt · esta página em Markdown

O básico

URL base
https://ember-mass-times.dpgu.workers.dev
OpenAPI
openapi.json, para Postman, Bruno ou um gerador de clientes (em inglês)
Autenticação
Nenhuma. Toda rota aceita qualquer origem, então uma página web pode chamá-la diretamente.
Cache
As leituras são public, max-age=300; os blocos do mapa, uma hora, e mais um dia servidos enquanto se revalidam.
Erros
Uma igreja inexistente é 404 { "error": "not_found" }. Um parâmetro inválido é 400 com os problemas de validação. Escritas demais são 429 { "error": "rate_limited" }.

As descrições curtas de parâmetros e campos vêm dos schemas no código e estão em inglês.

Lendo os horários

Os services de uma igreja são seus horários recorrentes, cada um com um padrão e uma hora: “domingos às 9h” é um horário e “domingos às 11h30” é outro. rrule é uma regra do iCalendar que escolhe os dias, e startTime dá a hora local no timezone da própria igreja. exdate lista os dias cancelados e rdate os acrescentados. A API manda as regras sem expandir, então é você quem calcula a próxima Missa.

O expand.ts faz isso em sessenta linhas com o pacote rrule e, como todo o código do Ember, está em domínio público para copiar:

JavaScript
import { expandService } from './expand' // packages/api/src/expand.ts

const church = await (await fetch('https://ember-mass-times.dpgu.workers.dev/churches/ns-do-carmo-se-sao-paulo-sp')).json()
for (const service of church.services.filter((s) => s.kind === 'mass')) {
  for (const { date, startTime } of expandService(service, { count: 3 })) {
    console.log(date.toISOString().slice(0, 10), startTime, service.language)
  }
}

Um bundler o aceita como está. No Node puro, o rrule não tem exports nomeados: escreva import rrule from 'rrule' e const { RRule, RRuleSet } = rrule.

Quando não há horário estruturado registrado (hasStructuredSchedule é falso), o texto da própria paróquia está em texts, como foi publicado.

Igrejas

Leituras públicas

GET /churches/near

Igrejas perto de um ponto

Igrejas a até radiusKm de um ponto, da mais próxima à mais distante. Um filtro de kind ou rite restringe os horários de cada igreja e tira as que ficam sem nenhum.

Parâmetros
lat query obrigatório number
lng query obrigatório number
radiusKm query number
kind query string

Keep only services of this kind: mass, confession, adoration

rite query string

Keep only services of this rite, e.g. latin_tridentine

institute query string

Only churches served by this institute, e.g. FSSP

status query string

active | temporarily_closed | closed

limit query integer

Respostas

  • 200 OK { churches: (Church & { distanceKm: number })[] }
  • 400 Um parâmetro ou o corpo não passou na validação ValidationError

Experimente

https://ember-mass-times.dpgu.workers.dev/churches/near?lat=-23.5505&lng=-46.6333&radiusKm=2&limit=5
GET /churches

Buscar pelo nome, ou ler a área de um mapa

Passe q para buscar pelo nome, ou bbox para as igrejas na área visível de um mapa. Uma área grande demais para listar responde com clusters, contados por célula de geohash.

Parâmetros
q query string

Name search

near query string

With q: "lat,lng" to rank matches nearest it first

bbox query string

A map viewport, "minLng,minLat,maxLng,maxLat": churches, or clusters when wide

kind query string
rite query string
institute query string
status query string
limit query integer
offset query integer

Respostas

  • 200 { churches } para uma busca, { churches, clusters } para uma área do mapa { churches: Church[], clusters?: Cluster[] }
  • 400 Um parâmetro ou o corpo não passou na validação ValidationError

Experimente

https://ember-mass-times.dpgu.workers.dev/churches?q=Carmo&near=-23.5505%2C-46.6333&limit=5
GET /churches/index

O diretório inteiro, uma página por vez

Todas as igrejas na ordem do id, com os poucos campos de que um sitemap precisa, ou com full=1 cada igreja inteira, como /churches/{id} a dá. Passe o next de uma página como o after da seguinte; uma página sem next é a última.

Parâmetros
after query string

The last id of the previous page

scheduled query "1"

Only churches with service times on record

country query string

Only churches in these countries: ISO codes, comma-separated (BR,PT)

limit query integer
full query "1"

Each church whole, as /churches/{id} gives it: schedule, texts, links, parish and chapels

Respostas

  • 200 OK { churches: { id: string, name: string, longName: string | null, city: string | null, region: string | null, countryCode: string | null, hasStructuredSchedule: boolean | null, updatedAt: string | null }[], next?: string }
  • 400 Um parâmetro ou o corpo não passou na validação ValidationError

Experimente

https://ember-mass-times.dpgu.workers.dev/churches/index?limit=5
GET /churches/tiles/{cell}

Um bloco do mapa

Uma célula de cinco caracteres responde com suas igrejas (sem textos e links); uma mais curta, ou root, com a contagem das células dentro dela. Fica uma hora em cache.

Parâmetros
cell path obrigatório string

A geohash of 1–5 characters, or root

kind query string

Count only churches with services of this kind

Respostas

  • 200 { churches } para uma célula completa, { cells } acima dela { churches: Church[] } | { cells: Cluster[] }
  • 400 Um parâmetro ou o corpo não passou na validação ValidationError

Experimente

https://ember-mass-times.dpgu.workers.dev/churches/tiles/6gyf
GET /churches/{id}

Uma igreja

Uma igreja com seus horários, textos e links, a paróquia a que pertence e as capelas que atende.

Parâmetros
id path obrigatório string

O id da igreja, feito do nome e da cidade

Respostas

Experimente

https://ember-mass-times.dpgu.workers.dev/churches/ns-do-carmo-se-sao-paulo-sp
GET /churches/{id}/verifications

Confirmações dos horários de uma igreja

Quando as pessoas confirmaram os horários registrados, da mais recente à mais antiga.

Parâmetros
id path obrigatório string

O id da igreja, feito do nome e da cidade

limit query integer
offset query integer

Respostas

Experimente

https://ember-mass-times.dpgu.workers.dev/churches/ns-do-carmo-se-sao-paulo-sp/verifications?limit=5

Mudanças

O que os moderadores mudaram, para diretórios que acompanham

GET /changes

O registro de mudanças

Cada mudança que um moderador aplicou ao diretório e que continua valendo, da mais recente à mais antiga. Cada igreja atingida vem com o que mudou e seus horários como estão agora, e message diz o mesmo em texto simples, pronta para repassar. Passe o next de uma página como o before da seguinte; para acompanhar, peça com since igual ao appliedAt mais recente que você tem.

Mudanças recentes mostra o mesmo registro numa página.

Parâmetros
since query string

Only changes applied after this instant (ISO 8601)

before query string

The last id of the previous page

church query string

Only changes that touched this church

lang query "en" | "pt"

The language of every message; by default each church’s own

limit query integer

Respostas

  • 200 OK { changes: { id: string, appliedAt: string, churches: ChangedChurch[], message: string }[], next?: string }
  • 400 Um parâmetro ou o corpo não passou na validação ValidationError

Experimente

https://ember-mass-times.dpgu.workers.dev/changes?limit=5

Sugestões

Escritas com limite de frequência, revisadas antes de valer

POST /churches/{id}/verify

Confirmar os horários registrados

Conta uma vez por cliente e igreja a cada 30 dias; uma repetição responde deduped: true e não registra nada.

Parâmetros
id path obrigatório string

O id da igreja, feito do nome e da cidade

X-Client-Id header string

Um id fixo por aparelho ou pessoa; junto com o IP, identifica o cliente para o limite de escritas e para as confirmações

Corpo da requisição

serviceId string

The service confirmed; none confirms the whole church

Respostas

  • 200 OK { deduped: boolean }
  • 400 Um parâmetro ou o corpo não passou na validação ValidationError
  • 429 Escritas demais deste cliente: rate_limited Error
Terminal
curl -X POST 'https://ember-mass-times.dpgu.workers.dev/churches/ns-do-carmo-se-sao-paulo-sp/verify' \
  -H 'Content-Type: application/json' -H 'X-Client-Id: device-7f3a2c' \
  -d '{}'
POST /churches/{id}/corrections

Sugerir uma correção

Põe na fila de um moderador uma mudança num horário ou na igreja, um novo horário, um fechamento ou uma observação. kind define a forma do restante.

Parâmetros
id path obrigatório string

O id da igreja, feito do nome e da cidade

X-Client-Id header string

Um id fixo por aparelho ou pessoa; junto com o IP, identifica o cliente para o limite de escritas e para as confirmações

Corpo da requisição

kind: "edit_service"

kind obrigatório "edit_service"
serviceId obrigatório string
changes obrigatório object
↳ kind string
↳ rite string
↳ language string
↳ rrule string
↳ startTime string
↳ endTime string
↳ exdate string
↳ rdate string
↳ locationNote string
↳ note string
comment string at least 1 charactersat most 2000 characters
attachmentKeys string[] at most 10 items

kind: "edit_church"

kind obrigatório "edit_church"
changes obrigatório object
↳ name string
↳ longName string
↳ address string
↳ city string
↳ region string
↳ postalCode string
↳ country string
↳ phoneE164 string
↳ email string
↳ status string
↳ administration string
↳ institute string
↳ canonicalStatus string
↳ note string
comment string at least 1 charactersat most 2000 characters
attachmentKeys string[] at most 10 items

kind: "add_service"

kind obrigatório "add_service"
changes obrigatório object
↳ kind obrigatório string
↳ rite string
↳ language string
↳ rrule obrigatório string
↳ startTime obrigatório string
↳ endTime string
↳ exdate string
↳ rdate string
↳ locationNote string
↳ note string
comment string at least 1 charactersat most 2000 characters
attachmentKeys string[] at most 10 items

kind: "flag_closed"

kind obrigatório "flag_closed"
serviceId string
comment string at least 1 charactersat most 2000 characters
attachmentKeys string[] at most 10 items

kind: "note"

kind obrigatório "note"
serviceId string
comment obrigatório string at least 1 charactersat most 2000 characters
attachmentKeys string[] at most 10 items

Respostas

  • 201 Na fila { id: string }
  • 400 Um parâmetro ou o corpo não passou na validação ValidationError
  • 429 Escritas demais deste cliente: rate_limited Error
Terminal
curl -X POST 'https://ember-mass-times.dpgu.workers.dev/churches/ns-do-carmo-se-sao-paulo-sp/corrections' \
  -H 'Content-Type: application/json' -H 'X-Client-Id: device-7f3a2c' \
  -d '{"kind": "note", "comment": "A partir de outubro, a Missa de domingo é às 9h30."}'
POST /churches/{id}/corrections/attachments

Anexar uma foto a uma correção

Os bytes de um arquivo de até 1 MB, como a foto do boletim. Envie a key devolvida nos attachmentKeys da correção.

Parâmetros
id path obrigatório string

O id da igreja, feito do nome e da cidade

X-Client-Id header string

Um id fixo por aparelho ou pessoa; junto com o IP, identifica o cliente para o limite de escritas e para as confirmações

Corpo da requisição

Respostas

  • 201 Guardado { key: string }
  • 400 Corpo vazio: empty_body Error
  • 413 Maior que 1 MB: too_large Error
  • 429 Escritas demais deste cliente: rate_limited Error
Terminal
curl -X POST 'https://ember-mass-times.dpgu.workers.dev/churches/ns-do-carmo-se-sao-paulo-sp/corrections/attachments' \
  -H 'Content-Type: image/jpeg' -H 'X-Client-Id: device-7f3a2c' \
  --data-binary @bulletin.jpg
GET /health

Verificação de funcionamento

Respostas

  • 200 OK { ok: boolean }

Schemas

Church

id obrigatório string
name obrigatório string
longName obrigatório string | null
address obrigatório string | null
city obrigatório string | null
region obrigatório string | null
postalCode obrigatório string | null
country obrigatório string | null
countryCode obrigatório string | null
lat obrigatório number
lng obrigatório number
geohash obrigatório string
timezone obrigatório string
phoneE164 obrigatório string | null
email obrigatório string | null
status obrigatório string | null
featured obrigatório boolean | null
administration obrigatório string | null
institute obrigatório string | null
canonicalStatus obrigatório string | null
parishId obrigatório string | null
note obrigatório string | null
hasStructuredSchedule obrigatório boolean | null
lastVerifiedAt obrigatório string | null
verifiedSource obrigatório string | null
updatedAt obrigatório string | null
services obrigatório Service[] | null
texts obrigatório ChurchText[] | null
links obrigatório ChurchLink[] | null

Service

id obrigatório string
kind obrigatório string

mass | confession | adoration

rite string

Mass only: latin_novus_ordo | latin_tridentine | byzantine | …

language string

ISO 639

rrule obrigatório string

iCal RRULE: one pattern at one time

startTime obrigatório string

'HH:MM' wall-clock in the church's timezone

endTime string
exdate string

RRuleSet EXDATE: cancelled dates

rdate string

RRuleSet RDATE: one-off added dates

locationNote string
note string
source string

import | manual | user

confidence number

ChurchText

kind obrigatório string

mass_times | seasonal_mass_times | confession | adoration | info

rawText obrigatório string
sourceUpdatedAt string

ChurchKin

id obrigatório string
name obrigatório string

Cluster

id obrigatório string

The geohash cell

lat obrigatório number
lng obrigatório number
count obrigatório integer
church ChurchKin

Named when the cell holds one church

Verification

id obrigatório string
churchId obrigatório string
serviceId obrigatório string | null
fingerprint obrigatório string
createdAt obrigatório string

ChangeLine

label obrigatório string
before string
after string

ChangedChurch

id obrigatório string
name obrigatório string
isNew obrigatório boolean

Created by this change

parish ChurchKin

The parish this church is a chapel of

place obrigatório string
lat obrigatório number
lng obrigatório number
changes obrigatório ChangeLine[]
schedule obrigatório { kind: string, label: string, times: string[] }[]

Error

error obrigatório string

ValidationError

success: false

success obrigatório false
error obrigatório object
↳ name obrigatório "ZodError"
↳ message obrigatório string