Using the SDKs
To interact with a data stream you found in the explorer, your first step is to choose the SDK for your preferred language. Each repository contains the full installation instructions, API reference, and examples you’ll need.What is a streamID
?
A streamID
is the unique identifier for a data stream on the TRUF.NETWORK. You can find the streamID
for any stream on its page in the TRUF.NETWORK Explorer. You will use this ID in the SDK functions to retrieve data.
How to Fetch Data from a Stream
Once you have a Stream ID and Data Provider from the TRUF.NETWORK Explorer, you can use the SDKs to query its data. The SDKs provide several core methods for querying, depending on what you need to do.Core Query Methods
The explorer may show a specificSDK Method
for a stream (like get_index_change
). These methods correspond to the core functions available in all our SDKs. Here are the most common ones:
-
getRecord
/get_records
: Retrieves the raw, original numeric values from a stream. Use this when you need the exact, unaltered data. This is the most fundamental query. -
getIndex
: Transforms the raw values into a normalized index (based to 100). This is useful for comparing the performance of different streams on the same scale. -
getIndexChange
: Calculates the percentage change of a stream’s index over a specified time interval (e.g., day-over-day, year-over-year). - Custom Procedures: For advanced use cases, the SDKs provide a way to call any custom stored procedure defined on a stream’s contract.
Conceptual Example: Fetching Raw Data (getRecord
)
Here is a conceptual example of how to use the getRecord
method to fetch the raw data points from a stream.
TypeScript/JavaScript
Go
Python
SDK Capabilities
Each SDK provides comprehensive tools to interact with the TRUF.NETWORK, enabling operations such as:- Deploying primitive and composed streams
- Inserting and retrieving records
- Managing stream metadata
- Handling stream permissions
- Performing batch operations
Stream Deployment Permissions
To ensure the integrity and quality of data streams on the TRUF.NETWORK, the creation of new streams (both primitive and composed) is a permissioned operation. This process is governed by asystem:network_writer
role within the network’s role-based access control (RBAC) system.
Only wallets that are members of the system:network_writer
role are authorized to deploy new streams using the SDKs.
How to get access:
If you are a partner or data provider interested in deploying streams on the TRUF.NETWORK, please contact our team. We will guide you through the process of obtaining the necessary permissions by granting your wallet the system:network_writer
role.
Using SDKs with Your Local Node
This section is intended for node operators who are running a local
TRUF.NETWORK node that is fully synced with the network. If your node is not
connected to the network, queries will return empty results because your local
database will not contain any data. Always ensure your node is synchronized
before using it as an SDK endpoint. Follow the Node Operator
Guide
for instructions on connecting to the network and syncing data.
Prerequisites
- Node is fully synced: Ensure your node is fully synchronized with the network and has all data available. See the Node Operator Guide for instructions on checking sync status.
-
Local Endpoint:
Your node should be running and exposing the HTTP API at
http://localhost:8484
(the default).
Configuration
To use the SDKs with your local node, you need to configure the client to point to your local endpoint (http://localhost:8484
) instead of the default public gateway. For detailed instructions and code examples, refer to the guide in the README of the respective SDK repository:
- Go: Local Node Guide
- TypeScript/JavaScript: Local Node Guide
- Python: Local Node Guide