Skip to content

gRPC API Overview

View as Markdown

The Thru gRPC API provides high-performance, strongly-typed remote procedure calls for interacting with the blockchain. Built on Protocol Buffers and HTTP/2, gRPC offers efficient binary serialization and bidirectional streaming.

For browser-based applications, gRPC-Web provides a JavaScript-compatible version of the gRPC protocol that works in web browsers without requiring plugins or proxies.

NetworkEndpointProtocolDescription
Alphanetgrpc.alphanet.thruput.org:443gRPC over HTTP/2 with TLSNative gRPC endpoint for all platforms
Alphanethttps://grpc-web.alphanet.thruput.orggRPC-WebBrowser-compatible gRPC endpoint

All gRPC services use Protocol Buffers (proto3) for serialization. Proto definitions are available in the GitHub repository.

gRPC uses Protocol Buffers for efficient binary serialization, resulting in payloads 2-10x smaller than JSON.

The StreamingService supports bidirectional streaming for real-time updates:

# Subscribe to account updates
request = SubscribeAccountRequest(address=account_address)
for update in client.SubscribeAccount(request):
print(f"Account updated: {update}")

gRPC uses status codes for error handling:

  • OK (0) - Success
  • NOT_FOUND (5) - Resource not found
  • INVALID_ARGUMENT (3) - Invalid request parameters
  • INTERNAL (13) - Internal server error
  • UNAVAILABLE (14) - Service unavailable

Typical performance characteristics:

  • Request latency: <50ms
  • Throughput: 1000+ requests/second per connection
  • Payload size: 2-10x smaller than REST/JSON

Connection Pooling

Reuse gRPC channels and connections instead of creating new ones for each request

Timeouts

Set appropriate deadlines for requests to prevent hanging operations

Retry Logic

Implement exponential backoff for retries on transient failures

Health Checks

Monitor service health using gRPC health check protocol