# NBP Gold Price History by Publication Date (`thatmike1/commodity-pl-nbp-gold-window`) Actor

Export official NBP gold price observations for the latest publications or a bounded date window. Keep publication dates, exact source decimals and explicit no-data coverage.

- **URL**: https://apify.com/thatmike1/commodity-pl-nbp-gold-window.md
- **Developed by:** [Michal Pšenčík](https://apify.com/thatmike1) (community)
- **Categories:** Business, Automation
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.00005 / actor start

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

## NBP Gold Price History by Publication Date

Export the official gold price published by Narodowy Bank Polski (NBP) through its public API at
`api.nbp.pl`, either for the latest publications or for a bounded window of publication dates. Each row is
one publication date with the exact decimal the API returned, so a daily schedule or a one-month backfill
lands in a dataset you can download as JSON, CSV or Excel, or read through the Apify API.

NBP documents the price as the price of 1 gram of gold at 1000 fineness. Data start on 2 January 2013.

### Input

| Field         | Meaning                                                                                                                                        |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `mode`        | `latest` (default) or `range`.                                                                                                                 |
| `latestCount` | Latest mode only. How many recent publications to request, 1 to 20 (5 when empty). These are publications, not days; the API may return fewer. |
| `startDate`   | Range mode only. First date, `YYYY-MM-DD`, from 2013-01-02.                                                                                    |
| `endDate`     | Range mode only. Last date, at most today in Warsaw, and at most 93 calendar dates after `startDate` counting both ends.                       |
| `maxItems`    | The most rows the run stores and bills, 1 to 93 (default 93).                                                                                  |

The default input returns the five latest publications:

```json
{ "mode": "latest", "latestCount": 5, "maxItems": 93 }
```

A one-week backfill:

```json
{ "mode": "range", "startDate": "2026-10-01", "endDate": "2026-10-09", "maxItems": 93 }
```

Unknown fields, a date field in latest mode, `latestCount` in range mode, impossible dates and ranges
longer than 93 calendar dates are refused before any request.

### Output

One row per publication date:

```json
{
    "schemaVersion": 1,
    "id": "nbp-gold:2026-10-22",
    "publicationDate": "2026-10-22",
    "sourcePrice": "515.01",
    "currency": null,
    "goldMassGrams": 1,
    "goldFinenessMillesimal": 1000,
    "observedAt": "2026-10-22T22:04:01.997936+00:00",
    "sourceUrl": "https://api.nbp.pl/api/cenyzlota/last/5/?format=json",
    "sourceResponseSha256": "1667162d25e5fe0ff35d2cf5a744c888910a438c836a05872cb3b814d9a164c0"
}
```

- `sourcePrice` is the API's `cena` value as an exact plain decimal string (no rounding, no binary
  floating point, trailing fractional zeros dropped, so `514.00` becomes `514`).
- `currency` is always `null`. The NBP API documentation describes the gram and fineness of the reference
  but does not name the currency next to the price, so this actor does not assert one. If you need a
  currency-guaranteed accounting feed, do not infer that guarantee from this dataset.
- `publicationDate` is the API's `data` field. It is not a release timestamp.
- `observedAt` is when this run received the response; `sourceResponseSha256` is the SHA-256 of the raw
  response body, so you can prove what the API said.

Dates without a publication (weekends, holidays or any other gap) simply have no row: nothing is carried
forward or filled in, and a gap is not labelled as a holiday or a deletion. Within a run, rows are added in
ascending date order. Sort by `publicationDate` when you combine runs.

### Run summary (free)

Every run writes a free `SUMMARY` record to its key-value store with the status (`complete`, `partial`,
`empty` or `error`), the requested window, every publication date the API returned, how many rows were
stored, why the run stopped and what to do next. A window with no publications, such as a single Sunday, is
a free `empty` result. An API error, a blocked request or a malformed response is an `error`, never an
empty success. `RECOVERY`, `REQUEST_LEDGER` and `DELIVERY-LEDGER-*` and `DELIVERY-UNSENT-*` records are internal and let a restarted
run continue without storing or billing a row twice.

### Pricing

Pay per event:

- **Actor start:** $0.00005 per run.
- **Gold price observation:** $0.0005 per row actually stored in the dataset.

Five latest publications cost $0.00255; a 31-day window with 23 publications costs $0.01155. Rerunning the
same window stores and bills the same unchanged rows again. Empty windows, errors and the summary are not
billed as rows. The start fee applies to every run, including empty or failed ones. If your run's spending
limit cannot pay for another row, the run stops before storing it and says so in the summary.

### Limits

- One request per run (at most three including retries), paced politely, with no proxy, login or key.
  If the API refuses the request (403, 429 or a challenge page), the run stops and reports it.
- `latestCount` counts publications. A latest run may return fewer rows than requested.
- No history of revisions: a value that changes between runs is a new snapshot, not proof of a revision.
- The NBP API's own documentation mentions a 93-day enquiry limit; this actor keeps windows to 93 calendar
  dates.

### Support

Source: [NBP Web API](https://api.nbp.pl/en.html). Report issues through the Issues tab on this actor's
page.

# Actor input Schema

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

`latest` exports the most recent NBP gold publications; `range` exports every publication in a date window.

## `latestCount` (type: `integer`):

Latest mode only: how many recent publications to request, 1 to 20 (5 when left empty). These are publications, not calendar days; the source may return fewer. Leave empty in range mode.

## `startDate` (type: `string`):

Range mode only: first publication date, YYYY-MM-DD, from 2013-01-02. Leave empty in latest mode.

## `endDate` (type: `string`):

Range mode only: last publication date, YYYY-MM-DD, at most today in Warsaw and at most 93 calendar dates after the start date (inclusive). Leave empty in latest mode.

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

The most rows this run stores and bills, 1 to 93.

## Actor input object example

```json
{
  "mode": "latest",
  "maxItems": 93
}
```

# Actor output Schema

## `rows` (type: `string`):

No description

## `summary` (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("thatmike1/commodity-pl-nbp-gold-window").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("thatmike1/commodity-pl-nbp-gold-window").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 thatmike1/commodity-pl-nbp-gold-window --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,thatmike1/commodity-pl-nbp-gold-window"
        }
    }
}
```

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/6Ka3DTIZXk5Iy8bRo/builds/TZggQxDNV2BaiGvNi/openapi.json
