This article describes an example /update example/update_santiment.py script that automates data history uploads to a forked repository.
The script gets data from Santiment API and converts it into CSV files.
For more information about Santiment API, you can refer to the Santiment's main page, API reference, and metrics overview.
Note
The
update_santiment.pyscript is only an example of how the automated uploads can be implemented. You will need to implement your own script.
The update_santiment.py script requests several metric values for two Crypto assets: Ethereum and Bitcoin.
For each Crypto asset metric, a /<CRYPTO_ASSET_FILE_PREFIX>_<METRIC_SUFFIX>.csv file is updated.
For example:
- for Bitcoin, the
sentiment_negative_totalmetric updatesdata/seed_crypto_santiment/BTC_SENTIMENT_NEGATIVE_TOTAL.csv, - for Ethereum, the
unique_social_volume_total_1hmetric updatesdata/seed_crypto_santiment/ETH_UNIQUE_SOCIAL_VOLUME_TOTAL_1H.csv.
For each Crypto asset metric, TradingView makes HTTP requests to Santiment GraphQL API for all data up to today inclusively and saves updated values to corresponding files. If there is a value for a date in the file, but there is no one in the response from the API, the value for this date remains unchanged in the file.
Before running the script, you first need to:
- Install the latest version of Python. For more information, refer to the Downloading Python instructions.
- Install the latest version of Git. For more information, refer to the Git download page.
- Download the
update_example/update_example.pyfile from the current repository. You can do it either by right-clicking Raw → Save as… or clicking Copy raw contents () and saving the file content locally via any text editor.
To update the data, follow the steps below:
-
On the repository page, copy the repository name by clicking Code → Copy to clipboard (
). You can use the HTTPS or SSH authentication. To use HTTPS, you need to generate an access token. To use SSH, you need to generate an SSH key.
-
On your computer, open command line and run the
git clone <your-repository-name.git>command. -
Change the current folder to folder where you saved
update_santiment.pyby executingcd <folder-name-with-update_santiment.py> -
Run
update_santiment.pyby executing the following command:python3 update_santiment.py --data-folder <path-to-forked-folder-with-your-local-data> -
Change the current folder to fork local copy by executing
cd <path-to-your-local-fork> -
You can run
git statusto see which files have changed.-
If you see Untracked files in the output, you need to add your symbol descriptions into symbol_info according to the step 1 in the tutorial.
-
If you see changes only in existing files, you can go to the next step.
-
If it is not your first data update, you can see what changed in the files by running
git diff. Pressqto exitgit diff.
-
-
Run
git add .to add the changes in the working directory to the index. -
Run
git commit -m "Update data"to record the changes to your remote repository. -
Run
git pushto upload your local repository content to the remote repository. -
Go to your repository page on GitHub and open Actions. Check that there is a new successful action run.
Note
Data should be updated every day. For next updates, you only need to follow steps 4−10.











