Ping gRPC Method
Please note that this method is metered based on data consumption at 0.1 MB = 10 API credits.
Parameters
count
integer
Loading...
Returns
response
integer
Loading...
Request
1package main23import (4"context"5"crypto/tls"6"fmt"7"log"89"google.golang.org/grpc"10"google.golang.org/grpc/credentials"11"google.golang.org/grpc/metadata"1213pb "hyperliquid-grpc-go/pb"14)1516const (17// Using Quicknode endpoint18grpcEndpoint = "your-endpoint.hype-mainnet.quiknode.pro:10000"19authToken = "your-auth-token"20)2122// Create gRPC connection with TLS23func createConnection() (*grpc.ClientConn, error) {24tlsConfig := &tls.Config{25InsecureSkipVerify: false, // Set to true only for testing26}27creds := credentials.NewTLS(tlsConfig)2829conn, err := grpc.Dial(30grpcEndpoint,31grpc.WithTransportCredentials(creds),32grpc.WithDefaultCallOptions(33grpc.MaxCallRecvMsgSize(100*1024*1024), // 100MB34),35)3637return conn, err38}3940// Create context with auth metadata41func createContext() context.Context {42md := metadata.Pairs("x-token", authToken)43return metadata.NewOutgoingContext(context.Background(), md)44}454647// Test connectivity48func pingTest(client pb.StreamingClient) error {49ctx := createContext()5051resp, err := client.Ping(ctx, &pb.PingRequest{Count: 1})52if err != nil {53return fmt.Errorf("ping failed: %v", err)54}5556log.Printf("✅ Ping successful: %+v", resp)57return nil58}596061func main() {62// Create connection63conn, err := createConnection()64if err != nil {65log.Fatalf("❌ Failed to connect: %v", err)66}67defer conn.Close()6869// Create client70client := pb.NewStreamingClient(conn)7172// Test connectivity73fmt.Printf("Testing connection to: %s\n", grpcEndpoint)74if err := pingTest(client); err != nil {75log.Fatalf("❌ Ping test failed: %v", err)76}7778fmt.Println("✅ Connection test completed successfully!")79}
1package main23import (4"context"5"crypto/tls"6"fmt"7"log"89"google.golang.org/grpc"10"google.golang.org/grpc/credentials"11"google.golang.org/grpc/metadata"1213pb "hyperliquid-grpc-go/pb"14)1516const (17// Using Quicknode endpoint18grpcEndpoint = "your-endpoint.hype-mainnet.quiknode.pro:10000"19authToken = "your-auth-token"20)2122// Create gRPC connection with TLS23func createConnection() (*grpc.ClientConn, error) {24tlsConfig := &tls.Config{25InsecureSkipVerify: false, // Set to true only for testing26}27creds := credentials.NewTLS(tlsConfig)2829conn, err := grpc.Dial(30grpcEndpoint,31grpc.WithTransportCredentials(creds),32grpc.WithDefaultCallOptions(33grpc.MaxCallRecvMsgSize(100*1024*1024), // 100MB34),35)3637return conn, err38}3940// Create context with auth metadata41func createContext() context.Context {42md := metadata.Pairs("x-token", authToken)43return metadata.NewOutgoingContext(context.Background(), md)44}454647// Test connectivity48func pingTest(client pb.StreamingClient) error {49ctx := createContext()5051resp, err := client.Ping(ctx, &pb.PingRequest{Count: 1})52if err != nil {53return fmt.Errorf("ping failed: %v", err)54}5556log.Printf("✅ Ping successful: %+v", resp)57return nil58}596061func main() {62// Create connection63conn, err := createConnection()64if err != nil {65log.Fatalf("❌ Failed to connect: %v", err)66}67defer conn.Close()6869// Create client70client := pb.NewStreamingClient(conn)7172// Test connectivity73fmt.Printf("Testing connection to: %s\n", grpcEndpoint)74if err := pingTest(client); err != nil {75log.Fatalf("❌ Ping test failed: %v", err)76}7778fmt.Println("✅ Connection test completed successfully!")79}
1const grpc = require('@grpc/grpc-js');2const protoLoader = require('@grpc/proto-loader');3const path = require('path');45// Configuration6const GRPC_ENDPOINT = 'your-endpoint.hype-mainnet.quiknode.pro:10000';7const AUTH_TOKEN = 'your-auth-token';89// Load proto file10const packageDefinition = protoLoader.loadSync(11path.join(__dirname, 'proto/streaming.proto'),12{13keepCase: true,14longs: String,15enums: String,16defaults: true,17oneofs: true,18}19);2021const hyperliquidProto = grpc.loadPackageDefinition(packageDefinition).hyperliquid;2223// Create gRPC client with TLS24function createClient() {25const credentials = grpc.credentials.createSsl();2627const client = new hyperliquidProto.Streaming(28GRPC_ENDPOINT,29credentials,30{31'grpc.max_receive_message_length': 100 * 1024 * 1024, // 100MB32}33);3435return client;36}3738// Create metadata with auth token39function createMetadata() {40const metadata = new grpc.Metadata();41metadata.add('x-token', AUTH_TOKEN);42return metadata;43}4445// Test connectivity with ping46function testPing(client) {47return new Promise((resolve, reject) => {48const metadata = createMetadata();4950client.Ping({ count: 1 }, metadata, (error, response) => {51if (error) {52reject(new Error(`Ping failed: ${error.message}`));53return;54}5556console.log('✅ Ping successful:', response);57resolve(response);58});59});60}6162// Main function63async function main() {64try {65console.log(`Testing connection to: ${GRPC_ENDPOINT}`);6667// Create client68const client = createClient();6970// Test connectivity71await testPing(client);7273console.log('✅ Connection test completed successfully!');7475// Close the client76client.close();7778} catch (error) {79console.error('❌ Error:', error.message);80process.exit(1);81}82}8384// Run the application85main();
1const grpc = require('@grpc/grpc-js');2const protoLoader = require('@grpc/proto-loader');3const path = require('path');45// Configuration6const GRPC_ENDPOINT = 'your-endpoint.hype-mainnet.quiknode.pro:10000';7const AUTH_TOKEN = 'your-auth-token';89// Load proto file10const packageDefinition = protoLoader.loadSync(11path.join(__dirname, 'proto/streaming.proto'),12{13keepCase: true,14longs: String,15enums: String,16defaults: true,17oneofs: true,18}19);2021const hyperliquidProto = grpc.loadPackageDefinition(packageDefinition).hyperliquid;2223// Create gRPC client with TLS24function createClient() {25const credentials = grpc.credentials.createSsl();2627const client = new hyperliquidProto.Streaming(28GRPC_ENDPOINT,29credentials,30{31'grpc.max_receive_message_length': 100 * 1024 * 1024, // 100MB32}33);3435return client;36}3738// Create metadata with auth token39function createMetadata() {40const metadata = new grpc.Metadata();41metadata.add('x-token', AUTH_TOKEN);42return metadata;43}4445// Test connectivity with ping46function testPing(client) {47return new Promise((resolve, reject) => {48const metadata = createMetadata();4950client.Ping({ count: 1 }, metadata, (error, response) => {51if (error) {52reject(new Error(`Ping failed: ${error.message}`));53return;54}5556console.log('✅ Ping successful:', response);57resolve(response);58});59});60}6162// Main function63async function main() {64try {65console.log(`Testing connection to: ${GRPC_ENDPOINT}`);6667// Create client68const client = createClient();6970// Test connectivity71await testPing(client);7273console.log('✅ Connection test completed successfully!');7475// Close the client76client.close();7778} catch (error) {79console.error('❌ Error:', error.message);80process.exit(1);81}82}8384// Run the application85main();
1import grpc2import sys3from pb import streaming_pb2, streaming_pb2_grpc45# Configuration6GRPC_ENDPOINT = 'your-endpoint.hype-mainnet.quiknode.pro:10000'7AUTH_TOKEN = 'your-auth-token'89def create_channel():10"""Create gRPC channel with TLS"""11credentials = grpc.ssl_channel_credentials()12channel = grpc.secure_channel(13GRPC_ENDPOINT,14credentials,15options=[16('grpc.max_receive_message_length', 100 * 1024 * 1024), # 100MB17('grpc.max_send_message_length', 100 * 1024 * 1024), # 100MB18]19)20return channel2122def create_metadata():23"""Create metadata with auth token"""24return [('x-token', AUTH_TOKEN)]2526def test_ping(stub):27"""Test connectivity with ping"""28try:29metadata = create_metadata()30request = streaming_pb2.PingRequest(count=1)3132response = stub.Ping(request, metadata=metadata)33print(f"✅ Ping successful: {response}")34return True35except grpc.RpcError as e:36print(f"❌ Ping failed: {e.details()}")37return False3839def main():40"""Main function"""41try:42print(f"Testing connection to: {GRPC_ENDPOINT}")4344# Create channel and stub45channel = create_channel()46streaming_stub = streaming_pb2_grpc.StreamingStub(channel)4748# Test connectivity49if test_ping(streaming_stub):50print("✅ Connection test completed successfully!")51else:52print("❌ Connection test failed!")5354# Close channel55channel.close()5657except KeyboardInterrupt:58print("\n👋 Goodbye!")59except Exception as e:60print(f"❌ Error: {e}")61sys.exit(1)6263if __name__ == "__main__":64main()
1import grpc2import sys3from pb import streaming_pb2, streaming_pb2_grpc45# Configuration6GRPC_ENDPOINT = 'your-endpoint.hype-mainnet.quiknode.pro:10000'7AUTH_TOKEN = 'your-auth-token'89def create_channel():10"""Create gRPC channel with TLS"""11credentials = grpc.ssl_channel_credentials()12channel = grpc.secure_channel(13GRPC_ENDPOINT,14credentials,15options=[16('grpc.max_receive_message_length', 100 * 1024 * 1024), # 100MB17('grpc.max_send_message_length', 100 * 1024 * 1024), # 100MB18]19)20return channel2122def create_metadata():23"""Create metadata with auth token"""24return [('x-token', AUTH_TOKEN)]2526def test_ping(stub):27"""Test connectivity with ping"""28try:29metadata = create_metadata()30request = streaming_pb2.PingRequest(count=1)3132response = stub.Ping(request, metadata=metadata)33print(f"✅ Ping successful: {response}")34return True35except grpc.RpcError as e:36print(f"❌ Ping failed: {e.details()}")37return False3839def main():40"""Main function"""41try:42print(f"Testing connection to: {GRPC_ENDPOINT}")4344# Create channel and stub45channel = create_channel()46streaming_stub = streaming_pb2_grpc.StreamingStub(channel)4748# Test connectivity49if test_ping(streaming_stub):50print("✅ Connection test completed successfully!")51else:52print("❌ Connection test failed!")5354# Close channel55channel.close()5657except KeyboardInterrupt:58print("\n👋 Goodbye!")59except Exception as e:60print(f"❌ Error: {e}")61sys.exit(1)6263if __name__ == "__main__":64main()
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free