A dynamic dashboard for fetching public social media data and displaying related stats
The dashboard is divided into two main parts: the sidebar
on the left and the main dashboard area
on the right.
- Use the
sidebar
on the left to choose a platform and mode using theChoose a platform
andChoose a mode
dropdowns provided there.
Definitions:Platform
: The social media platform to get data from (Facebook or Twitter)Mode
: The account from which to get this data
- On the
main dashboard area
:- Use the
Start date
andEnd date
input fields to choose the date range for which to fetch and view posts. The number of posts fetched and accounts from which they are fetched will be displayed. - Use the dropdowns to view statistics and graphs for the given date range.
- Use the
This dashboard is built in Python using the following tools and resources:
- Clone the project:
git clone https://github.com/SunbirdAI/social-media-data-dashboard.git
- Create a virtual environment:
python3 -m virtualenv venv
- Activate the virtual environment:
source venv/bin/activate
- Install project dependencies:
pip install -r requirements.txt
- Create an environment file (
.env
) and add environment variables as shown in the.env.example
file (more detail on theEnvironment Variables
section below) - Run the project:
streamlit run dashboard.py
The environment variables added to the .env
file are used to determine which account you will be fetching data from and which API key you will be using to fetch this data.
Data from Facebook is fetched through the CrowdTangle API. Below are the environment variables used:
Variable | How it is used |
---|---|
CROWDTANGLE_API_TOKEN | The API token from CrowdTangle that allows you to fetch data from their API |
CROWDTANGLE_MODE_LIST_ID | The id of the CrowdTangle list from which the posts will be fetched. Insert your mode to the MODE section, based on the definition of Mode above. |
CROWDTANGLE_POSTS_URL | The url for fetching posts. It is currently https://api.crowdtangle.com/posts |
Variable | How it is used |
---|---|
DATABASE_URL | The url to a PostgreSQL database for storing tweets |
To change modes or add your own modes to the dashboard, go to constants.py
in the project root folder and update the MODES
and TITLE_TO_MODE
dictionaries.
As a special case for Facebook posts, update the FB_TITLE_TO_MODE
dictionary. Make sure that for each added mode, there is an environment variable in the .env file in the form CROWDTANGLE_*MODE*_LIST_ID
as was explained above in Facebook (CrowdTangle) environment variables
.