# Polystash API quick start

Choose the product that contains the operation you need. Each product requires its own active RapidAPI subscription, including for the free tier. Use the application's X-RapidAPI-Key and the matching X-RapidAPI-Host header. Subscription, quota and billing are handled by RapidAPI.

## Add business days

Subscribe through [Business Days and Public Holidays](https://rapidapi.com/polystash-polystash-default/api/business-days-and-public-holidays1).
Gateway: https://business-days-and-public-holidays1.p.rapidapi.com

Set RAPIDAPI_KEY through your shell's secret facility, then run:

```sh
curl --fail-with-body --get 'https://business-days-and-public-holidays1.p.rapidapi.com/v1/businessdays/add' \
  --header "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  --header 'X-RapidAPI-Host: business-days-and-public-holidays1.p.rapidapi.com' \
  --data-urlencode 'country=US' \
  --data-urlencode 'date=2027-03-05' \
  --data-urlencode 'days=3'
```

This example returns a result date of 2027-03-10. To select a region, add the region parameter using the code returned by /countries.

## Calculate a settlement date

Subscribe through [Settlement Calendar and Payment Value Dates](https://rapidapi.com/polystash-polystash-default/api/settlement-calendar-and-payment-value-dates).
Gateway: https://settlement-calendar-and-payment-value-dates.p.rapidapi.com

Set RAPIDAPI_KEY to an application key subscribed to this product, then run:

```sh
curl --fail-with-body 'https://settlement-calendar-and-payment-value-dates.p.rapidapi.com/v1/settlement' \
  --header "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  --header 'X-RapidAPI-Host: settlement-calendar-and-payment-value-dates.p.rapidapi.com' \
  --header 'Content-Type: application/json' \
  --data '{"tradeDate":"2027-05-28","mic":"XNYS","cycle":"T+1"}'
```

This example returns a settlement date of 2027-06-01 after the weekend and the exchange holiday. Calendar arithmetic uses the supplied cycle; it is not a determination of the settlement rule for a particular security.

### JavaScript (Deno)

Save this as settlement.js. It reads RAPIDAPI_KEY from the environment and sends a JSON-encoded body.

```js
const key = Deno.env.get("RAPIDAPI_KEY");
if (!key) throw new Error("Set RAPIDAPI_KEY before running this example");
const response = await fetch("https://settlement-calendar-and-payment-value-dates.p.rapidapi.com/v1/settlement", {
  method: "POST",
  headers: {
    "X-RapidAPI-Key": key,
    "X-RapidAPI-Host": "settlement-calendar-and-payment-value-dates.p.rapidapi.com",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({tradeDate: "2027-05-28", mic: "XNYS", cycle: "T+1"}),
  signal: AbortSignal.timeout(15000),
});
if (!response.ok) throw new Error("HTTP " + response.status);
console.log(await response.json());
```

```sh
deno run --allow-env=RAPIDAPI_KEY --allow-net=settlement-calendar-and-payment-value-dates.p.rapidapi.com settlement.js
```

### Python (standard library)

Save as settlement.py and run python3 settlement.py with RAPIDAPI_KEY set.

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://settlement-calendar-and-payment-value-dates.p.rapidapi.com/v1/settlement",
    method="POST",
    headers={
        "X-RapidAPI-Key": os.environ["RAPIDAPI_KEY"],
        "X-RapidAPI-Host": "settlement-calendar-and-payment-value-dates.p.rapidapi.com",
        "Content-Type": "application/json",
    },
    data=json.dumps({"tradeDate": "2027-05-28", "mic": "XNYS", "cycle": "T+1"}).encode("utf-8"),
)
with urllib.request.urlopen(request, timeout=15) as response:
    print(json.loads(response.read()))
```

Both examples send the same request as cURL above. Serialize JavaScript request bodies with JSON.stringify; passing a plain object to Fetch does not send JSON.

## Request errors and coverage

- 403 from the provider origin means the request did not arrive through the authorized gateway. Use the RapidAPI host above; customers do not need a provider proxy secret.
- For gateway authorization errors, check the application's key and subscription to that exact product. A Business Days subscription does not grant Settlement access.
- For quota errors, check the current RapidAPI plan and usage. Do not retry indefinitely.
- Read coverage flags and response errors. Regional coverage and future calendars have limitations; the full reference explains them.

## Reference and downloads

- [OpenAPI schema](https://api.polystash.com/openapi.json): Use its path and parameter definitions with the appropriate gateway host. Listing endpoint availability is authoritative.
- [Full API reference](https://api.polystash.com/docs)
- [Plans](https://api.polystash.com/pricing)
- [Buy the dataset — $9 one-off](https://polystash.gumroad.com/l/public-holidays-business-days-2000-2060): Holiday data as files, without API requests.
- [Free CSV sample](https://www.kaggle.com/datasets/polystash/public-holidays-by-country-and-region-2026-2028)
