View Streams
This page explains how you can see existing streams and view their details.
- Web Console
- Python SDK
- JavaScript SDK
- REST API
- CLI
View existing streams.
Click Data > Streams.
Macrometa displays a list of streams and their attributes.
To see more details and stream statistics, click a stream name.
View a list of existing streams.
from c8 import C8Client
# Define variables
URL = "play.paas.macrometa.io"
GEO_FABRIC = "_system" # Change this to your fabric
API_KEY = "your-api-key" # Change this to your API key
# Create client instance with API KEY
client = C8Client(protocol='https', host=URL, port=443, apikey=API_KEY, geofabric=GEO_FABRIC)
# Fetch the list of streams
streams = client.get_streams()
# Print the formatted list of streams
print("List of streams:")
for stream in streams:
print(f"- Name: {stream['name']}")
print(f" Topic: {stream['topic']}")
print(f" Type: {stream['type']}")
print(f" Status: {stream['status']}")
Get stats for a specific stream.
from c8 import C8Client
# Define variables
URL = "play.paas.macrometa.io"
GEO_FABRIC = "_system" # Change this to your fabric
API_KEY = "your-api-key" # Change this to your API key
# Create client instance with API KEY
client = C8Client(protocol='https', host=URL, port=443, apikey=API_KEY, geofabric=GEO_FABRIC)
# Name of the stream to get information for
# Do not include the prefix
stream_name = "your-stream-name"
try:
# Get stream stats
stream_stats = client.get_stream_stats(stream_name)
# Print stream stats
print("Stream statistics for '{}'".format(stream_name))
print("----------------------------------------")
for key, value in stream_stats.items():
print("{}: {}".format(key, value))
except Exception as e:
print("Error getting stream stats: {}".format(e))
View a list of existing streams.
const { C8Client } = require('jsC8');
// Set up the client instance
const client = new C8Client({url: "https://play.paas.macrometa.io",
apiKey: "your-api-key", // Change this to your API key
fabricName: "_system"}); // Change this to your fabric
async function getStreams() {
try {
const streams = await client.getStreams();
// Stream list
console.log(streams);
} catch (e) {
await console.log("Not able to get streams: " + e);
}
}
getStreams();
Get stats for a specific stream.
const { C8Client } = require('jsC8');
// Set up the client instance
const client = new C8Client({url: "https://play.paas.macrometa.io",
apiKey: "your-api-key", // Change this to your API key
fabricName: "_system"}); // Change this to your fabric
async function getStreamStats() {
try {
const streamName = "myStream"; // Change this to your stream, do not include the prefix
const stats = await client.getStreamStats(streamName);
console.log(stats);
} catch (e) {
console.log(`Error getting stream stats: ${e}`);
}
}
getStreamStats();
Use our interactive API Reference with code generation in 18 programming languages to:
Use the following CLI commands to view existing streams: