# Japan Laws & Regulations (e-Gov Law API) (`vespa-zzz/egov-laws`) Actor

Search Japanese laws and regulations by title or keyword, extract articles or whole laws, and retrieve amendment histories from the official e-Gov Law API v2.

- **URL**: https://apify.com/vespa-zzz/egov-laws.md
- **Developed by:** [Vespa ZZZ](https://apify.com/vespa-zzz) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.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.

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

## Japan Laws & Regulations (e-Gov Law API)

Search Japanese laws and regulations, extract their text as structured JSON, and retrieve amendment histories from Japan's official e-Gov Law API v2. The API is public and requires no key.

### Modes and output

| Mode | Dataset records | Main inputs |
| --- | --- | --- |
| `search` (default) | One row per law with law and revision metadata | Partial `lawTitle`, `lawType`, `categoryCd`, `promulgationDateFrom` / `To`, `asof`, `repealStatus` |
| `keyword` | One row per law with a `sentences` array of matching positions and plain-text snippets | `keyword`, `lawType`, `categoryCd`, `promulgationDateFrom` / `To`, `asof` |
| `fullText` | One row per article by default, or one row per law with `outputFormat: "whole"` | `laws`, `includeSupplementaryProvisions`, `outputFormat`, `includeRawXml` |
| `revisions` | One row per revision with amending law title and number, promulgation and enforcement dates, and status | `laws`, `amendmentDateFrom` / `To` (effective dates) |

Use dates in `YYYY-MM-DD` format. `asof` selects the latest applicable revision at the given date for search and keyword results. Keyword results include snippets from the pages fetched before the row limit is reached. The e-Gov API's limits can also leave a law's `sentences` array incomplete. Each snippet retains its API `position` for citation or retrieval.

In `fullText` and `revisions`, `laws` accepts e-Gov law IDs, official law numbers, and exact Japanese titles. Use a law ID or law number when several laws share a title or the title search has more than 10 pages of results.

Article rows contain `lawId`, `lawTitle`, `lawNum`, `revisionId`, `lawUrl`, `path` (ordered heading titles), `articleNum`, `articleCaption`, `articleTitle`, and `text`. Paragraph and item labels present in XML are included alongside their text. Set `includeSupplementaryProvisions` to include numbered supplementary articles, which have `supplementary: true`.

Whole-law rows include plain text from the main provisions and annexes. Set `includeSupplementaryProvisions` to include supplementary provisions, including paragraphs outside an article. Set `includeRawXml` to include the original XML as `rawXml`. This XML can include supplementary provisions regardless of the plain-text setting. Images and other attachments are available through the e-Gov source link.

`maxResults` caps dataset rows across the run (default 100, maximum 10,000). In `fullText` and `revisions`, increase `maxResults` for large laws with many articles or revisions. If the limit leaves records out, the Actor logs a warning and sets `truncated` to `true` in `RUN_SUMMARY` in the default key-value store. When the dataset reaches the limit, the Actor may check subsequent input laws to determine whether any records remain. Requests are sequential and spaced by `requestIntervalMs` (default 1,000 ms, minimum 500 ms). Temporary failures are retried up to three times with backoff.

### Input examples

Search for laws with 個人情報 in the title.

```json
{ "mode": "search", "lawTitle": "個人情報", "maxResults": 5 }
```

Find passages mentioning the Digital Agency.

```json
{ "mode": "keyword", "keyword": "デジタル庁", "lawType": ["Act"], "maxResults": 10 }
```

Extract Companies Act articles with a higher `maxResults` because the law has hundreds of articles.

```json
{ "mode": "fullText", "laws": ["平成十七年法律第八十六号"], "maxResults": 2000 }
```

List amendments enforced since April 2022 for the Act on the Protection of Personal Information. For a longer amendment history, increase `maxResults` above the default of 100.

```json
{
  "mode": "revisions",
  "laws": ["平成十五年法律第五十七号"],
  "amendmentDateFrom": "2022-04-01",
  "maxResults": 500
}
```

### Use cases

- **Legal tech** — Index laws by ID and link search results to the official text.
- **Compliance monitoring** — Compare revision IDs and track amendment enforcement dates for a list of laws.
- **Retrieval-augmented generation (RAG)** — Index article text with its revision ID, article number, headings, and source URL.
- **AI agents** — Look up laws by topic and retrieve provisions relevant to a question.

### Data source and terms

The Actor uses the official data from e-Gov Law Search. The terms of use explain how to attribute and reuse the data. [e-Gov Law Search](https://laws.e-gov.go.jp/), [Law API v2](https://laws.e-gov.go.jp/api/2/redoc/), [Terms of use](https://laws.e-gov.go.jp/terms)

This Actor is unaffiliated with e-Gov or Japan's Digital Agency. Its output is for information and does not constitute legal advice.

### Local development

From this Actor's directory, run `npm install`, `npm test`, and `apify validate-schema`. Tests use mocked requests and two fixtures captured from e-Gov Law API v2.

***

### 日本語の概要

e-Gov 法令 API v2 から、法令名検索、本文のキーワード検索、条文または全文の取得、改正履歴の取得ができます。条文ごとの出力では法令 ID、版 ID、見出し、条番号、本文、出典 URL を確認できます。附則を含めるには `includeSupplementaryProvisions` を有効にしてください。法的判断には e-Gov の原文をご確認ください。

# Actor input Schema

## `mode` (type: `string`):

Search law titles, search within law text, retrieve full text, or list amendment history.

## `lawTitle` (type: `string`):

Partial Japanese law title or abbreviation. Used in Law search.

## `keyword` (type: `string`):

Japanese search term or e-Gov search expression. Required for Full-text keyword search.

## `lawType` (type: `array`):

Keep laws of any selected type. Applies to Law search and Full-text keyword search.

## `categoryCd` (type: `array`):

Keep laws in any selected e-Gov category. Applies to Law search and Full-text keyword search.

## `promulgationDateFrom` (type: `string`):

Earliest promulgation date to include (YYYY-MM-DD). Applies to Law search and Full-text keyword search.

## `promulgationDateTo` (type: `string`):

Latest promulgation date to include (YYYY-MM-DD). Applies to Law search and Full-text keyword search.

## `asof` (type: `string`):

Select the latest applicable revision as of this date (YYYY-MM-DD). Applies to Law search and Full-text keyword search.

## `repealStatus` (type: `array`):

Keep laws with any selected repeal status. Applies to Law search.

## `laws` (type: `array`):

Law IDs, official law numbers, or exact Japanese titles. Required for Law text and Amendment history. Example ID is the Act on National Flag and Anthem.

## `includeSupplementaryProvisions` (type: `boolean`):

Include supplementary article records or supplementary provision text in Law text mode.

## `outputFormat` (type: `string`):

Choose one row per numbered article or one row with the whole plain-text law. Applies to Law text.

## `includeRawXml` (type: `boolean`):

Include the original XML returned by e-Gov in Law text mode when the output format is Whole. It can contain supplementary provisions and references to attachments.

## `amendmentDateFrom` (type: `string`):

Earliest amendment enforcement date to include (YYYY-MM-DD). Applies to Amendment history.

## `amendmentDateTo` (type: `string`):

Latest amendment enforcement date to include (YYYY-MM-DD). Applies to Amendment history.

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

Maximum total dataset rows per run, across all input laws (default: 100). In Law text and Amendment history, increase maxResults for large laws with many articles or revisions.

## `requestIntervalMs` (type: `integer`):

Minimum pause before the next e-Gov request. Requests run sequentially. Retries can wait longer.

## Actor input object example

```json
{
  "mode": "search",
  "lawTitle": "個人情報",
  "laws": [
    "411AC0000000127"
  ],
  "includeSupplementaryProvisions": false,
  "outputFormat": "articles",
  "includeRawXml": false,
  "maxResults": 100,
  "requestIntervalMs": 2000
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

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

No description

## `runSummary` (type: `string`):

No description

# 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 = {
    "mode": "search",
    "lawTitle": "個人情報",
    "laws": [
        "411AC0000000127"
    ],
    "requestIntervalMs": 2000
};

// Run the Actor and wait for it to finish
const run = await client.actor("vespa-zzz/egov-laws").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 = {
    "mode": "search",
    "lawTitle": "個人情報",
    "laws": ["411AC0000000127"],
    "requestIntervalMs": 2000,
}

# Run the Actor and wait for it to finish
run = client.actor("vespa-zzz/egov-laws").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 '{
  "mode": "search",
  "lawTitle": "個人情報",
  "laws": [
    "411AC0000000127"
  ],
  "requestIntervalMs": 2000
}' |
apify call vespa-zzz/egov-laws --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,vespa-zzz/egov-laws"
        }
    }
}
```

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/jYFyjZ1dNvLWAEsLO/builds/qFubNfiTgj0RpQmsf/openapi.json
