graphtracks_client 1.0.0-dev.10
SDKdartflutter
Platformandroidioswindowslinuxmacosweb
GraphTracks API Bluesky Analytics client for Dart. Provides access to Bluesky social network analytics data through the GraphTracks API.
GraphTracks Analytics API Example
This example demonstrates how to use the GraphTracks Analytics API Dart client to fetch account statistics.
Prerequisites
-
API Key: Get your API key from GraphTracks and set it as an environment variable:
export GRAPHTRACKS_API_KEY=your_api_key_here -
Dart SDK: Ensure you have Dart 2.18.0+ installed.
-
Dependencies: Install the required dependencies:
dart pub get
Usage
Run the example script with a Bluesky account DID:
dart run example/main.dart <account_did>
Example
# Set your API key
export GRAPHTRACKS_API_KEY=your_api_key_here
# Run the example with a Bluesky DID
dart run example/main.dart did:plc:example123
Alternative: Using the Shell Script
For convenience, you can also use the provided shell script:
# Set your API key
export GRAPHTRACKS_API_KEY=your_api_key_here
# Run the shell script (from project root)
./example/run_example.sh did:plc:example123
The shell script provides additional validation and user-friendly error messages.
What the Example Does
The example script:
- Validates Input: Checks that a DID is provided as a command line argument
- Authentication: Uses the
GRAPHTRACKS_API_KEYenvironment variable for authentication - API Call: Fetches followers statistics for the specified account from BlueSky
- Data Display: Prints the timestamp and follower count data points
Configuration Options
You can modify the example to change:
- Network: Currently only
Network.blueSkyis supported - Metric: Choose from
Metric.followers,Metric.likes,Metric.replies,Metric.reposts - Timeframe: Options include
Timeframe.n1h,Timeframe.n1d,Timeframe.n7d,Timeframe.n30d,Timeframe.n90d,Timeframe.all - Date Range: Set custom
fromandtodates (cannot usetimeframeandtotogether) - Bucket Size: Adjust the interval between data points (in seconds)
Error Handling
The example includes error handling for:
- Missing command line arguments
- Missing API key environment variable
- API call failures
Sample Output
Response data:
Timestamp: 2025-05-01T00:00:00.000Z, Value: 1250
Timestamp: 2025-05-02T00:00:00.000Z, Value: 1255
Timestamp: 2025-05-03T00:00:00.000Z, Value: 1262
...