Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/totigm/twitter-crypto-bot
This is a Twitter bot that tweets about cryptocurrencies prices every certain amount of minutes
https://github.com/totigm/twitter-crypto-bot
binance binance-api bot bots candlestick candlestick-chart candlesticks crypto cryptocurrencies cryptocurrency javascript js node nodejs trading ts twitter twitter-api twitter-bot typescript
Last synced: 4 months ago
JSON representation
This is a Twitter bot that tweets about cryptocurrencies prices every certain amount of minutes
- Host: GitHub
- URL: https://github.com/totigm/twitter-crypto-bot
- Owner: totigm
- License: mit
- Created: 2021-04-21T23:04:50.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-06T06:15:51.000Z (about 2 years ago)
- Last Synced: 2023-03-06T10:25:16.315Z (almost 2 years ago)
- Topics: binance, binance-api, bot, bots, candlestick, candlestick-chart, candlesticks, crypto, cryptocurrencies, cryptocurrency, javascript, js, node, nodejs, trading, ts, twitter, twitter-api, twitter-bot, typescript
- Language: TypeScript
- Homepage:
- Size: 868 KB
- Stars: 29
- Watchers: 4
- Forks: 18
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Twitter Crypto Bot
This bot tweets about the price variations of any cryptocurrency every certain time interval.
> Every coin listed in [Binance](https://www.binance.com) are supported.
>
> Prices' data is retrieved from the [Binance API](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md).Tweets generated by the bot look like this:
You can achieve this with just one line of code! Simply choose a coin, a time interval between tweets, and that's it!
![Crypto bot initialization](https://user-images.githubusercontent.com/64804554/143302340-21f115f2-b628-45f5-8df9-2cf4c9e0e582.png)
## 📋 Prerequisites
- [**Node.js**](https://nodejs.org): You need to have Node.js installed on your computer to run this bot. You can download it [here](https://nodejs.org/en/download).
- [**Twitter account**](https://twitter.com): This is just a normal Twitter account. You can create one [here](https://twitter.com/i/flow/signup).
- [**Twitter developer account**](https://developer.twitter.com): Log in with your Twitter account and apply for a developer one [here](https://developer.twitter.com/en/apply-for-access).
- [**RapidAPI account**](https://rapidapi.com): If you don't have one already, you can create one [here](https://rapidapi.com/auth/sign-up).## 🎉 Let's start!
- First of all, fork this repository. If you don't know how forking works, check out [this guide](https://guides.github.com/activities/forking).
- Now that you have your own fork of the project, clone your repository to your computer.
- Go to the [Twitter tokens generator](https://github.com/totigm/twitter-tokens-generator) and generate the necessary access tokens for this bot.
- You can skip this step if you already have them.
- Go to the [Candlestick Chart API](https://rapidapi.com/totigm/api/candlestick-chart/pricing) and subscribe to a plan of your choice. Note that the basic plan will allow you to tweet with charts' images every 20 minutes.
- Copy your `x-rapidapi-key` key from the code snippet that you can find [in the API page](https://rapidapi.com/totigm/api/candlestick-chart). If you are having trouble finding the RapidAPI key, watch [this video](https://www.youtube.com/watch?v=t1lbJvoPxwM).
- Create a file named `.env` at the repo's root directory and paste the keys from the previous steps in it (It should look like [`.env.example`](.env.example)).
- Open your console inside the directory.
- Run `yarn` or `npm i` to install the project's dependencies.
- Go to the `index.ts` file and choose the cryptocurrency you want, you can also change the time between tweets. Go to the [⚙️ Bot options](#⚙️-bot-options) section to see how to customize your bot.
- Finally, run `yarn start` or `npm start` and your bot will start running!
- That's it! You have your own Twitter Crypto Bot!## ⚙️ Bot options
Your bot can be customized if you want it to have a different behaviour. The options that it supports right now are:
![Crypto bot options](https://user-images.githubusercontent.com/64804554/143328560-cee24984-44fd-4f8f-b624-2e608f4fbe97.png)
Option
Sub option
Description
Default value
Value type
credentials
consumer_key
Key you get from your Twitter app.
CONSUMER_KEY value in your .env file.
String
consumer_secret
Secret key you get from your Twitter app.
CONSUMER_SECRET value in your .env file.
String
access_token
Generated access token you get for an specific Twitter user.
ACCESS_TOKEN value in your .env file.
String
access_token_secret
Generated secret access token you get for an specific Twitter user.
ACCESS_TOKEN_SECRET value in your .env file.
String
decimalsAmount
Number of decimal places after the comma of the cryptocurrency price.
From 0 to 8 depending on the cryptocurrency price.
Positive number
hasHashtags
code
If the tweet should contain the coin code as a hashtag or not. E.g. #BTC.
true
Boolean
name
If the tweet should contain the coin name as a hashtag or not. E.g. #Bitcoin.
true
Boolean
hasComparisons
lastTweet
If the tweet should contain the comparison between the current price and the one
from 24 hours ago.
true
Boolean
lastDay
If the tweet should contain the comparison between the current price and the one
from the last tweet.
true
Boolean
chartOptions
interval
Time interval for each candle.
- m: Minutes
- h: Hours
- d: Days
- w: Weeks
- M: Months
1m
- 1m
- 3m
- 5m
- 15m
- 30m
- 1h
- 2h
- 4h
- 6h
- 8h
- 12h
- 1d
- 3d
- 1w
- 1M
limit
Amount of candles in the chart
16
Integer. Maximum 1000
When you saw the first example, you might have noticed that the tweet interval was set in minutes. If you want to set the interval to certain amount of hours, minutes, and/or seconds, you can use a time object to explicitly set them.
![Set tweet interval options](https://user-images.githubusercontent.com/68404335/143306008-907e046a-a682-4b90-83b0-dc6428e3a031.png)
| Option | Description | Value Type |
| ----------- | ---------------------------------------- | --------------- |
| **hours** | Time interval in hours between tweets. | Positive number |
| **minutes** | Time interval in minutes between tweets. | Positive number |
| **seconds** | Time interval in seconds between tweets. | Positive number |> As shown in the [first example](#twitter-crypto-bot) you can also use just a number instead of an object and it will be considered as minutes.
>
> E.g. `bot.setTweetInterval(15)` is the same as `bot.setTweetInterval({ minutes: 15 })`## 💖 Support the project
If you like what we do and want to encourage us to continue creating stuff, starring and sharing this project would be really appreciated! Also, if you want to support us a little bit more, you can [buy us a coffe](https://www.buymeacoffee.com/pamboo), or make a BTC tip to the following address: `1E6ZBxA8c32YwJxiWW4ohvm9oVYqqWh5tU`
[![Buy us a coffe](https://user-images.githubusercontent.com/64804554/143627395-6e441486-8efc-47cd-b40a-f3bb9ef777ee.png)](https://www.buymeacoffee.com/pamboo)
## ✨ Contributing
Contributions are more than welcome!
We think that you might have great ideas to make this project even better, so if you do, please create a pull request and/or issue following our [contribution guidelines](./docs/CONTRIBUTING.md).
## 😃 Authors
- [Totigm](https://github.com/totigm)
- [Hernancano98](https://github.com/Hernancano98)## 📄 License
[MIT](./LICENSE)
This project was made with ❤ and TypeScript