# Mexico Case Law Search (SCJN: Theses, Precedents, Rulings) (`legaltech/sjf-scjn`) Actor

Search Mexican case law in the SCJN's official Buscador Jurídico: SJF theses (jurisprudencia and tesis aisladas), precedents and Supreme Court rulings, by text, registry number and court.

- **URL**: https://apify.com/legaltech/sjf-scjn.md
- **Developed by:** [Miguel González](https://apify.com/legaltech) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### Mexico Case Law Search (SCJN: Theses, Precedents, Rulings)

Searches Mexican case law in the Buscador Jurídico of the Supreme Court of Justice of the Nation (SCJN), the official search engine that serves the Semanario Judicial de la Federación (SJF): theses (binding jurisprudencia and tesis aisladas) from the SCJN, Plenos Regionales, Plenos de Circuito and Tribunales Colegiados; precedents (ejecutorias) published in the SJF; and SCJN rulings (sentencias). Full-text search in Spanish with "exact phrase"; lookup by registro digital; filters by court (órgano), instance, thesis type, subject (materia), epoch, case type, rapporteur justice (ponente) and dates; sorting by relevance or date. Returns registro digital, rubro, thesis key (clave), type, instance, court, subjects, epoch, publication or decision date, SJF location, precedents, case number, parties, operative part (puntos resolutivos), theses issued, passages and optional full text.

### Use cases

- Find binding jurisprudencia of the SCJN on an issue (e.g. pensión alimenticia, interés superior del menor).
- Retrieve a thesis or precedent by its registro digital, with its full text and precedents.
- List the theses of a specific Tribunal Colegiado or Sala.
- Find SCJN rulings (amparo en revisión, acciones de inconstitucionalidad) by rapporteur justice and get the operative part.

### How to use (guide for AI agents)

- `documentTypes`: tesis (theses), ejecutorias (precedents), sentencias_pub (SCJN rulings) — pick by title.
- `court`, `caseType` and `rapporteur` are matched by "contains" against the official values (an exact name wins): "Primera Sala", "tribunal colegiado en materia civil del primer circuito", "Pardo Rebolledo".
- `thesisType: "Tesis de Jurisprudencia"` returns only binding theses.
- Search terms in Spanish; use quotes for an exact phrase.
- `registryNumbers`: registro digital of a thesis or precedent (e.g. 2013834) or the id of a ruling from a previous result.
- Every result includes `searchTerm` and `rank`; `passages` holds the paragraphs where the search terms appear, ready for LLM analysis.

### Input example

```json
{
    "searchTerms": ["\"pensión alimenticia\""],
    "documentTypes": ["tesis"],
    "instance": "Suprema Corte de Justicia de la Nación",
    "thesisType": "Tesis de Jurisprudencia",
    "subject": "Civil",
    "dateFrom": "2015-01-01",
    "maxResults": 20,
    "passages": 3
}
```

### Output example (abridged)

```json
{
    "searchTerm": "\"pensión alimenticia\"",
    "rank": 1,
    "documentType": "Tesis",
    "registryNumber": 2029528,
    "title": "PENSIÓN ALIMENTICIA. CUANDO SU INCREMENTO SE PACTA EN LA MISMA PROPORCIÓN QUE EL SALARIO MÍNIMO, PARA SU CÁLCULO DEBEN TOMARSE EN CUENTA TODOS LOS FACTORES QUE LO COMPONEN, INCLUIDO EL MONTO INDEPENDIENTE DE RECUPERACIÓN (MIR).",
    "thesisKey": "1a./J. 152/2024 (11a.)",
    "thesisType": "Tesis de Jurisprudencia",
    "instance": "Suprema Corte de Justicia de la Nación",
    "court": "Primera Sala",
    "subjects": [
        "Civil"
    ],
    "epoch": "Undécima Época",
    "publicationDate": "2024-11-15",
    "location": "Libro 43, Tomo III, Volumen 1, p. 137",
    "precedents": "Contradicción de criterios 319/2023. Entre los sustentados por el Cuarto Tribunal Colegiado del Trigésimo Circuito, el Sexto Tribunal Colegiado en Materia Civil...",
    "passages": [
        "Hechos: Los Tribunales Colegiados de Circuito contendientes sustentaron criterios contradictorios al analizar la forma en que debía interpretarse el pacto relat..."
    ],
    "url": "https://bj.scjn.gob.mx/documento/tesis/2029528",
    "sjfUrl": "https://sjf2.scjn.gob.mx/detalle/tesis/2029528"
}
```

### Notes and limits

- The actor uses the SCJN Buscador Jurídico (bj.scjn.gob.mx), which serves the same theses and precedents as the SJF website (sjf2.scjn.gob.mx) through its API.
- Since the 2025 judicial reform the SCJN sits only in Pleno; the Primera and Segunda Sala have no new theses after August 2025.
- Precedents are filtered by year (not by exact date); old theses have no publication date, so "oldest first" sorts them by year.

### Source

Only official sources are used (courts, ministries or the open data published by the courts themselves). Results are returned as published by the source.

### Proxy

By default it uses the Apify **RESIDENTIAL proxy (MX)**, also when called via API or MCP without `proxyConfiguration` (the code applies it), because the Buscador Jurídico blocks datacenter IPs. Each session goes out through a fixed IP (sticky session) and the IP is changed on a block. With `proxyUrls` your own proxies are used and the Apify proxy is not consumed. Residential traffic is billed per GB.

# Actor input Schema

## `searchTerms` (type: `array`):

One search per item, full text, in Spanish. Words (the source ranks by relevance) and "exact phrase" in quotes.

## `registryNumbers` (type: `array`):

Retrieve a thesis or precedent by its registro digital (e.g. "2013834"), or a SCJN ruling by its id (field `registryNumber` of a previous result). Returns the full text.

## `documentTypes` (type: `array`):

Which collections to search. Codes are opaque: do NOT guess them; choose by reading the title (enumTitle) of each option.

## `court` (type: `string`):

Issuing body, matched by "contains": e.g. "Primera Sala", "Pleno", "Segunda Sala" or "tribunal colegiado en materia civil del primer circuito". For rulings: PLENO, PRIMERA SALA, SEGUNDA SALA.

## `instance` (type: `string`):

Issuing instance of theses and precedents. Pick by option title.

## `thesisType` (type: `string`):

Jurisprudencia (binding) or tesis aislada. Applies to theses only.

## `subject` (type: `string`):

Subject area (materia) of the thesis. Applies to theses only.

## `epoch` (type: `string`):

SJF epoch (época). Applies to theses only.

## `caseType` (type: `string`):

Matched by "contains": e.g. "amparo directo en revisión", "acción de inconstitucionalidad", "controversia constitucional", "contradicción".

## `rapporteur` (type: `string`):

Ministro ponente, matched by "contains": e.g. "Pardo Rebolledo".

## `dateFrom` (type: `string`):

Publication date (theses) or decision date (rulings), start of range (YYYY-MM-DD). Precedents are filtered by year.

## `dateTo` (type: `string`):

End of range (YYYY-MM-DD).

## `sortOrder` (type: `string`):

Sort criterion.

## `maxResults` (type: `integer`):

Maximum per search term and document type.

## `passages` (type: `integer`):

Paragraphs of the document containing the search terms, returned in `passages` (0 = none; then the document is not opened). Ideal for LLM analysis.

## `includeFullText` (type: `boolean`):

Adds the `text` field with the full thesis, precedent or ruling. Greatly increases output size for rulings.

## `connection` (type: `string`):

The SCJN site (Incapsula) asks networks with low IP reputation, such as proxies, to run its verification script first. "auto" calls the API directly and, at the first block, switches to a regular Chromium (Playwright) that loads the home page, lets the site run its own JavaScript and then calls the API from that page. No stealth plugins or CAPTCHA solving are used.

## `proxyConfiguration` (type: `object`):

Default: Apify RESIDENTIAL proxy (MX), because the source blocks datacenter IPs. If this field is omitted (API or MCP call), the actor applies it anyway. With proxyUrls your own proxies are used and the Apify proxy is not consumed.

## Actor input object example

```json
{
  "searchTerms": [
    "interés superior del menor"
  ],
  "registryNumbers": [],
  "documentTypes": [
    "tesis"
  ],
  "instance": "",
  "thesisType": "",
  "subject": "",
  "epoch": "",
  "sortOrder": "relevance",
  "maxResults": 20,
  "passages": 3,
  "includeFullText": false,
  "connection": "auto",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "MX"
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset of theses, precedents and rulings returned by the search, one item per result. Main fields: searchTerm, documentType, registryNumber, title, thesisKey, thesisType, court, publicationDate, decisionDate, passages, url. See the dataset schema for the full list of fields.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "searchTerms": [
        "interés superior del menor"
    ],
    "registryNumbers": [],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "MX"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("legaltech/sjf-scjn").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "searchTerms": ["interés superior del menor"],
    "registryNumbers": [],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "MX",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("legaltech/sjf-scjn").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchTerms": [
    "interés superior del menor"
  ],
  "registryNumbers": [],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "MX"
  }
}' |
apify call legaltech/sjf-scjn --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,legaltech/sjf-scjn"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Ml5d7huD9K45Wcd2y/builds/LNRNZJeLzK8aHu01x/openapi.json
