A Cloudflare Workers Scheduled Worker that automatically fetches exchange rates from Open Exchange Rates API and updates a Notion database.
| Property | Type | |----------|------| | Code | Title | | Rate | Number | | Updated At | Date |
# Clone the repository
git clone git@ssh.git.ac:kotoyuuko/notion-exrate-worker.git
cd notion-exrate-worker
# Install dependencies
npm install
Copy the example environment file:
cp .dev.vars.example .dev.vars
Fill in your credentials in .dev.vars:
OXR_APP_ID=your_open_exchange_rates_app_id
NOTION_TOKEN=your_notion_integration_token
NOTION_DATABASE_ID=your_notion_database_id
# Start development server
npm run dev
# Test scheduled handler
curl "http://localhost:8787/__scheduled?cron=0+*+*+*+*"
# Or use manual sync endpoint
curl "http://localhost:8787/sync"
# Deploy to Cloudflare Workers
npm run deploy
# Set production secrets
wrangler secret put OXR_APP_ID
wrangler secret put NOTION_TOKEN
wrangler secret put NOTION_DATABASE_ID
The worker runs automatically every hour via Cron trigger.
Send a GET request to the /sync endpoint:
curl https://your-worker.workers.dev/sync
Response:
{
"success": true,
"currenciesFound": 173,
"ratesFetched": 172,
"succeeded": 172,
"failed": 0,
"errors": []
}
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Info page |
/sync |
GET | Manually trigger exchange rate sync |
MIT