# Portuguese Constitutional Court - Case Law Search (`legaltech/tribunal-constitucional-pt`) Actor

Search decisions of the Portuguese Constitutional Court by text, chamber, proceeding type, reporting judge and date, with operative part and full text.

- **URL**: https://apify.com/legaltech/tribunal-constitucional-pt.md
- **Developed by:** [Miguel González](https://apify.com/legaltech) (community)
- **Categories:** Automation
- **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

### Portuguese Constitutional Court - Case Law Search

Searches the decisions (acórdãos) of the Portuguese Constitutional Court (Tribunal Constitucional, 1983-present) in its official database (tribunalconstitucional.pt) by free text with word exclusion, and filters by chamber (Plenário, 1st-3rd Secção, Conferência), type of proceeding (Recurso, Reclamação, Preventivo, Sucessivo…), reporting judge (approximate name, accents optional) and decision date range. Returns decision number, case number, chamber, proceeding type, date and reporting judge, and can open each decision to extract the operative part ("Decisão") and the full text. Specific decisions can be fetched directly by URL. Limits: the official search pages 30 results at a time; extracting the operative part requires one request per decision.

### Use cases

- Find Constitutional Court decisions on a statute or topic (e.g. insolvency, administrative fines).
- List the decisions of a given reporting judge in a period.
- Filter by proceeding type (preventive or abstract review, appeal, complaint) or by plenary decisions.
- Get the operative part of each decision to see whether a provision was declared unconstitutional.

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

- `section` and `species`: pick by option title; do not invent values.
- `relator`: write the judge name as used by the Court (e.g. "Afonso Patrão"); partial and accent-free matches work.
- Dates use YYYY-MM-DD; you may give only one end of the range.
- Set `includeDecision: false` for a much faster run (list metadata only).
- Every result includes `searchTerm` and `rank`; `passages` holds the paragraphs where the search terms appear, ready for LLM analysis.

### Input example

```json
{
    "searchTerms": ["insolvência"],
    "relator": "Afonso Patrão",
    "dateFrom": "2023-01-01",
    "dateTo": "2024-12-31",
    "maxResults": 30,
    "includeDecision": true,
    "includeFullText": false
}
```

### Output example (abridged)

```json
{
    "searchTerm": "insolvência",
    "court": "Tribunal Constitucional",
    "rank": 1,
    "acordaoNumber": "148/23",
    "processNumber": "143/23",
    "section": "Conf.",
    "species": "Reclamação",
    "decisionDate": "30.03.2023",
    "decisionDateISO": "2023-03-30",
    "relator": "Afonso Patrão",
    "documentUrl": "https://www.tribunalconstitucional.pt/tc/acordaos/20230148.html",
    "title": "ACÓRDÃO Nº 148/2023",
    "relatorFull": "Conselheiro Afonso Patrão",
    "decisionText": "Pelo exposto, decide-se indeferir a reclamação..."
}
```

### Notes and limits

- Search terms should be in Portuguese.
- For Constitutional Court decisions before 1998 with official headnotes, see also `legaltech/dgsi` (database `atco1`).

### 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

Uses the **Apify RESIDENTIAL proxy (PT)** by default, also when called via API or MCP without `proxyConfiguration` (the code applies it). Each session keeps a fixed IP (sticky session) and the IP is rotated when blocked. With `proxyUrls` your own proxies are used and no Apify proxy is consumed; to run without a proxy, pass `{"useApifyProxy": false}`. Residential traffic is billed per GB.

# Actor input Schema

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

Words to search in the text of the decisions (Portuguese). One search per item.

## `excludeTerms` (type: `string`):

Words that must NOT appear in the decision.

## `section` (type: `string`):

Chamber or formation that issued the decision. Codes are opaque: do NOT guess them; choose by reading the title (enumTitle) of each option.

## `species` (type: `string`):

Type of constitutional proceeding (Recurso = appeal, Reclamação = complaint, Preventivo = preventive review, Sucessivo = abstract review…).

## `relator` (type: `string`):

Reporting judge name as used by the Court (e.g. "Afonso Patrão"). Partial and accent-free matches work.

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

Decision date, start of range (YYYY-MM-DD).

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

Decision date, end of range (YYYY-MM-DD).

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

Maximum decisions per search term. The Court pages results 30 at a time.

## `includeDecision` (type: `boolean`):

Opens each decision and extracts its operative part ("Decisão"). Disable for a much faster, list-only run.

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

Adds the `text` field with the full decision. Greatly increases output size; enable only if needed.

## `documentUrls` (type: `array`):

URLs of decisions (`documentUrl` from previous results, e.g. https://www.tribunalconstitucional.pt/tc/acordaos/20240809.html). Maximum 100 per run.

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

Default: Apify RESIDENTIAL proxy (PT). If omitted (API/MCP call), the actor applies it anyway. With proxyUrls your own proxies are used instead.

## Actor input object example

```json
{
  "searchTerms": [
    "insolvência"
  ],
  "section": "",
  "species": "",
  "maxResults": 10,
  "includeDecision": true,
  "includeFullText": false,
  "documentUrls": [],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "PT"
  }
}
```

# Actor output Schema

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

Dataset of decisions returned by the search, one item per result. Main fields: searchTerm, acordaoNumber, decisionDateISO, processNumber, section, species, relator, decisionText, documentUrl. 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": [
        "insolvência"
    ],
    "documentUrls": [],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "PT"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("legaltech/tribunal-constitucional-pt").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": ["insolvência"],
    "documentUrls": [],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "PT",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("legaltech/tribunal-constitucional-pt").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": [
    "insolvência"
  ],
  "documentUrls": [],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "PT"
  }
}' |
apify call legaltech/tribunal-constitucional-pt --silent --output-dataset

```

## MCP server setup

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

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/UBgCO40c3Q8yw57MC/builds/CsPjTXlgVziRJW2Y1/openapi.json
