# Malaysian Law Data — AGC Laws of Malaysia (`epiconetic/malaysia-law-data`) Actor

Malaysian federal legislation from the official AGC portal (lom.agc.gov.my): 19,600+ Principal, Amendment, Constitution and subsidiary legislation records with EN/BM titles, dates, status and official PDF links. Pay-per-event, no proxies, no browser.

- **URL**: https://apify.com/epiconetic/malaysia-law-data.md
- **Developed by:** [dedy iskandar](https://apify.com/epiconetic) (community)
- **Categories:** Business, Developer tools, Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 legislation records

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## Malaysian Law Data — AGC (Laws of Malaysia)

Scrape **Malaysian federal legislation** from the official Attorney General's Chambers portal — [`lom.agc.gov.my`](https://lom.agc.gov.my) — into clean, structured JSON.

Every record is normalised to the **same schema**, regardless of which of the ten source collections it came from: bilingual titles (English + Malay), act numbers, status, dates, and a direct link to the **official PDF** issued by AGC.

No proxies, no browser, no API key. The portal serves its data through an encrypted JSON endpoint; this Actor decrypts it directly.

***

### What you get

| What | Detail |
| --- | --- |
| **Coverage** | ~19,600 documents across 10 collections |
| **Bilingual titles** | `titleEN` and `titleBM` separated from the source's combined title cells |
| **Official PDFs** | `pdfEN` / `pdfBM` point at AGC's own download gateway — always downloadable, no extra request per record |
| **Dates** | Publication, royal assent and commencement, normalised to ISO-8601 |
| **Status** | Latest consolidated version, revised, translated, repealed, etc. |
| **Repeal relations** | Repealed acts carry a `repealedBy` object with the repealing act |
| **Parent act** | Subsidiary legislation carries a `parentAct` object linking to the parent Act in both languages |
| **Deterministic ids** | `id` = `<collection>:<source identity>`, stable across runs |
| **No duplication** | Records are de-duplicated in-flight, even when the source repeats rows |

***

### Collections

Pick one or more with the `collections` input. Defaults are the three most useful for most buyers.

| `collections` value | What it contains | ≈ Records |
| --- | --- | --- |
| `principal-original` | Principal Acts as originally enacted | 893 |
| `principal-updated` | Principal Acts, latest consolidated version | 889 |
| `principal-revised` | Principal Acts — Revision of Laws timeline | 405 |
| `principal-translated` | Authoritative translations of principal Acts | 127 |
| `principal-repealed` | Repealed principal Acts (with the repealing act) | 113 |
| `amendment` | Amendment Acts (Act A…) | 414 |
| `federal-constitution` | Federal Constitution amendments (English + Malay naskhah merged) | 60 |
| `ordinance` | Sabah / Sarawak ordinances | 2 |
| `subsid-pua` | Subsidiary legislation — P.U.(A) | 7,392 |
| `subsid-pub` | Subsidiary legislation — P.U.(B) | 9,280 |

> Counts are `recordsTotal` reported by the source at build time (2026-11). The portal grows; treat them as a guide.

***

### Input

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `collections` | array | `["principal-original","principal-updated","amendment"]` | Collections to scrape. |
| `keyword` | string | `""` | Server-side title filter. Empty = everything. |
| `maxItems` | integer | `100` | Max records written this run. Hard cap `25000`. |
| `includeRaw` | boolean | `false` | Attach the untouched source record under `raw`. |
| `resume` | boolean | `true` | Continue from where the previous identical run stopped. |

#### Example: one act family by number

```json
{
  "collections": ["principal-updated", "principal-repealed"],
  "maxItems": 50
}
```

#### Example: every subsidiary regulation mentioning a keyword

```json
{
  "collections": ["subsid-pua", "subsid-pub"],
  "keyword": "perbekalan",
  "maxItems": 1000
}
```

#### Example: a full corpus snapshot

```json
{
  "collections": [
    "principal-original",
    "principal-updated",
    "principal-revised",
    "principal-translated",
    "principal-repealed",
    "amendment",
    "federal-constitution",
    "ordinance",
    "subsid-pua",
    "subsid-pub"
  ],
  "maxItems": 25000,
  "resume": true
}
```

***

### Output

One dataset item per document. Empty strings and `null` mean *the source does not provide that value for this document* — they are never invented.

```json
{
  "id": "principal-original:13",
  "collection": "principal-original",
  "collectionLabel": "Principal Acts — as originally enacted",
  "docType": "principal",
  "actNo": "1",
  "titleEN": "INCOME TAX ACT 1967",
  "titleBM": "AKTA CUKAI PENDAPATAN 1967",
  "status": "UPDATED",
  "year": 1967,
  "publicationDate": "1967-09-21",
  "royalAssentDate": "1967-09-15",
  "commencementDate": "1968-01-01",
  "commencementRemark": "",
  "language": "",
  "sourceUrl": "https://lom.agc.gov.my/act-detail.php?act=1&lang=BI",
  "pdfEN": "https://lom.agc.gov.my/ilims/upload/portal/akta/outputaktap/.../Income Tax Act 1967.pdf",
  "pdfBM": "",
  "scrapedAt": "2026-11-15T09:14:03.118Z"
}
```

| Field | Type | Notes |
| --- | --- | --- |
| `id` | string | `<collection>:<identity>` — stable, unique per document |
| `collection` | string | Source collection id |
| `collectionLabel` | string | Human-readable collection name |
| `docType` | string | `principal` | `amendment` | `constitution` | `ordinance` | `subsidiary` |
| `actNo` | string | Act / P.U. number, e.g. `1`, `A1392`, `P.U. (A) 117/2003` |
| `titleEN` | string | English title, when the source has one |
| `titleBM` | string | Malay title, when the source has one |
| `status` | string | Status label from the source (`UPDATED`, `REVISED`, `repealed`, …) |
| `year` | integer | Derived from commencement, falling back to publication |
| `publicationDate` | string | ISO-8601 |
| `royalAssentDate` | string | ISO-8601 |
| `commencementDate` | string | ISO-8601 |
| `commencementRemark` | string | Free-text note from the source |
| `language` | string | Language of the authoritative text, when stated (`BI` English, `BM` Malay, `BI+BM` when both naskhahs are merged) |
| `sourceUrl` | string | AGC page for the document |
| `pdfEN` / `pdfBM` | string | Official PDF URLs (AGC download gateway) |
| `repealedBy` | object | `{actNo, titleEN, titleBM, url}` — repealed acts only |
| `parentAct` | object | `{urlEN, urlBM}` — parent Act pages — subsidiary legislation only |
| `scrapedAt` | string | ISO-8601 run timestamp |
| `raw` | object | Untouched source record, only when `includeRaw: true` |

Field names are treated as a stable public contract.

***

### Pricing

**Pay-per-event: $0.0025 per legislation record written to your dataset.** You pay for data, not for run time, memory or proxies.

- 100 records ≈ **$0.25**
- 1,000 records ≈ **$2.50**
- Full corpus (~19,600 records) ≈ **$49**

Charging rules:

- **Write first, charge second.** A record is only charged after it has been successfully pushed to the dataset. If storage fails, you are not charged for it.
- **No charge for empty results.** A keyword with no matches costs nothing.
- **Budget is respected mid-page.** If your run's maximum charge is reached, the Actor stops cleanly and keeps the records already delivered.
- **Re-runs only pay for new records.** With `resume: true`, a second run continues where the first stopped instead of re-billing the same documents.

Duplicated rows from the source are collapsed *before* charging, so you never pay twice for the same document in a single run.

**Plan discounts are automatic.** Five tier events are registered alongside the base event — Bronze $0.0023, Silver $0.0021, Gold $0.0019, Platinum $0.0017, Diamond $0.0015. The Actor reads the buyer's plan at run time and charges the matching price. Because some accounts cannot read the plan, the Actor falls back to the base price in that case; it never charges a discount the customer did not qualify for.

**The minimum spend floor is $0.10.** Your own per-run budget is what actually limits how much a run may buy — raise it in the Apify Console if you want the whole ~19,600-record corpus in one go (~$49).

***

### Running it from the API

> **Pass the input flat.** The Apify run API silently discards a payload whose input is wrapped in an `input` key and falls back to the schema defaults — your filter is lost and you are billed for the default corpus. Send the fields at the top level of the request body.

```bash
## WRONG - the nested "input" object is discarded, defaults are applied
curl -X POST "https://api.apify.com/v2/acts/vMHxFcrgTiJm0ahld/runs?token=$APIFY_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"input":{"collections":["subsid-pua"],"maxItems":50}}'

## RIGHT - flat body
curl -X POST "https://api.apify.com/v2/acts/vMHxFcrgTiJm0ahld/runs?token=$APIFY_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"collections":["subsid-pua"],"maxItems":50}'
```

The Apify Console, the Apify MCP server and the `apify` CLI all send flat input correctly, so this only matters for hand-written API calls.

Every run writes its **effective input** to the default key-value store under `OUTPUT`, alongside the per-collection statistics. If the input you sent is not what you see there, you were charged for something else — check it before a large run.

***

### How it works

1. Loads the collection page, reads the per-session AES key and the JSON endpoint from the HTML (both rotate, so both are read fresh every run).
2. Requests pages of 200 records with the collection's real field names — this is what keeps server-side pagination and ordering correct.
3. Decrypts each response (AES-256-GCM), normalises every record to the public schema.
4. Resolves PDF links locally by decoding the portal's base64 file tokens, avoiding one HTTP request per document.
5. Pushes the page to the dataset, then charges for exactly those records.
6. Saves the per-collection cursor so the next run resumes instead of restarting.

Requests are spaced out (~400 ms) to stay polite to a government portal.

***

### Limitations

- **Legislation only.** Court judgments live on a separate, JavaScript-only portal (`cms2.kehakiman.gov.my`) and are not part of this Actor.
- **No reprint collection.** The source's reprint endpoint returns a server error (`SQLSTATE[42S02]`); it is disabled rather than shipped broken.
- **Keyword search is server-side and language-bound.** The portal matches titles in each collection's primary language. Use Malay terms for `amendment`, `subsid-*` and `principal-revised` (e.g. `perbekalan`, not `supply`).
- **No AI summaries in v1.** Output is source-faithful data only, so nothing in the dataset is generated or inferred.
- **`principal-revised` reports timeline rows.** `recordsTotal` counts timeline rows, which is why records are de-duplicated by act.
- **Resume needs a named key-value store.** The cursor is kept in a per-user store (`state-<userId>`). If the platform refuses to create it for your account (some accounts restrict named storage creation from runs), the Actor logs a warning, falls back to the run's default store and continues — only resume *across* runs is then unavailable. `OUTPUT.stateStore.persistent` tells you which mode was used.
- **Empty fields are honest.** If AGC does not publish a commencement date or English title for a document, the field is empty rather than guessed.
- **Some documents have no PDF.** A number of Federal Constitution amendments are published only as P.U. gazette references with no downloadable file. Those records keep a working `sourceUrl` and empty `pdfEN` / `pdfBM`.
- **PDF URLs use AGC's download gateway.** `pdfEN` / `pdfBM` point at `processFile.php?token=…` rather than the raw file path, because the raw `/ilims/upload/…` path intermittently returns HTTP 500 while the gateway reliably returns the PDF. Treat these as download links, not as stable permanent URLs.
- **The portal refuses non-Malaysian IP ranges.** `lom.agc.gov.my` serves Malaysian clients normally while resetting connections from foreign IP ranges. From an Apify container, from a home connection outside Malaysia, and through a third-party rendering proxy, the TLS connection is reset and the Actor reports `fetch failed`.

  How to tell an outage from a block — the portal was confirmed **up** (serving gazettes published that day) while every subpage request was reset:

  | Probe | Result |
  |---|---|
  | Public DNS for `lom.agc.gov.my` | resolves normally |
  | TCP connect to the resolved IP, port 443 | connection times out |
  | Third-party renderer fetching the homepage | succeeds (cached edge) |
  | Third-party renderer fetching any subpage | `ERR_CONNECTION_RESET` |

  A run on a blocked network now fails with an explicit message saying so, instead of silently reporting success with zero rows. Running it from a Malaysian network, or through a proxy with a Malaysian exit, is the only way to verify live collection.

***

### Use cases

- Legal-tech and compliance teams building a Malaysian statute database.
- Law firms and in-house counsel tracking amendments and repeals.
- Fintech, insurance and healthcare companies mapping sector regulation.
- Researchers, journalists and NGOs analysing legislative output over time.
- AI/RAG pipelines that need citable, current Malaysian legal sources with official PDFs.

***

### Data source

Public data published by the **Attorney General's Chambers of Malaysia** — [Laws of Malaysia portal](https://lom.agc.gov.my). This Actor reads only what the portal serves publicly, at a polite rate, and always links back to the official page and PDF.

The source is authoritative; this Actor is an access layer. Always verify against the official document before relying on it legally.

***

### Project structure

```
src/                      # Actor source (sources, lib, schemas)
tests/                    # vitest suites + HTML/JSON fixtures
scripts/                  # one-off helpers (capture-fixtures.mjs)
.actor/                   # actor.json + dataset schema
PRICING.md                # pay-per-event pricing model
REPORT.md                 # build & verification checklist
```

***

### Support

Open an issue from the Actor's page in Apify Console with the run id and the input you used. Questions about coverage or a missing collection are welcome.

# Actor input Schema

## `collections` (type: `array`):

Which AGC collections to scrape. Each collection has its own schema on the source portal, but all records are normalised to the same output shape.

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

Optional keyword matched against the document title on the source portal (server-side filter). The search uses the collection's primary title language, so use Malay terms for bilingual collections (e.g. "perbekalan" rather than "supply" for amendment acts). Leave empty to fetch everything.

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

Maximum number of records written in this run (hard cap, capped at 25000). Run the Actor again with the same settings to continue from where it stopped.

## `includeRaw` (type: `boolean`):

Attach the original, unmodified record from the AGC portal under the `raw` field. Useful for fields not mapped to the standard output. Increases dataset size.

## `resume` (type: `boolean`):

Continue from the position stored by the previous run with the same settings instead of starting from the beginning. Disable to always start from the first record.

## Actor input object example

```json
{
  "collections": [
    "principal-original",
    "principal-updated",
    "amendment"
  ],
  "keyword": "",
  "maxItems": 100,
  "includeRaw": false,
  "resume": true
}
```

# Actor output Schema

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

All legislation records produced by this run: id, collection, act number, titles, status, dates and official PDF links.

## `summary` (type: `string`):

Per-collection statistics, charging details and resume state for this run.

# 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 = {
    "collections": [
        "principal-original",
        "principal-updated",
        "amendment"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("epiconetic/malaysia-law-data").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 = { "collections": [
        "principal-original",
        "principal-updated",
        "amendment",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("epiconetic/malaysia-law-data").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 '{
  "collections": [
    "principal-original",
    "principal-updated",
    "amendment"
  ]
}' |
apify call epiconetic/malaysia-law-data --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,epiconetic/malaysia-law-data"
        }
    }
}
```

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/vMHxFcrgTiJm0ahld/builds/3i3cTXlcL2UFRn2tT/openapi.json
