# CanadaBuys — Canada Federal Contracts (Proactive Disclosure) (`accommodating_aptitude/canadabuys`) Actor

Pulls contract records from the Proactive Disclosure - Contracts over $10,000 dataset through the Canadian federal government's official open-data CKAN API (open.canada.ca).

- **URL**: https://apify.com/accommodating_aptitude/canadabuys.md
- **Developed by:** [Korhan Coşan Ergün](https://apify.com/accommodating_aptitude) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$7.50 / 1,000 contract founds

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

## CanadaBuys — Canada Federal Contracts (Proactive Disclosure)

The original task description asked for federal tender notices from
`canadabuys.canada.ca`. **After research, no request is ever made to
`canadabuys.canada.ca`** — see the "Why not canadabuys.canada.ca?" section
below. Instead, the **Proactive Publication – Contracts over $10,000**
dataset is used, via the Canadian government's official open-data CKAN API
(`open.canada.ca`).

### Why not canadabuys.canada.ca?

Verified on 9–10 November 2026:

1. The END of `https://canadabuys.canada.ca/robots.txt` contains this
   block:
   ```
   User-agent: *
   Disallow: /
   ```
   Even though detailed, permissive rules are defined for Googlebot/Bingbot,
   the site is closed end to end for ALL other unnamed bots (including this
   actor) — including the `/opendata/pub/*.csv` open-data files.
2. The "CanadaBuys tender notices" dataset in the `open.canada.ca` CKAN
   catalogue (`package_show?id=6abd20d4-...`) was checked: all of its CSV
   resources (`New tender notices`, `Open tender notices`, `All tender
   notices`, etc.) are hosted only on `canadabuys.canada.ca` and have
   `datastore_active: false` — meaning this data is not reachable through
   CKAN's own queryable API either.
3. The task rule is explicit: when you hit a bot wall, do not force it —
   switch to a publicly available alternative.

### The alternative used

**Proactive Publication – Contracts over $10,000**
(dataset: `d8f85d91-7dec-4fd1-8055-483b77225d8b`, resource:
`fac950c0-00d5-4ec1-a4d3-9cbebf98a305`), queried through the CKAN
`datastore_search` API on `open.canada.ca`:

```
https://open.canada.ca/data/api/3/action/datastore_search?resource_id=fac950c0-00d5-4ec1-a4d3-9cbebf98a305
```

- Official, open, **key-free** federal contract data, published as a legal
  obligation under sections 77/86 of the Access to Information Act.
- The `open.canada.ca` robots.txt only disallows specific paths for the
  generic `User-agent: *` (`/admin/`, `/search/`, `/user/...`, etc.) and
  asks for `Crawl-delay: 20`; `/data/api/` is NOT disallowed — this is
  verified with `RobotsChecker` on every run and the crawl delay is
  respected.
- It fits the niche's purpose (tracking government tenders/contracts): the
  leading actor referenced in the same niche list,
  `parseforge/us-gov-contract-watch-scraper`, also does "contract tracking"
  rather than returning a raw list of open tenders.
- The data is under the Open Government Licence - Canada.

### Input

| Field | Description |
|---|---|
| `vendorQuery` | CKAN full-text search (vendor name / word from the description) |
| `ownerOrgQuery` | Exact-match filter on the buying organization name (`owner_org_title`) |
| `minContractValue` | Minimum contract value in CAD (client-side filter) |
| `maxItems` | Maximum number of records |

### Output (each record)

```json
{
  "id": "C-2025-2026-Q3-908",
  "title": "Safety & sanitation equipment & parts",
  "link": "https://search.open.canada.ca/en/ct/?sort=contract_date+desc&search_text=Real%20Time%20Networks%20Inc",
  "date": "2026-12-01",
  "source_url": "https://open.canada.ca/data/api/3/action/datastore_search",
  "scraped_at": "2026-11-10T00:41:35Z",
  "source": "open_canada_proactive_contracts",
  "buyer": "Canada Border Services Agency | Agence des services frontaliers du Canada",
  "vendor": "Real Time Networks Inc",
  "value": {"amount": 120518.57, "currency": "CAD"},
  "contract_period_start": "2026-01-12",
  "delivery_date": "2027-03-31",
  "category": "G",
  "commodity_code": "7125",
  "reporting_period": "2025-2026-Q3"
}
```

Because the `link` field has no single per-record page (the CKAN datastore
does not provide one), it is built as a URL into the official
`search.open.canada.ca/en/ct/` contract search interface, pre-filtered by
vendor name — so the user can reach the relevant record in one click.

`sample_output.json` contains **15 records** taken from a real local run
(sorted by the most recent `contract_date`, with no filters applied).

### Pricing (PPE)

A `contract-found` event is fired for every contract record found
(`Actor.charge("contract-found")`). Based on the niche data
(`research/data/niches_v2.csv`, "CanadaBuys" row, `med_p1k`=7.5 USD per
1000 records), the **suggested price is ≈ $0.0075 per contract-found
event**.

**Important:** `Actor.charge()` calls do nothing until Pay-Per-Event
pricing is ENABLED for this actor in the Apify Console — in a live test run
on the real platform (`apify call`, 10 November 2026) the log showed this
warning: `Ignored attempt to charge for an event - the Actor does not use
the pay-per-event pricing`. In other words the code side is ready, but to
actually activate the price you need to pick the "Pay per event" model in
Apify Console → Actor → Monetization, enter a $0.0075 price for the
`contract-found` event and complete the Store listing (this step cannot be
done from the CLI).

### Local run

```bash
cd ~/rua/products/apify/canadabuys
mkdir -p storage/key_value_stores/default
cat > storage/key_value_stores/default/INPUT.json <<'EOF'
{"maxItems": 15}
EOF
APIFY_LOCAL=1 python3 main.py
## output: storage/datasets/default/*.json
```

### Known limitations

- This data is not **open/active tenders** but **awarded contracts** — it
  does not match the niche name exactly, but it serves the same
  intelligence need (which agency pays whom, for what, and how much).
- Contracts are published quarterly; the most recent records can appear
  4–5 months after the contract date (per the official statement).
- The `category` field is the raw `commodity_type` code (G=Goods,
  S=Services, C=Construction, etc.); a human-readable description is not
  present in the CKAN record.

# Actor input Schema

## `vendorQuery` (type: `string`):

CKAN datastore full-text search (e.g. vendor name, a word from the description). Can be left empty.

## `ownerOrgQuery` (type: `string`):

Exact-match filter on the buying organization name (owner_org_title), e.g. 'Canada Border Services Agency | Agence des services frontalières du Canada'. Can be left empty.

## `minContractValue` (type: `integer`):

Contracts below this value are filtered out (client-side).

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

Maximum number of contract records to pull.

## Actor input object example

```json
{
  "vendorQuery": "",
  "ownerOrgQuery": "",
  "minContractValue": 0,
  "maxItems": 20
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing all records found in 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 = {};

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

```

## MCP server setup

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

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/pouMiLyVBnznqg3hy/builds/06s6OlCmTM5Sf3dwK/openapi.json
