A Node.js application that automatically fetches cryptocurrency prices from CoinGecko and updates them in one or more Notion databases. The app can run in two modes: as a server with automatic updates or as a one-time update script.
- Fetches real-time cryptocurrency prices from CoinGecko's free API
- Updates prices and market cap in your Notion database(s)
- Support for multiple Notion databases
- Two running modes:
- Server mode with automatic updates every 5 minutes
- One-time update mode
- Rate limiting to respect CoinGecko's free API limits
- Simple shell script for easy execution
- Node.js (v14 or higher)
- A Notion account
- A Notion integration (API key)
- One or more Notion databases with the required properties
- Clone the repository:
git clone https://github.com/rudimocnik/gecko-notion-sync.git
cd gecko-notion-sync- Install dependencies:
npm install- Make the run script executable:
chmod +x run.sh- Create a
.envfile in the root directory with the following variables:
For a single database:
NOTION_API_KEY=your_notion_integration_key
NOTION_DATABASE_ID=your_notion_database_id
NOTION_PRICE_PROPERTY="Current Price ($)"
NOTION_MARKET_CAP_PROPERTY="Market Cap ($)"
NOTION_SYMBOL_PROPERTY="API ID"
PORT=3000For multiple databases:
NOTION_API_KEY=your_notion_integration_key
NOTION_DATABASES='[
{
"id": "database_id_1",
"priceProperty": "Current Price ($)",
"marketCapProperty": "Market Cap ($)",
"symbolProperty": "API ID"
},
{
"id": "database_id_2",
"priceProperty": "Price",
"marketCapProperty": "Market Cap",
"symbolProperty": "Coin ID"
}
]'
PORT=3000-
Create one or more databases in Notion
-
For each database, add the following properties:
- A text property for the CoinGecko API ID (e.g., "API ID" or "Coin ID")
- A number property for the current price
- A number property for the market cap
-
Share your databases with your Notion integration:
- Go to each database
- Click "Share" in the top right
- Add your integration
The application can be run in two modes using the provided shell script:
- Server Mode (with automatic updates every 5 minutes):
./run.sh server- One-time Update Mode:
./run.sh updateTo run the server in the background (useful for long-term operation):
nohup ./run.sh server > coingecko-notion.log 2>&1 &To check if the server is running:
ps aux | grep "node src/server.js"To stop the server:
pkill -f "node src/server.js"When running in server mode, the following endpoint is available:
GET /- Trigger a manual update of all cryptocurrency prices
Use the exact IDs from CoinGecko's API. You can find the complete list at:
https://api.coingecko.com/api/v3/coins/list
Example IDs:
- "bitcoin" for Bitcoin
- "ethereum" for Ethereum
- "solana" for Solana
- "virtual-protocol" for Virtuals Protocol
The application includes rate limiting to respect CoinGecko's free API limits:
- 10-50 calls per minute
- 1-second delay between requests
- Automatic retry with 60-second delay if rate limit is hit
The application includes comprehensive error handling and logging for:
- API rate limits
- Invalid property names
- Missing database entries
- Network errors
Feel free to submit issues and enhancement requests!