Skip to content
marganiPublic

About

Auto-updated pricedb for Iranian Rial (IRR) exchange rates in Iran's free market

Topics

Resources

Code of conduct

Stars

26 stars

Watchers

1 watching

Forks

Repository files navigation

PriceDB

ci deploy USD

Free-market prices in Iran for the US dollar, euro, pound, gold and coins, taken from tgju.org every 30 minutes during market hours and served as a free API: no key, no sign-up, CORS enabled.

Usage

For example, the latest price of USD in IRR:

curl https://api.priceto.day/v1/latest/irr/usd

Or in PowerShell:

$(Invoke-WebRequest 'https://api.priceto.day/v1/latest/irr/usd').Content

The list of symbols is at https://api.priceto.day/v1/symbols.

Status

  • /v1/health: when prices were last updated. Returns 503 when the updates have stalled.
  • /v1/version: the deployed version and git commit.
  • /v1/stats: API requests and distinct users per day. IPs are kept only as a daily-salted hash and deleted the next day.

Prices don't change on Fridays or after Thursday afternoon, when Iran's market is closed.

Telegram bot

@Price2DayBot on Telegram sends a daily report after the evening update and lets anyone set price alerts:

  • /price usd — latest price
  • /alert usd > 280000 — message me when the dollar goes above 280,000 Toman (< for below)
  • /alerts, /unalert 3 — list and remove alerts

MCP server

Ask Claude (or any MCP client) about prices directly. The server at https://api.priceto.day/mcp (Streamable HTTP, no authentication) offers the tools list_symbols, get_latest_price, get_price_history, get_price_change and convert.

  • Claude Code: claude mcp add --transport http pricedb https://api.priceto.day/mcp
  • Claude (web/desktop): Settings → Connectors → Add custom connector → https://api.priceto.day/mcp

Dataset

The full price history of all 29 tracked symbols (daily since 2023-12, plus every 30-minute update) is published as CSV on the 1st of each month: see the dataset-* releases. The current data can also be downloaded any time from https://api.priceto.day/v1/dataset/daily.csv and .../hourly.csv.

Sources

Prices come from tgju.org. The dollar is cross-checked against USDT on the Bitpin exchange every 30 minutes (an alert fires when they differ by more than 5%), and either can be requested: /v1/latest/irr/usd?source=bitpin or ?source=average.

CSV and RSS

  • History as CSV: https://api.priceto.day/v1/history/irr/usd?from=2025-01-01&format=csv
  • Daily prices as an RSS feed: https://api.priceto.day/v1/feed.xml

Badges

Embed live prices in a README or web page. Optional query parameters: label, rounding (divide by 10^n), precision, unit and color (a name such as green or a hex code).

USD Gold Miskal

![USD](https://api.priceto.day/v1/badge/irr/usd?rounding=1&unit=Toman&color=green)

Charts

Long-term and real-value charts

Any symbol can be priced in another one (e.g. a coin in USD, or USD in gold), and charts can cover any range. Add format=svg for a vector image.

Emami coin in USD since 2024

Hosting

The API and the website run on Cloudflare Workers, with prices stored in D1. A Cron Trigger fetches new prices every 30 minutes during market hours.

GitHub Actions deploys the Worker. A push to sandbox deploys the sandbox at pricedb-sandbox.whosane.workers.dev, and a merge into main deploys production.

Self-hosting

You can run your own copy with a Cloudflare account; the Workers Free plan is enough for a small instance.

git clone https://github.com/margani/pricedb && cd pricedb
npm install
npx wrangler login

# Deploy the Worker. The D1 database is created on the first deploy.
cd worker && npx wrangler deploy && cd ..

# Create the tables and load the full price history from the latest public dataset
(cd worker && npx wrangler d1 migrations apply DB --remote)
node scripts/import-dataset.mjs

Your API is then available at https://pricedb-api.<your-subdomain>.workers.dev/v1/... and keeps itself up to date. Optional alerts: set the TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID secrets (npx wrangler secret put ...) to get a Telegram message when updates fail.

For local development, npx wrangler d1 migrations apply DB --local, node scripts/import-dataset.mjs --local and npx wrangler dev (in worker/). Run the tests with npm test.

About

Auto-updated pricedb for Iranian Rial (IRR) exchange rates in Iran's free market

Topics

Resources

Code of conduct

Stars

26 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages