Lex API MX — cliente Python
Cliente mínimo de Lex API MX para consultar la legislación federal mexicana vigente. Cada respuesta trae la fuente oficial, el checksum SHA-256 del texto y su periodo de vigencia.
pip install lex-api-mx-client
from lex_api_mx import LexApiClient, LexApiError
with LexApiClient(base_url="https://api.lexapi.mx", api_key="tu_clave") as lex:
paquete = lex.resolve(query="Artículo 47 LFT", as_of="2026-10-08")
articulos = lex.search_articles(query="aguinaldo", norm="lft", jurisdiction="federal")
arbol = lex.norm_structure("lft")
| Método | Endpoint |
|---|---|
resolve(query, norm=None, jurisdiction="federal", as_of=None, limit=10) |
POST /api/v1/resolve |
search_articles(query, norm=None, matter=None, jurisdiction=None, as_of=None, limit=20) |
GET /api/v1/articulos/search |
norm_structure(norm, as_of=None, include_text=False, page=1, page_size=None) |
GET /api/v1/normas/{slug}/estructura (texto según permisos de la cuenta, por páginas de nodos: revisa text_page.has_more) |
map(query, jurisdiction=None, as_of=None) |
POST /api/v1/map (requiere el permiso map:read) |
resolve y map aceptan idempotency_key: un reintento con la misma clave no
se cobra dos veces. Los errores HTTP se lanzan como LexApiError con
status_code, detail, request_id, body y retry_after; 402 significa
saldo agotado.
Un 429 (límite de peticiones) no se cobra: el cliente espera los segundos de
Retry-After y reintenta solo, hasta max_retries=2 veces, cuando la espera no
pasa de max_retry_wait=30.0 segundos. Una espera mayor, como el límite diario
del plan gratuito, se lanza enseguida como LexApiError con retry_after.
LexApiClient(..., max_retries=0) desactiva los reintentos.
Para obtener una clave, crea tu cuenta en lexapi.mx/cuenta. Referencia de la API: lexapi.mx/docs.
Para usar Lex API MX desde Claude, Cursor u otro agente, instala el servidor MCP
lex-api-mx-mcp.
Código fuente: github.com/Julio-Patron/lexapi-mx. Licencia MIT.
Lectura incluida y versión 0.4.0
API y MCP requieren la misma clave de una cuenta con correo confirmado. La política
activa de Cuenta determina cuota y permisos; la lectura incluida no exige créditos.
La cuota mensual se comparte entre claves por cuenta y mes UTC. monthly_quota_exceeded
indica cuándo se renueva; no se resuelve comprando créditos. Se mantienen límites de
texto, resultados, tamaño y concurrencia.
El SDK 0.4.0 incluye article, list_norms, norm, article_history y
corpus_status, además de búsqueda, estructura, resolve y mapa. El MCP expone
las ocho lecturas normativas y el estado público del corpus; el mapa conserva
un catálogo limitado de temas. Las ocho lecturas normativas aceptan
idempotency_key: conserva identificador y parámetros para el mismo reintento;
una petición distinta es otro evento. No se eliminan límites de ráfagas por reintentar.
corpus_status() consulta el estado público y no consume cuota.
La API y el MCP son gratuitos; no se venden planes ni recargas. Confirma tu correo y entra en Cuenta para recibir tu primera clave. Las cuentas anteriores pueden aceptar allí los límites gratuitos, conservando saldos e historial.
Metadata
Release files for lex-api-mx-client 0.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lex_api_mx_client-0.4.2.tar.gz | 6.8 kB | With provenance | Details for lex_api_mx_client-0.4.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lex_api_mx_client-0.4.2-py3-none-any.whl | Python 3 | none | any | Details for lex_api_mx_client-0.4.2-py3-none-any.whl |
Total release size: 13.4 kB
Release files / lex_api_mx_client-0.4.2.tar.gz
| Download URL | lex_api_mx_client-0.4.2.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f24c947ee0eb1e3c4552b9d77a0c9ab0f42d7378633e9f5434439d582ea9576d
|
|
BLAKE2b-256 checksum How to use checksums |
160265295f32ebd972a761d4e7f8981e9d83b12d4cb7d529d0bd766c8cd622eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logRelease files / lex_api_mx_client-0.4.2-py3-none-any.whl
| Download URL | lex_api_mx_client-0.4.2-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
59ed41bb04f7226c543ff0d28e1540a6d534536c53e91ed909b231902e586ff5
|
|
BLAKE2b-256 checksum How to use checksums |
812a50eb3263de9bad999b707a35cafaf7bf8c998dd5e7c00aea4e522d991d4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logSecurity for lex-api-mx-client 0.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for lex_api_mx_client-0.4.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.