# Singapore Law Data — Singapore Statutes Online (`epiconetic/singapore-law-data`) Actor

Singapore statutes and subsidiary legislation from the official AGC Singapore Statutes Online portal: 6,300+ in-force records with title, Act number, status, year and official PDF links. Pay-per-event.

- **URL**: https://apify.com/epiconetic/singapore-law-data.md
- **Developed by:** [dedy iskandar](https://apify.com/epiconetic) (community)
- **Categories:** Business, Developer tools
- **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

## Singapore Law Data — Singapore Statutes Online (SSO)

Scrape **Singapore legislation** from the official Attorney-General's Chambers portal — [Singapore Statutes Online](https://sso.agc.gov.sg) — into clean, structured JSON.

Every record is normalised to the **same schema**, whether it came from the Acts collection or the Subsidiary Legislation collection: title, official document code, status, year, reference date, and a direct link to the **official PDF** published by AGC.

No API key. No proxies. The portal is protected by an AWS WAF JavaScript challenge, which this Actor solves once with a real browser and then reuses for every subsequent request.

***

### What you get

| What | Detail |
| --- | --- |
| **Coverage** | ~6,380 documents: 524 Acts + ~5,860 Subsidiary Legislation items, all currently in force |
| **Stable schema** | One row shape for both collections — no per-source field guessing |
| **Official codes** | `code` carries the SSO document reference, e.g. `AA2004`, `AA2004-R5`, `SCJA1969-N2` |
| **Official PDFs** | `pdfUrl` points at the AGC-hosted PDF for that document |
| **Dates** | `referenceDate` normalised to ISO-8601 |
| **Status** | `in_force` for everything in the v1 scope |
| **Deterministic ids** | `id` = `<collection>:<code>`, 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. Both are included by default.

| `collections` value | What it contains | ≈ Records |
| --- | --- | --- |
| `acts` | Acts currently in force | 524 |
| `sl` | Subsidiary Legislation currently in force | 5.860 |

> Counts are reported by the source at build time (2026-11), minus browse-table
> navigation rows that carry no document link. The portal grows; treat them as a guide.

***

### Input

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `collections` | array | `["acts","sl"]` | Collections to scrape. |
| `maxItems` | integer | `100` | Max records written this run. Hard cap `25000`. |
| `includeRaw` | boolean | `false` | Attach the untouched source row under `raw`. |
| `resume` | boolean | `true` | Continue from where the previous identical run stopped. |

#### Example: just the Acts

```json
{
  "collections": ["acts"],
  "maxItems": 526
}
```

#### Example: a full corpus snapshot

```json
{
  "collections": ["acts", "sl"],
  "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": "act:AA2004",
  "collection": "act",
  "collectionLabel": "Acts",
  "docType": "Act",
  "code": "AA2004",
  "title": "Accountants Act 2004",
  "status": "in_force",
  "year": 2004,
  "referenceDate": "2004-01-01",
  "language": "en",
  "country": "SG",
  "sourceUrl": "https://sso.agc.gov.sg/Act/AA2004",
  "pdfUrl": "https://sso.agc.gov.sg/Act/AA2004?ViewType=Pdf",
  "collectedAt": "2026-11-15T09:14:03.118Z"
}
```

| Field | Type | Notes |
| --- | --- | --- |
| `id` | string | `<collection>:<code>` — stable, unique per document |
| `collection` | string | `act` or `sl` |
| `collectionLabel` | string | Human-readable collection name |
| `docType` | string | `Act` or `Subsidiary Legislation` |
| `code` | string | Official SSO document reference, e.g. `AA2004` |
| `title` | string | Official short title |
| `status` | string | `in_force` in v1 |
| `year` | integer | Derived from the reference date, falling back to the document code |
| `referenceDate` | string | ISO-8601 date of the source document reference, when provided |
| `language` | string | Always `en` — SSO is English-only |
| `country` | string | Always `SG` |
| `sourceUrl` | string | Official SSO page for the document |
| `pdfUrl` | string | Official SSO PDF link |
| `collectedAt` | string | ISO-8601 run timestamp |
| `raw` | object | Untouched source row, 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 (~6,380 records) ≈ **$16**

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 collection with no records 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.0020, Gold $0.0018, Platinum $0.0016, Diamond $0.0014. 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 ~6,380-record corpus in one go (~$16).

***

### 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/BU3SQVyId7cdqu1hR/runs?token=$APIFY_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"input":{"collections":["sl"],"maxItems":50}}'

## RIGHT - flat body
curl -X POST "https://api.apify.com/v2/acts/BU3SQVyId7cdqu1hR/runs?token=$APIFY_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"collections":["sl"],"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. Launches headless Chromium with a stealth fingerprint (no `navigator.webdriver`, realistic plugin and locale profile).
2. Solves the AWS WAF JavaScript challenge once and captures the issued token and cookies.
3. Reuses that browser context's HTTP client (`context.request`) for every subsequent request — navigating with `page.goto` per request burns the portal's rate-limit budget and triggers HTTP 467.
4. Walks the SSO browse endpoints with 0-based page indexes in the path (`/Browse/Act/Current/All/0`) and a `PageSize` of 500.
5. Parses each browse table, normalises every row to the public schema, and resolves the document code, title and PDF link.
6. Pushes the page to the dataset, then charges for exactly those records.
7. 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. HTTP 467 (rate limited) is retried with exponential backoff; HTTP 403 triggers a fresh browser context with a matching user agent.

***

### Limitations

- **In-force documents only.** v1 covers Acts and Subsidiary Legislation currently in force. Revised editions (`-R5`), supplements, repealed or revoked documents, court judgments and the Singapore Gazette are **not** included — they are planned for v2.
- **Metadata and PDF links only.** v1 does not download or chunk document text. The `pdfUrl` is the official PDF; fetch and parse it yourself if you need full text.
- **English only.** SSO publishes English only, so there is no bilingual value to extract. `language` is always `en`.
- **PDF links require the same WAF token.** `pdfUrl` resolves normally from a normal browser session; automated fetches with no WAF token may receive HTTP 202 (challenge) instead of the PDF.
- **Rate limiting is real.** Aggressive concurrent runs from the same IP can receive HTTP 467. The Actor backs off and retries, but a single run remains the safest way to consume this source.
- **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.resumeState` tells you which mode was used.
- **Empty fields are honest.** If SSO does not publish a reference date for a document, the field is empty rather than guessed.

***

### Use cases

- Legal-tech and compliance teams building a Singapore statute database.
- Law firms and in-house counsel tracking subsidiary legislation and its parent Acts.
- Fintech, insurance and healthcare companies mapping sector regulation.
- Researchers, journalists and NGOs analysing legislative output over time.
- AI/RAG pipelines that need citable, current Singapore legal sources with official PDF links.

***

### Data source

Public data published by the **Attorney-General's Chambers of Singapore** — [Singapore Statutes Online](https://sso.agc.gov.sg). 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.

***

### 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 SSO document collections to scrape. Each collection is normalised to the same output shape.

## `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 row from the SSO browse table 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": [
    "acts",
    "sl"
  ],
  "maxItems": 100,
  "includeRaw": false,
  "resume": true
}
```

# Actor output Schema

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

All legislation records produced by this run: id, collection, document code, title, status, year, reference date 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": [
        "acts",
        "sl"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("epiconetic/singapore-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": [
        "acts",
        "sl",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("epiconetic/singapore-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": [
    "acts",
    "sl"
  ]
}' |
apify call epiconetic/singapore-law-data --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,epiconetic/singapore-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/BU3SQVyId7cdqu1hR/builds/oKmsynn9CLMypgcvp/openapi.json
