# Scotland PCS Site Notices (OCDS) (`elekezem/scotland-pcs-site-notices`) Actor

Unofficial reader of Public Contracts Scotland Site Notices (noticeType 101-104) from the official OCDS API.

- **URL**: https://apify.com/elekezem/scotland-pcs-site-notices.md
- **Developed by:** [OSEKA Data](https://apify.com/elekezem) (community)
- **Categories:** Lead generation, Open source
- **Security:** 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 ocds releases

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

## Scotland PCS Site Notices (OCDS)

Unofficial Apify Actor. It reads **Public Contracts Scotland Site Notices** from the official OCDS API and writes **one dataset item per OCDS release**.

This Actor covers **PCS site notices only** (`noticeType` 101 / 102 / 103 / 104). Above-threshold England / UK-wide notices go through Find a Tender (FTS) or the complementary Actor [`elekezem/uk-tenders-ocds`](https://github.com/elekezem/uk-tenders-ocds). It does **not** read Contracts Finder, Sell2Wales, PCS HTML/RSS, or PCS notice types 1-25.

Contains public sector information licensed under the Open Government Licence v3.0.

This project is **not affiliated with, endorsed by, or connected to** Public Contracts Scotland, the Scottish Government, or Proactis. Do not use PCS or Scottish Government logos with this Actor.

### 中文摘要

只拉苏格兰 Public Contracts Scotland 的 **Site Notices**（101 PIN、102 合同通知、103 授标、104 Quick Quote 授标）。输出与 `elekezem/uk-tenders-ocds` 对齐的扁平 OCDS 字段，并去掉联系人姓名 / 邮箱 / 电话。英格兰及英国门槛以上通知请走 FTS / 那个互补 Actor。非正式产品，不含官方徽标，不声称官方背书。

Contains public sector information licensed under the Open Government Licence v3.0.

### What it does

- Calls `GET https://api.publiccontractsscotland.gov.uk/v1/Notices?dateFrom=mm-yyyy&noticeType={101-104}&outputType=0`.
- Optionally calls `GET …/v1/Notice?id={ocid}` when `fetchFamily` is true.
- Maps each release to fields aligned with the UK tenders Actor (`ocid`, `title`, `buyerName`, value, dates, `documents`, `source="pcs"`, `noticeType`) plus a PII-stripped `raw` release.
- Charges the PPE event `ocds-release` once per saved item. Unpriced local runs log the Apify SDK warning and still save data.
- Sends requests serially with at least 2 seconds between calls. Retries HTTP 429 / 503 with backoff.

No PCS account. No API key. No HTML scraping. No login.

### Input

Defaults are a cheap sample run for Apify daily tests and free users.

| Field | Default | Notes |
| --- | --- | --- |
| `mode` | `sample` | `sample`, `dateRange`, or `incremental` |
| `dateFrom` / `dateTo` | unset | ISO dates. Expanded to covering `mm-yyyy` months. |
| `noticeTypes` | `[101, 102, 103, 104]` | Subset allowed. Types 1-25 are rejected. |
| `maxResults` | `10` | Caps dataset items and charges. |
| `keywords` | unset | Title / description / buyer, any keyword, case-insensitive. |
| `cpvCodes` | unset | CPV prefixes. |
| `fetchFamily` | `false` | Extra `/v1/Notice` calls. Off by default. |
| `watermarkStoreName` | `scotland-pcs-site-notices-watermarks` | Incremental mode only. |
| `minRequestIntervalSeconds` | `2` | Floor 2. |

Example:

```json
{
  "mode": "sample",
  "noticeTypes": [102, 103],
  "maxResults": 10
}
```

### Output

One item per OCDS release. Overview columns: `source`, `noticeType`, `title`, `buyerName`, `tag`, `valueAmount`, `date`, `noticeUrl`.

Each item includes `license`: Contains public sector information licensed under the Open Government Licence v3.0.

`raw` deletes `parties[].contactPoint` name / email / telephone / faxNumber, drops street-level address fields, and replaces emails and phone numbers in free text with `[contact removed]`.

### Run locally

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
pytest -m "not live"
RUN_LIVE=1 pytest -m live -s
```

The PCS TLS chain often omits the Sectigo DV R36 intermediate. This Actor loads that public intermediate from `scotland_pcs_site_notices/certs/`. Do not disable certificate verification.

Apify CLI (optional): `apify run` with `storage/key_value_stores/default/INPUT.json`.

### Legal

- Data licence: [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).
- Attribution: Contains public sector information licensed under the Open Government Licence v3.0.
- Personal data is outside OGL. Contact fields are stripped before save.
- RSS terms on the PCS website do not apply. This Actor uses the OCDS API only.

### Store status

Draft copy lives in `STORE.md`. Do not publish this Actor to Apify Store from this repository until pricing and listing review are done.

# Actor input Schema

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

sample = current calendar month preview (falls back to the previous month if empty). dateRange = every mm-yyyy month covering dateFrom/dateTo. incremental = only releases after the stored watermark.

## `dateFrom` (type: `string`):

ISO date (YYYY-MM-DD). Mapped to covering mm-yyyy months because the PCS API is month-grained. Required for dateRange.

## `dateTo` (type: `string`):

ISO date (YYYY-MM-DD). Defaults to today for dateRange and incremental.

## `noticeTypes` (type: `array`):

Site Notices only: 101 PIN, 102 Contract Notice, 103 Award, 104 Quick Quote Award. Types 1-25 are rejected.

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

Maximum dataset items (and PPE ocds-release charges) per run.

## `keywords` (type: `array`):

Keep a notice if title, description, or buyer name contains ANY keyword (case-insensitive).

## `cpvCodes` (type: `array`):

Keep a notice if any CPV code starts with one of these prefixes (e.g. 45, 72000000).

## `fetchFamily` (type: `boolean`):

If true, call GET /v1/Notice?id={ocid} for each kept ocid and emit extra family releases. Extra API requests; default off.

## `watermarkStoreName` (type: `string`):

Named key-value store used only in incremental mode.

## `minRequestIntervalSeconds` (type: `number`):

Serial delay between official API calls. Floor is 2 seconds; lower values are raised to 2.

## Actor input object example

```json
{
  "mode": "sample",
  "noticeTypes": [
    "101",
    "102",
    "103",
    "104"
  ],
  "maxResults": 10,
  "fetchFamily": false,
  "watermarkStoreName": "scotland-pcs-site-notices-watermarks",
  "minRequestIntervalSeconds": 2
}
```

# Actor output Schema

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

No description

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

// Run the Actor and wait for it to finish
const run = await client.actor("elekezem/scotland-pcs-site-notices").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("elekezem/scotland-pcs-site-notices").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 elekezem/scotland-pcs-site-notices --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,elekezem/scotland-pcs-site-notices"
        }
    }
}
```

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/1adlYB1LHbbPuZues/builds/she4jrNBQw7xzmRkC/openapi.json
