BBS Network Data Analysis - Tutorial - First Script
Jul 11, 2022 2:01 PM
This is a tutorial on how to write your first script to query the EOS blockchain to get some BBS Network data. The tutorial will be using PHP just because it's simple to understand and follow and many people know the basics but something like Python or JavaScript maybe better choices for more complex applications.
This tutorial follows the first one I wrote on Getting Started
If you find this guide useful and get value out of it by doing your own analysis please consider posting a reference link to this tutorial to help it get some views and share the knowledge.
Let's get started!
Related stories
Step 1
Create an empty text file called bbs_data.php
Step 2
Add some code to get the data from a file if it is given as an argument and the file exists. For now we won't worry about getting live data or processing the response.

You can run this script on the command line. On a Mac use terminal and type the following commands.
To use the saved data:
php bbs_data.php data.json
To fetch the data from the API:
php bbs_data.php
Step 3
Because we don't yet have any saved data we will need to fetch it from the API. First we need to get an access token so we will add a function called getAuthToken to do that.

Replace "YOUR API KEY" with your actual API key and call the function.

Step 4
Now we have the access token we need to get some data. Add a function called doSearch.

The $dataString has the following value:
{"query": "query { \\n searchTransactionsBackward(query: \\"receiver:deweb.eosn action:ledgerprint\\",lowBlockNum: 0,limit: 1000) { \\n results { \\n cursor\\n trace {\\n id\\n matchingActions { \\n account\\n name\\n data\\n }\\n } \\n } \\n }\\n}\\n","variables":{}}
This will fetch the last 1000 transactions which is the maximum. To get fewer transactions you can change the "limit" value.
Note that we are saving the data to a file called data.json. This will allow you to use the saved snapshot so that you don't use up all your API data quota for debugging and testing.
Call the function after getting the access token.

Tip: Fetch a small amount of data first to study the json structure of the response and the types of actions that are to be found for the BBS Network. There be treasure in that data aaarrgghhh 🏴☠️ 🦜 😂
Step 5
When users visit a board they get a daily visit bonus. Let's extract the counts of how many users collected their bonus for a few selected boards from the data snapshot we just fetched.

Step 6
Now just echo the counts

This will output something like the following:

Step 8
Modify the code to suit your use and style. Add some error checking. Make it your own. Experiment.
Final words
- It's important to use the data wisely. Don't flood the boards with useless data analysis posts. Really think about what types of statistics will be useful to the community.
- Don't name and shame others. You can get statistics for things like who tipped the most or who did the most thumbs down but even though the data is publicly available be mindful about the feelings of others.
- It can be useful to ask a question like:
What would be the most effective board for a board owner to advertise on in order to get more users to join their board?
The daily visit counts we used in the example above can be extended to find out an estimate of how many unique users are active on a board. In the case of the question above, it would not be effective for the Board Owner to advertise on a board that had too many overlapping users so we can exclude users who also collected a bonus on their board.
- Be creative in how you present the data. My presentation is generally very boring and simple because I just haven't had the time to make fancy infographics. Presenting the data in beautiful and easy to digest ways can get you more engagement.
- Happy data mining and happy coding 😊
7
Comments
Powered by RoundtableAn AI/DeFi-powered Enterprise Media Operating System. Learn more at Roundtable.io.© Roundtable 2026. By using this site you agree to the Terms of Use and Privacy Policy

