# Japan e-Gov Law Search (Law API v2) (`jpopendata/japan-laws-egov`) Actor

Unofficial client for the official e-Gov Law API v2 (Digital Agency Japan, no key). List Japanese laws by type, keyword-search law text, or download a law's full text as structured 編/章/条/項 articles. 政府標準利用規約 2.0.

- **URL**: https://apify.com/jpopendata/japan-laws-egov.md
- **Developed by:** [JP Open Data](https://apify.com/jpopendata) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 record scrapeds

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Japan e-Gov Law Search (Law API v2)

**List Japanese laws by type, run a full-text keyword search across the statute book, or download any law's full text as clean, structured 編/章/条/項 articles — in JSON, with no API key.**

This Actor is a thin, polite client for the **official e-Gov 法令API バージョン2** (`laws.e-gov.go.jp/api/2`) operated by the **デジタル庁 (Digital Agency)** behind [e-Gov 法令検索](https://laws.e-gov.go.jp/). It is **not a scraper** — it calls the documented government JSON API, needs **no registration and no API key**, and returns each result as a flat record with a legal envelope (`source` / `sourceUrl` / `license` / `retrievedAt`) on every item.

The index of laws is a directory; the value here is `get_law`: point it at a law and it downloads the official full text and flattens it into one record per article — the *statute*, structured, not just a link.

> **Unofficial tool.** Independently built and maintained. **Not affiliated with, endorsed by, or connected to the Digital Agency or the Government of Japan.** Law data is provided under the **政府標準利用規約（第2.0版）** (Government Standard Terms of Use 2.0), which permits commercial reuse with attribution; the required 出典 statement **「出典：e-Gov法令検索（デジタル庁）」** is embedded in the `license` of every record. The **text of a law is not subject to copyright** (著作権法第13条). **Provided for reference only — this is not legal advice; confirm the accuracy and currency of any law against the official e-Gov Law Search.**

***

### Quick start — verified input

Copy, paste, run. This exact input is verified on the platform (SUCCEEDED, items > 0):

```json
{
  "mode": "search",
  "keyword": "個人情報保護"
}
```

Running with **no input at all** also works (same defaults). To download a law's full text, take a `lawId` from the search output and run `{"mode": "get_law", "lawId": "415AC0000000057"}`; to list all statutes of a type run `{"mode": "list", "lawType": "Act"}`.

### No API key required

The e-Gov Law API v2 is public and unauthenticated. Pick a mode and run. The Actor keeps a single connection, spaces requests ≥ 1.2 s apart, backs off exponentially on HTTP 429/5xx, and **fails visibly on a persistent block — it never attempts rate-limit evasion.**

### License, source-display obligation & the law-text point

- e-Gov law data is offered under the **政府標準利用規約（第2.0版）**: 出典表示を条件に、複製・公衆送信・翻訳・改変・**商用利用**が認められています (attribution required, commercial reuse permitted).
- The credit **「出典：e-Gov法令検索（デジタル庁）」** is embedded verbatim in the `license` field of every record. If you display or republish the data, keep that credit visible.
- The **text of statutes themselves** (憲法・法律・政令・省令 等) **is excluded from copyright** by Article 13 of the Copyright Act (著作権法第13条 — 憲法その他の法令), so full-text reproduction and redistribution are free.
- **This tool is for reference.** Law data can lag or be mid-amendment. The **authoritative source is the official e-Gov Law Search**; verify anything you rely on there. Nothing here is legal advice.

### Three modes

#### 1. `list` — law index by type (e-Gov `/laws`)

Give a `lawType` (`Constitution` / `Act` / `CabinetOrder` / `ImperialOrder` / `MinisterialOrdinance` / `Rule` / `Misc`) and get back matching laws: `lawId`, `lawNum` (法令番号), `lawName`, kana reading, promulgation & enforcement dates, category, current/repealed status, and an e-Gov deep link. `lawType` is required (a targeted index, not a full-corpus dump).

#### 2. `search` — full-text keyword search (e-Gov `/keyword`)

Give a `keyword` (optionally narrowed by `lawType`) and get back matching laws, each with the **matched snippets** (`matches[]` — the position and the plain text where your term appears). The `<span>` highlight markup from the API is stripped.

#### 3. `get_law` — download a law's full text (e-Gov `/law_data`)

Give a `lawId` (e.g. `415AC0000000057`, 個人情報保護法) — or a `lawNum` like `平成十五年法律第五十七号` — and the Actor downloads the official full text and returns **one record per article/provision**, preserving the hierarchy: `partTitle` (編), `chapterTitle` (章), `sectionTitle` (節), `articleCaption` (条見出し), `articleTitle` (条番号), and `paragraphs[]` (項) in document order. 附則 (supplementary provisions) are flagged with `supplementary: true`. `maxItems` bounds how many articles a single run emits.

### Sample output

**search** (one hit):

```json
{
  "lawId": "322AC0000000073",
  "lawNum": "昭和二十二年法律第七十三号",
  "lawName": "会計検査院法",
  "lawNameKana": "かいけいけんさいんほう",
  "lawType": "Act",
  "promulgationDate": "1947-04-19",
  "enforcementDate": "2025-06-01",
  "category": "行政組織",
  "status": "現行",
  "lawUrl": "https://laws.e-gov.go.jp/law/322AC0000000073",
  "matches": [
    { "position": "toc", "text": "第五節　会計検査院情報公開・個人情報保護審査会" }
  ],
  "source": "e-Gov法令検索（デジタル庁）/ e-Gov Law Search (Digital Agency, Japan)",
  "sourceUrl": "https://laws.e-gov.go.jp/",
  "license": "出典：e-Gov法令検索（デジタル庁）… 政府標準利用規約（第2.0版）… 著作権法第13条 … Unofficial … not legal advice.",
  "retrievedAt": "2026-08-26T12:00:00.000Z"
}
```

**get\_law** (one article):

```json
{
  "lawId": "411AC0000000127",
  "lawNum": "平成十一年法律第百二十七号",
  "lawName": "国旗及び国歌に関する法律",
  "supplementary": false,
  "partTitle": null,
  "chapterTitle": null,
  "sectionTitle": null,
  "articleCaption": "（国旗）",
  "articleTitle": "第一条",
  "articleIndex": 1,
  "paragraphs": [
    { "num": null, "text": "国旗は、日章旗とする。" },
    { "num": "２", "text": "日章旗の制式は、別記第一のとおりとする。" }
  ],
  "source": "e-Gov法令検索（デジタル庁）/ e-Gov Law Search (Digital Agency, Japan)",
  "sourceUrl": "https://laws.e-gov.go.jp/",
  "license": "出典：e-Gov法令検索（デジタル庁）… 政府標準利用規約 … 著作権法第13条 … not legal advice.",
  "retrievedAt": "2026-08-26T12:00:00.000Z"
}
```

### Input reference

| Field | Mode | Description |
| --- | --- | --- |
| `mode` | all | `search` (default), `list`, or `get_law`. Case-insensitive; a bare `lawId` switches to `get_law`, a bare `lawType` to `list`. |
| `keyword` | search | Free-text query (e-Gov `keyword`), Japanese, e.g. `個人情報保護`. **Required in search mode.** |
| `lawType` | list / search | `Constitution` / `Act` / `CabinetOrder` / `ImperialOrder` / `MinisterialOrdinance` / `Rule` / `Misc` (Japanese `法律`, `政令` … also accepted). **Required in list mode.** |
| `lawId` | get\_law | e-Gov law id, e.g. `415AC0000000057`. A law\_revision\_id also works. |
| `lawNum` | get\_law | 法令番号 in kanji numerals, e.g. `平成十五年法律第五十七号` (used when lawId is absent). |
| `maxItems` | all | Max records, 1–100000 — laws (list/search) or articles (get\_law). Default 1000. |
| `maxApiRequests` | all | Hard per-run upstream request cap, 1–25 (default 10). |
| `proxyConfiguration` | all | Optional Apify proxy; default is a direct connection. |

Values are validated **before** the first request; an invalid value fails the run immediately with a message that lists the valid values.

#### Common input mistakes

| Mistake | Correct |
|---------|---------|
| `{"mode": "list"}` with no `lawType` | add `"lawType": "Act"` (法律) — or use `"mode": "search"` with a `keyword` |
| `"lawType": "PrimeMinisterOrder"` / `"Cabinet Order"` | one of the seven values, e.g. `"CabinetOrder"` (spaces/case are tolerated; other names are not) |
| `{"mode": "search", "lawId": "415AC0000000057"}` | `"mode": "get_law"` — lawId is a get\_law field |
| `"lawId": "個人情報保護法"` (a law name) | search for it first: `{"mode": "search", "keyword": "個人情報保護"}` → use the `lawId` from the output |
| `"lawNum": "Act No. 57 of 2003"` | the Japanese form: `"平成十五年法律第五十七号"` — or use `lawId` |
| `"maxItems": "all"` | a number, e.g. `1000` |

#### Empty results?

A run that finds nothing completes with 0 items and a warning in the log (not a failure). Typical causes: an English or romaji `keyword` (the full-text index is Japanese — try `労働時間` instead of `working hours`), a `lawType` filter that excludes every match (e.g. `Constitution` with an unrelated keyword), or a `get_law` target that is an image-only / attachment-only law (no article text). Broaden the keyword or drop the `lawType` filter and retry.

### Notes & limits

- **`category` is not a filter.** The e-Gov v2 `/laws` endpoint ignores a `category` parameter (it returns the full corpus regardless), so this Actor does not expose it as a filter — to avoid a silently-ignored option. The law's category is still reported in the `category` output field.
- **`search` paginates by matched sentence**, so a law with several hits may appear more than once across a large `maxItems`; dedupe on `lawId` if you only want distinct laws.
- **`get_law` emits provisions in document order.** Table-like content (号/欄) is concatenated into the paragraph text. Attached files (別表 images, PDFs) are not downloaded.
- A very large law can exceed `maxItems`; raise it (and `maxApiRequests` isn't consumed per article — one law is one request) to capture the whole text. Truncation is logged.

### Disclaimer

1. **Unofficial** — not affiliated with, endorsed by, or connected to the Digital Agency or the Government of Japan.
2. **Public data, your responsibility** — data is provided under the 政府標準利用規約（第2.0版）. Keep the 出典 credit visible when you republish. The text of laws is excluded from copyright (著作権法第13条).
3. **Not legal advice / verify against the source** — provided for reference only. Law data may lag or be mid-amendment; **the accuracy and currency of any law must be confirmed against the official e-Gov Law Search.**
4. **Polite by design** — one connection, ≥ 1.2 s spacing, exponential backoff, a hard request budget, and a visible failure on a persistent block. No rate-limit evasion.

### Search terms

japan law api, japanese laws english, e-gov laws data, japan legal database, japanese statutes api, japan law full text, e-gov法令検索 api, japanese law search, japan act text json, japanese legislation data, 法令 api, japan government law data

# Actor input Schema

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

`search` (default) runs a full-text keyword search (e-Gov keyword) and returns matching laws with the matched snippets — set keyword. `list` returns a 法令一覧 (law index) filtered by law type — set lawType. `get_law` downloads one law's full text and returns its 編/章/節/条/項 articles as structured JSON — set lawId or lawNum. Case-insensitive; if you pass only a lawId the Actor switches to get\_law for you. Example: "search".

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

search mode (REQUIRED there): free-text query over law bodies (e-Gov `keyword`), Japanese, e.g. "個人情報保護", "労働時間", "電子署名". Ignored in list / get\_law modes.

## `lawType` (type: `string`):

list mode (REQUIRED there) / search mode (optional filter): the law type. Constitution=憲法, Act=法律 (most statutes), CabinetOrder=政令, ImperialOrder=勅令, MinisterialOrdinance=府省令, Rule=規則, Misc=その他. Japanese names ("法律") are accepted too. Example: "Act".

## `lawId` (type: `string`):

get\_law mode (REQUIRED there unless lawNum is given): the e-Gov law id, e.g. "415AC0000000057" (個人情報保護法) — take it from a search/list run (the `lawId` field). A law\_revision\_id also works.

## `lawNum` (type: `string`):

get\_law mode (alternative to lawId): the 法令番号 in the official Japanese form, e.g. "平成十五年法律第五十七号" (kanji numerals, exactly as e-Gov prints it).

## `maxItems` (type: `integer`):

Maximum records to output, 1-100000 — laws (list/search) or articles (get\_law). PPE charges per record. Example: 1000.

## `maxApiRequests` (type: `integer`):

Hard safety cap on upstream requests per run, 1-25 (list/search page 1000 per request; get\_law is one request). Politeness (1 connection, >= 1.2 s spacing, exponential backoff on 429/5xx) is enforced in code. Example: 10.

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

Apify proxy settings. Default is NO proxy (direct connection) — a public government API rarely needs one. The Actor backs off exponentially on 429/5xx and fails visibly on a persistent block; it never attempts rate-limit evasion.

## Actor input object example

```json
{
  "mode": "search",
  "keyword": "個人情報保護",
  "lawId": "415AC0000000057",
  "lawNum": "平成十五年法律第五十七号",
  "maxItems": 1000,
  "maxApiRequests": 10,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `records` (type: `string`):

Law metadata (list/search) or flattened article records (get\_law), with source attribution (source, sourceUrl, license, retrievedAt) on every item.

# 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",
    "keyword": "個人情報保護",
    "maxItems": 1000,
    "maxApiRequests": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("jpopendata/japan-laws-egov").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",
    "keyword": "個人情報保護",
    "maxItems": 1000,
    "maxApiRequests": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("jpopendata/japan-laws-egov").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",
  "keyword": "個人情報保護",
  "maxItems": 1000,
  "maxApiRequests": 10
}' |
apify call jpopendata/japan-laws-egov --silent --output-dataset

```

## MCP server setup

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

```

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/9NHluGbbdpAIBVX8m/builds/e4IFsMBjkUcYEbHAd/openapi.json
