# Vietnam Legal Documents Metadata (`duytrinh98/vietnam-legal-documents`) Actor

Extracts metadata and attachment links of Vietnamese legal documents (decrees, circulars, decisions) from the official government portal vanban.chinhphu.vn.

- **URL**: https://apify.com/duytrinh98/vietnam-legal-documents.md
- **Developed by:** [Anh Duy Trịnh](https://apify.com/duytrinh98) (community)
- **Categories:** Business, AI
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$30.00 / 1,000 legal documents

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## Vietnam Legal Documents Scraper & Metadata API

Extract structured metadata and official attachment links for **Vietnam legal documents**—including **Vietnamese decrees and circulars**, decisions, and government regulations—directly from the official government portal [vanban.chinhphu.vn](https://vanban.chinhphu.vn/).

Whether you need a reliable **vanban.chinhphu.vn scraper** for **compliance monitoring**, a programmatic **legal data API** for automated alerts, or a clean **dataset for AI and RAG** (Retrieval-Augmented Generation) systems, this Actor provides structured, machine-readable legal metadata on demand.

***

### What it does

- **Scrapes official legal metadata**: Extracts document numbers, legal classifications (e.g., Nghị định, Thông tư, Quyết định), issuing bodies, issuance dates, effective dates, and official Vietnamese summaries (*trích yếu*).
- **Collects direct attachment links**: Returns the direct URLs of the attachment files published with each document (typically signed PDFs hosted on `datafiles.chinhphu.vn`).
- **Supports two extraction modes**:
  - *Listing mode (Default)*: Collects the latest legal documents linked on the source portal's listing page (defaults to 50 documents).
  - *ID range mode*: Traverses a specific document ID interval (`docIdFrom` to `docIdTo`) from highest to lowest.
- **Filters results in-flight**: Narrow records by document type (e.g., `Nghị định`) or issuing authority (e.g., `Chính phủ`, `Bộ Tài chính`).
- **Consistent output format**: Dates use `YYYY-MM-DD` where the source provides them, attachments come as a structured array, and every record carries its source attribution. Missing metadata is returned as `null`.

***

### Who is it for

- **Legal Tech & Engineering Teams**: Build document search engines, discovery platforms, and automated legal notification feeds.
- **Compliance & Regulatory Teams**: Track new legal issuances, ministerial circulars, and government decrees for regulatory compliance.
- **Foreign & Domestic Enterprises**: Research applicable Vietnamese regulatory frameworks and sector-specific legislation.
- **AI Agents & RAG Pipelines**: Feed verified metadata and source links into semantic search indexes, vector databases, and LLM workflows.

***

### Transparent Pricing

This Actor operates under Apify's **pay per event** model:

- **$0.03 USD per legal document saved** ($30 USD per 1,000 documents).
- **Platform usage is included**: Compute costs are covered by the event price. You pay nothing extra for running the Actor.
- **Pay only for saved matches**: If a document does not match your specified filters, it is not saved to the dataset and you are not charged for it.

***

### Input Parameters

| Field | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `maxDocuments` | Integer | `50` | Maximum matching documents to output (minimum: `1`, maximum: `1000`). |
| `docIdFrom` | Integer | *Unset* | Document ID range bound (minimum: `1`). Required if `docIdTo` is set. |
| `docIdTo` | Integer | *Unset* | Other inclusive range bound (minimum: `1`). Required if `docIdFrom` is set. Range is visited from highest to lowest ID. |
| `documentType` | String | *Unset* | Case-insensitive substring filter on document type (e.g., `Nghị định`, `Thông tư`, `Quyết định`). |
| `issuingBody` | String | *Unset* | Case-insensitive substring filter on the issuing ministry or government body (e.g., `Bộ Xây dựng`, `Chính phủ`). |

#### How extraction modes work

- **Listing mode (without ID bounds)**: The Actor extracts document IDs linked on the primary listing page of `vanban.chinhphu.vn`. A default run retrieves up to 50 documents.
- **Range mode (with `docIdFrom` and `docIdTo`)**: Both bounds must be positive integers. The Actor inspects document IDs between these two numbers inclusive, processing from highest to lowest.
- **Filtering**: Filters apply after retrieving each document's metadata. If fewer candidates match your criteria than `maxDocuments`, the final dataset will contain only matching records.

#### Input Examples

##### Example 1: Latest documents (Default configuration)

Fetches up to 50 recent legal documents from the listing page:

```json
{
  "maxDocuments": 50
}
```

##### Example 2: Targeted ID range with document type filter

Scans document IDs between 220190 and 220210, saving only Government Decrees (*Nghị định*):

```json
{
  "maxDocuments": 20,
  "docIdFrom": 220190,
  "docIdTo": 220210,
  "documentType": "Nghị định"
}
```

##### Example 3: Filter by issuing body

Collects recent documents issued by the Ministry of Construction (*Bộ Xây dựng*):

```json
{
  "maxDocuments": 30,
  "issuingBody": "Bộ Xây dựng"
}
```

***

### Output Data Structure

The Actor saves records directly into the Apify Dataset storage. Each record conforms to the following schema:

| Field | Type | Description |
| :--- | :--- | :--- |
| `docId` | String / Null | Internal document identifier on `vanban.chinhphu.vn`. |
| `url` | String / Null | Webpage URL of the document on the source portal. |
| `documentNumber` | String / Null | Official document number and notation (e.g., `401/2026/NĐ-CP`). |
| `documentType` | String / Null | Document classification (e.g., `Nghị định`, `Thông tư`). |
| `issuingBody` | String / Null | Agency or ministry that issued the document. |
| `issueDate` | String / Null | Date of issuance in ISO format (`YYYY-MM-DD`). |
| `effectiveDate` | String / Null | Specified effective date in ISO format (`YYYY-MM-DD`). |
| `summaryVi` | String / Null | Official Vietnamese summary title (*trích yếu*). |
| `attachments` | Array / Null | List of attached files, each containing `name` and `url`. |
| `source` | String / Null | Origin site domain (`vanban.chinhphu.vn`). |
| `attribution` | String / Null | Mandatory attribution string (`Nguồn: vanban.chinhphu.vn`). |

#### Output Example

```json
[
  {
    "docId": "220209",
    "url": "https://vanban.chinhphu.vn/?pageid=27160&docid=220209",
    "documentNumber": "401/2026/NĐ-CP",
    "documentType": "Nghị định",
    "issuingBody": "Chính phủ",
    "issueDate": "2026-11-04",
    "effectiveDate": "2026-12-22",
    "summaryVi": "Quy định xử phạt vi phạm hành chính trong lĩnh vực công nghiệp công nghệ số",
    "attachments": [
      {
        "name": "401_2026_ndcp_04112026-signed.signed.pdf",
        "url": "https://datafiles.chinhphu.vn/cpp/files/vbpq/2026/11/401_2026_ndcp_04112026-signed.signed.pdf"
      }
    ],
    "source": "vanban.chinhphu.vn",
    "attribution": "Nguồn: vanban.chinhphu.vn"
  },
  {
    "docId": "220199",
    "url": "https://vanban.chinhphu.vn/?pageid=27160&docid=220199",
    "documentNumber": "81/2026/TT-BXD",
    "documentType": "Thông tư",
    "issuingBody": "Bộ Xây dựng",
    "issueDate": "2026-11-04",
    "effectiveDate": "2027-01-01",
    "summaryVi": "Quy định việc dán nhãn năng lượng đối với vật liệu xây dựng thuộc phạm vi quản lý của Bộ Xây dựng",
    "attachments": [
      {
        "name": "81-bxd.signed.pdf",
        "url": "https://datafiles.chinhphu.vn/cpp/files/vbpq/2026/11/81-bxd.signed.pdf"
      }
    ],
    "source": "vanban.chinhphu.vn",
    "attribution": "Nguồn: vanban.chinhphu.vn"
  }
]
```

***

### Data Source & Attribution

- **Primary Source**: Data is collected from [vanban.chinhphu.vn](https://vanban.chinhphu.vn/), the official legal document portal of the Vietnamese Government.
- **Attribution Requirement**: When reusing, displaying, or redistributing this data, retain the source URL and official attribution note: `Nguồn: vanban.chinhphu.vn`.

***

### Limitations

- **Metadata and direct links only**: This Actor extracts structured metadata and direct URLs to attached files. It does not perform full-text parsing or download attachment files to local storage.
- **No legal status evaluation**: The `effectiveDate` field represents the date indicated in the metadata. It does not indicate whether a document remains in force, or has subsequently been amended, superseded, or annulled.
- **Coverage boundaries**: Listing mode collects documents linked on the source listing page and does not guarantee a complete historical archive. Range mode evaluates only the specific ID window provided.
- **Source availability**: Output completeness depends on source portal availability and consistency. Network downtime or changes to the source page structure can impact extraction.

***

### Legal Note & Privacy

- **Public government information**: The Actor gathers public metadata and links for official government documents published for public awareness.
- **No personal data collected**: Signer names and individual contact details are deliberately excluded from dataset output records to maintain data privacy.
- **Informational use**: Data provided by this Actor is intended for research, informational, and indexing purposes and does not constitute formal legal advice.

***

### Frequently Asked Questions (FAQ)

#### Can I download full PDF or Word files with this Actor?

The Actor extracts direct download links to official signed attachments (hosted on `datafiles.chinhphu.vn`) inside the `attachments` array. It does not download or store binary files into the Apify dataset, keeping runs fast and cost-effective. You can process or download these links downstream using your preferred storage pipeline.

#### Can I use this data for AI, LLMs, and RAG pipelines?

Yes. The output format provides clean ISO dates, structured summaries (*trích yếu*), document types, issuing bodies, and source URLs, making it suitable for indexing into vector databases, semantic search engines, and RAG systems.

#### Does the Actor tell me if a document is still legally active?

No. While the Actor captures the official `effectiveDate` (ngày có hiệu lực), the source portal metadata does not reliably report current legal validity (e.g., whether a document has been superseded, amended, or expired). Verify status against official legal registers before making compliance decisions.

#### Why are signer names excluded from the output?

Signer names and personal contact details are deliberately omitted to prevent harvesting personal data and ensure the dataset focuses strictly on institutional legal metadata.

#### How does filtering affect pricing?

You only pay for documents saved to your dataset ($0.03 USD per document saved). If an inspected document ID is skipped because it does not match your `documentType` or `issuingBody` filter, you are not charged for that document.

#### How can I integrate this Actor via API?

You can start this Actor and read its results through the Apify REST API, the Python or JavaScript client, or scheduled runs, using your Apify API token. AI agents can call it through the Apify MCP server.

# Actor input Schema

## `maxDocuments` (type: `integer`):

Maximum matching documents to output.

## `docIdFrom` (type: `integer`):

Provide both range bounds. IDs are visited from highest to lowest, inclusive.

## `docIdTo` (type: `integer`):

Other inclusive range bound; required when docIdFrom is supplied.

## `documentType` (type: `string`):

Case-insensitive substring, for example Nghị định.

## `issuingBody` (type: `string`):

Case-insensitive issuing-body substring.

## Actor input object example

```json
{
  "maxDocuments": 50
}
```

# Actor output Schema

## `documents` (type: `string`):

Legal document metadata records.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("duytrinh98/vietnam-legal-documents").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("duytrinh98/vietnam-legal-documents").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 '{}' |
apify call duytrinh98/vietnam-legal-documents --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,duytrinh98/vietnam-legal-documents"
        }
    }
}
```

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/WEsFauQKifHEoMTmV/builds/MvitVMiP3lrCvOhw5/openapi.json
