A sleek Node.js bot that tweets Pi Network (PI) price updates three times daily from CoinMarketCap to X as Pi Network Price Chart @PiNetworkChart, keeping the Pi community in the loop with style and precision.
- Thrice-Daily Updates: Tweets the Pi price and 24-hour volume at 00:00, 08:00, and 16:00 UTC (01:00, 09:00, 17:00 WAT), plus on startup.
- Real-Time Data: Pulls exact prices (e.g., $2.75, not rounded) from CoinMarketCap.
- Rate Limit Savvy: Stays within X’s free tier (17 tweets/day) with built-in tracking.
- Clean Format: Delivers tweets like:
- Node.js: The runtime environment for the bot.
- X API: Used for posting tweets via the
twitter-api-v2
library. - CoinMarketCap API: Used for fetching price and volume data.
- Winston: For logging.
- Jest: For testing.
- Docker: For containerization.
- GitHub Actions: For CI/CD pipeline.
- Node.js: Install Node.js from nodejs.org.
- Docker: Install Docker from docker.com.
- X Developer Account (developer.twitter.com)
- CoinMarketCap API Key (coinmarketcap.com/api)
- Clone the Repo:
git clone https://github.com/vincentiroleh/pi-network-bot.git
cd pi-network-bot
- Install Dependencies:
npm install
- Set Up Environment Variables:
- Create a .env file in the root:
TWITTER_API_KEY=your_x_api_key
TWITTER_API_SECRET=your_x_api_secret
TWITTER_ACCESS_TOKEN=your_x_access_token
TWITTER_ACCESS_TOKEN_SECRET=your_x_access_token_secret
CMC_API_KEY=your_cmc_api_key
PRICE_PRECISION=2 # Optional: decimals for price (default: 2)
- Get X keys from your app (set to “Read and Write”).
- Get CMC key from your developer dashboard.
- Usage:
-
Run the bot:
npm start
-
Run tests:
npm test
-
Build the Docker image:
docker build -t pi-price-bot .
-
Run the Docker container:
docker run -d -p 8080:8080 --name pi-price-bot pi-price-bot
The project uses GitHub Actions for CI/CD. The pipeline is defined in .github/workflows/docker-ci.yml.
- Local: Tweets on start + 3x daily (edit
tweetPrice
toconsole.log
for mock runs). - Rate Limits: 17 tweets/day (X free tier), 333 CMC calls/day—3x/day fits perfectly.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.
© 2025 Vincent Iroleh