Prototype client for SIDOF's undocumented JSON open data service for Mexico's official gazette (DOF).
Project description
dofjson
Prototype client for the JSON open data service exposed by sidof.segob.gob.mx, the Secretaría de Gobernación's system for Mexico's official gazette (DOF, Diario Oficial de la Federación).
The service's public docs only show sample responses, but its real,
unauthenticated endpoints were found under https://sidof.segob.gob.mx/dof/sidof/:
| Endpoint | Description |
|---|---|
GET /diarios/porFecha/DD-MM-YYYY |
Edition metadata for a date (Matutina/Vespertina/Extraordinaria) |
GET /notas/DD-MM-YYYY |
Notes/documents published on a date |
GET /notas/nota/{codNota} |
Full detail of a single note, including its HTML content |
GET /indicadores/DD-MM-YYYY |
Economic indicators (exchange rate, TIIE, UDIS) |
This is an experimental package for evaluating whether this service is a
viable alternative (or complement) to dof2md's PDF download + Markdown
conversion pipeline — notes already come with structured HTML content,
which may be easier to work with than OCR'd PDFs.
On top of the raw endpoints, the client offers note-scoped downloads that
resolve a note's page span (infer_paginas) and fetch it in whichever form
you want:
download_nota_imagenes(codNota)— the note's scanned page image(s).download_nota_pdf(codNota)— the note as its own PDF: the whole edition PDF (there is no per-note PDF endpoint) sliced to just the note's pages, usingpypdf.
Usage
pip install -e "packages/dofjson[test]"
dofjson 2026-07-16 --endpoint notas --outdir output
Building a local archive of daily indexes (--archivo)
dofjson --archivo downloads the daily notes index incrementally, day by
day, over a whole date range (by default from January 2, 1917 to today). For
each date it does exactly what dofjson YYYY-MM-DD --endpoint notas does —
get_notas(date) filtered with quita_notas_sin_titulo — and saves one JSON
per day. It does not download each note's content or scanned images: only
the index.
dofjson --archivo # 1917-01-02 -> today
dofjson --archivo --desde 1980-01-01 --hasta 1980-12-31
dofjson --archivo --pausa 1.0 # slower (kinder to the server)
Output goes to notas-archivo/ (configurable with --outdir), a local,
never-committed directory (it is in the repo's .gitignore), with the same
per-day filenames the plain command produces:
notas-archivo/
.completados # registry of finished days (for resuming)
2026/
15072026-notas.json # index for 2026-07-15 (get_notas, filtered)
16072026-notas.json
1980/
02011980-notas.json
The mode is resumable and idempotent: the .completados registry records the
finished days, so each run only fetches what is missing. Days that fail with
network errors are not marked and get retried on the next run; days the
service does not have (holidays, weekends, very old dates — a 404) are
marked so they are not retried forever. "Today" is never marked, so late
additions are picked up by a later run. You can interrupt with Ctrl-C and
resume at any time.
The full range is ~40,000 days: a long download, meant to be run in parts. Start with a bounded range via
--desde/--hastaif you only need an era.
Development
pytest packages/dofjson
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dofjson-0.1.0.tar.gz.
File metadata
- Download URL: dofjson-0.1.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8153553fb478ebc7d841559d7c11ad1a4766a6b54332f19cc4262b496f061fe
|
|
| MD5 |
9ae820f703efacd98da90cdcac1ffcb9
|
|
| BLAKE2b-256 |
220c60822992e234bb715d5e45787da464480947b520ae0ceec9b24e554f0f9e
|
File details
Details for the file dofjson-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dofjson-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6faf189166aace6294e59ddd33615b832fde0d69b2f3be4d148e777205135ae
|
|
| MD5 |
87791689529359736184abb13bbd803e
|
|
| BLAKE2b-256 |
05efbcc14d2b7d451b218b48c341205f10e991a67ced393419f1cedd7edd5ecb
|