Data logo

Data

Organization
stellar
data

Querying Stellar chain data via Stellar RPC (preferred) and Horizon (legacy). Covers RPC JSON-RPC methods, Horizon REST endpoints, streaming, pagination, historical queries, Hubble/Galexie for deep history, and the RPC/Horizon migration story. Use when reading balances, transactions, operations, ledgers, contract events, or building any indexer/analytics workflow.

Overview

Publisherstellar
Repositorystellar-dev-skill
Skill namedata
Stars
56
Forks
64
Bundled files
1
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by stellar on GitHub. Read the source before you install it.

Installation

Install the Data AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/stellar/stellar-dev-skill/tree/main/skills/data
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/stellar/stellar-dev-skill.git /tmp/stellar-dev-skill
mkdir -p .claude/skills
cp -r /tmp/stellar-dev-skill/skills/data .claude/skills/data
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Data in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Data on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Data is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Stellar Data: RPC + Horizon

API access for reading chain state. Stellar RPC is the preferred entry point for new projects; Horizon remains for legacy and historical-query workflows. For deeper history beyond RPC's 7-day window, use Hubble/Galexie.

When to use this skill

  • Calling Stellar RPC methods (getLatestLedger, getLedgerEntries, getEvents, simulateTransaction, sendTransaction)
  • Querying Horizon endpoints (accounts, transactions, operations, effects, ledgers)
  • Streaming live events or operations
  • Pulling historical data beyond RPC's 7-day window (Hubble, Galexie)
  • Choosing between RPC and Horizon for a given workflow

Related skills

  • Building transactions to send → ../dapp/SKILL.md
  • Smart contract simulation and event emission → ../smart-contracts/SKILL.md
  • Asset balance and trustline lookups → ../assets/SKILL.md
  • Standards (SEP-7 deeplinks, SEP-10 auth) → ../standards/SKILL.md

Overview

Stellar provides two API paradigms:

APIStatusUse Case
Stellar RPCPreferredSmart contracts, real-time state, new projects
HorizonLegacy-focusedHistorical data, legacy applications

Recommendation: Use Stellar RPC for all new projects. Use Horizon mainly for historical queries and legacy compatibility paths.

Read the file that matches the task

TaskFile
RPC methods and usageStellar RPC (below)
Horizon endpoints, common operations, streaming, paginationhorizon.md
Migration strategyMigration: Horizon to RPC (below)
Data history/indexing optionsHistorical Data Access (below)
Environment setup and endpointsNetwork Configuration (below)

Stellar RPC

Endpoints

Note: SDF directly provides Futurenet public RPC. For Mainnet RPC, select a provider from the RPC providers directory.

NetworkRPC URL
MainnetProvider-specific endpoint (see RPC providers directory)
Testnethttps://soroban-testnet.stellar.org
Futurenethttps://rpc-futurenet.stellar.org
Localhttp://localhost:8000/soroban/rpc

Setup

typescript
import * as StellarSdk from "@stellar/stellar-sdk";

const rpc = new StellarSdk.rpc.Server("https://soroban-testnet.stellar.org");

Key Methods

Get Account
typescript
const account = await rpc.getAccount(publicKey);
// Returns account with sequence number for transaction building
Get Health
typescript
const health = await rpc.getHealth();
// { status: "healthy" }
Get Latest Ledger
typescript
const ledger = await rpc.getLatestLedger();
// { id: "...", sequence: 123456, protocolVersion: 25 }
Get Ledger Entries
typescript
// Read contract storage
const key = StellarSdk.xdr.LedgerKey.contractData(
  new StellarSdk.xdr.LedgerKeyContractData({
    contract: new StellarSdk.Address(contractId).toScAddress(),
    key: StellarSdk.xdr.ScVal.scvSymbol("Counter"),
    durability: StellarSdk.xdr.ContractDataDurability.persistent(),
  })
);

const entries = await rpc.getLedgerEntries(key);
if (entries.entries.length > 0) {
  const value = StellarSdk.scValToNative(
    entries.entries[0].val.contractData().val()
  );
}
Simulate Transaction
typescript
const simulation = await rpc.simulateTransaction(transaction);

if (StellarSdk.rpc.Api.isSimulationError(simulation)) {
  console.error("Simulation failed:", simulation.error);
} else if (StellarSdk.rpc.Api.isSimulationSuccess(simulation)) {
  console.log("Cost:", simulation.cost);
  console.log("Result:", simulation.result);
}
Send Transaction
typescript
// status: "PENDING" | "DUPLICATE" | "TRY_AGAIN_LATER" | "ERROR"
let response = await rpc.sendTransaction(signedTransaction);

// TRY_AGAIN_LATER: not queued. Usually this source account already has a
// transaction in flight, so resending the same signed transaction is safe.
// If the queue was full, stellar-core bans this exact transaction for 10
// ledgers, so resends keep failing: rebuild it with a higher fee instead.
for (let i = 0; response.status === "TRY_AGAIN_LATER" && i < 5; i++) {
  await new Promise((r) => setTimeout(r, 2000));
  response = await rpc.sendTransaction(signedTransaction);
}

if (response.status === "ERROR") {
  // Rejected by stellar-core. The SDK parses the raw errorResultXdr field
  // into errorResult (a TransactionResult).
  throw new Error("Transaction rejected", { cause: response.errorResult });
}
if (response.status === "TRY_AGAIN_LATER") {
  throw new Error("Not queued; rebuild with a higher fee or resubmit later");
}

// PENDING (queued now) or DUPLICATE (already queued): poll for the result.
// pollTransaction tries 30 times, 1s apart, by default.
const result = await rpc.pollTransaction(response.hash);

if (result.status === "SUCCESS") {
  console.log("Success:", result.returnValue);
} else if (result.status === "FAILED") {
  console.error("Failed on-chain:", result.resultXdr); // a TransactionResult
} else {
  console.error("Not confirmed yet (NOT_FOUND); check getTransaction later");
}

DUPLICATE means the same transaction is still in the queue. Once it is applied, sending it again returns ERROR (txBAD_SEQ). So before you treat ERROR on a resend as a failure, call getTransaction(hash).

Get Transaction
typescript
const tx = await rpc.getTransaction(txHash);
// status: "SUCCESS" | "FAILED" | "NOT_FOUND"
// returnValue: ScVal (for contract calls)
// ledger: number
Get Events
typescript
const events = await rpc.getEvents({
  startLedger: 1000000,
  filters: [
    {
      type: "contract",
      contractIds: [contractId],
      topics: [
        ["*", StellarSdk.xdr.ScVal.scvSymbol("transfer").toXDR("base64")],
      ],
    },
  ],
});

for (const event of events.events) {
  console.log("Event:", event.topic, event.value);
}

RPC Limitations

  • 7-day history for most methods: getTransaction, getEvents, etc. only cover recent data
  • getLedgers exception: on a data-lake-backed provider, "Infinite Scroll" pages back past the retention window — as far as that provider's data lake reaches (potentially genesis). On a plain RPC instance it is bounded by getHealth().oldestLedger; requests older than that fail with -32600. Check before assuming depth.
  • No streaming: Poll for updates (no WebSocket)
  • Contract-focused: Limited classic Stellar data

Migration: Horizon to RPC

Account Loading

typescript
// Horizon (old)
const account = await horizonServer.loadAccount(publicKey);

// RPC (new)
const account = await rpc.getAccount(publicKey);
// Note: RPC returns less data, just what's needed for transactions

Transaction Submission

typescript
// Horizon (for classic transactions)
const result = await horizonServer.submitTransaction(tx);

// RPC (for smart contract transactions)
const response = await rpc.sendTransaction(tx); // branch on response.status (see Send Transaction)
const result = await rpc.pollTransaction(response.hash);

Historical Data

typescript
// Horizon - full history
const allTxs = await horizonServer
  .transactions()
  .forAccount(publicKey)
  .call();

// RPC - most methods limited to the retention window (~7 days)
// Exception: getLedgers can page further back (Infinite Scroll), but only as far
// as the chosen provider's retention or data-lake integration reaches.
// Always check the floor of the instance you're talking to first:
const { oldestLedger } = await rpc.getHealth();
// For guaranteed full history, use:
// 1. Hubble (SDF's BigQuery dataset)
// 2. Galexie (data pipeline)
// 3. Your own indexer

Streaming Replacement

typescript
// Horizon - native streaming
server.payments().stream({ onmessage: handlePayment });

// RPC - polling (no native streaming)
async function pollForUpdates() {
  const lastLedger = await rpc.getLatestLedger();
  // Check for new events/transactions
  // Repeat on interval
}
setInterval(pollForUpdates, 5000);

Historical Data Access

For data older than the RPC retention window (~7 days — not available via most RPC methods; getLedgers reaches further only on data-lake-backed providers, see Data Lake below):

Hubble (BigQuery)

sql
-- Query Stellar data in BigQuery
SELECT *
FROM `crypto-stellar.crypto_stellar.history_transactions`
WHERE source_account = 'G...'
ORDER BY created_at DESC
LIMIT 100

Galexie

Self-hosted data pipeline for processing Stellar ledger data:

Data Lake

RPC "Infinite Scroll" is powered by the Stellar data lake — a cloud-based object store (SEP-0054 format). Deep getLedgers history is a property of the provider, not the method: an instance only serves history past its retention window if its operator wired a data lake in. Instances without one (the public SDF testnet RPC included) reject older start ledgers with JSON-RPC -32600 — compare your target against getHealth().oldestLedger before paging back.

Third-Party Indexers

For complex queries, event streaming, or custom data pipelines beyond what RPC/Horizon provide:

See the full indexer directory: https://developers.stellar.org/docs/data/indexers

Network Configuration

For a React/Next.js-specific setup, see the dapp skill. For mainnet RPC, set STELLAR_MAINNET_RPC_URL from a provider in the RPC providers directory.

Environment-Based Setup

typescript
// lib/stellar-config.ts
import * as StellarSdk from "@stellar/stellar-sdk";

type NetworkConfig = {
  rpcUrl: string;
  horizonUrl: string;
  networkPassphrase: string;
  friendbotUrl: string | null;
};

const requireEnv = (name: string): string => {
  const value = process.env[name];
  if (!value) throw new Error(`Missing required env var: ${name}`);
  return value;
};

// Lazy per-network factories: requireEnv only runs for the selected network,
// so testnet/local work without the mainnet env var set.
const configs: Record<string, () => NetworkConfig> = {
  mainnet: () => ({
    rpcUrl: requireEnv("STELLAR_MAINNET_RPC_URL"),
    horizonUrl: "https://horizon.stellar.org",
    networkPassphrase: StellarSdk.Networks.PUBLIC,
    friendbotUrl: null,
  }),
  testnet: () => ({
    rpcUrl: "https://soroban-testnet.stellar.org",
    horizonUrl: "https://horizon-testnet.stellar.org",
    networkPassphrase: StellarSdk.Networks.TESTNET,
    friendbotUrl: "https://friendbot.stellar.org",
  }),
  local: () => ({
    rpcUrl: "http://localhost:8000/soroban/rpc",
    horizonUrl: "http://localhost:8000",
    networkPassphrase: "Standalone Network ; February 2017",
    friendbotUrl: "http://localhost:8000/friendbot",
  }),
};

const network = process.env.STELLAR_NETWORK || "testnet";
const makeConfig = configs[network];
if (!makeConfig) throw new Error(`Unknown network: ${network}`);
export const config = makeConfig();

export const rpc = new StellarSdk.rpc.Server(config.rpcUrl);
export const horizon = new StellarSdk.Horizon.Server(config.horizonUrl);

Best Practices

Use RPC for:

  • New application development
  • Smart contract interactions
  • Transaction simulation and submission
  • Real-time account state

Use Horizon for:

  • Historical transaction queries
  • Payment streaming
  • Legacy application maintenance
  • Rich account metadata

Error Handling

typescript
// RPC: a rejected transaction does not throw. sendTransaction returns
// status "ERROR" (see Send Transaction). The SDK throws only JSON-RPC
// errors ({ code, message }, e.g. malformed params) and HTTP/network failures.
try {
  const response = await rpc.sendTransaction(tx);
  if (response.status === "ERROR") {
    // Rejected: inspect response.errorResult
  }
} catch (error) {
  console.error("RPC call failed:", error); // JSON-RPC { code, message } or HTTP error
}

// Horizon errors
try {
  const result = await horizon.submitTransaction(tx);
} catch (error) {
  const extras = error.response?.data?.extras;
  if (extras?.result_codes) {
    // Detailed error codes
    console.log("Transaction:", extras.result_codes.transaction);
    console.log("Operations:", extras.result_codes.operations);
  }
}

Rate Limiting

Both RPC and Horizon have rate limits:

  • Use exponential backoff for retries
  • Cache responses where appropriate
  • Consider running your own nodes for high-volume applications
typescript
async function withRetry<T>(fn: () => Promise<T>, maxRetries = 3): Promise<T> {
  let lastError: Error;
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      lastError = error;
      if (error.response?.status === 429) {
        // Rate limited - exponential backoff
        await new Promise(r => setTimeout(r, Math.pow(2, i) * 1000));
      } else {
        throw error;
      }
    }
  }
  throw lastError;
}

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Data AI skill do?

Querying Stellar chain data via Stellar RPC (preferred) and Horizon (legacy). Covers RPC JSON-RPC methods, Horizon REST endpoints, streaming, pagination, historical queries, Hubble/Galexie for deep history, and the RPC/Horizon migration story. Use when reading balances, transactions, operations, ledgers, contract events, or building any indexer/analytics workflow.

Why use Data on TypingMind?

Because you install it once and use it with any model. Data is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Data in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/stellar/stellar-dev-skill/tree/main/skills/data. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Data?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Data?

As many as you like. As long as a model supports skills, you can use Data with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Data AI skill free?

Yes. It is published on GitHub by stellar under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇