> For the complete documentation index, see [llms.txt](https://docs.blockrazor.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blockrazor.io/streams/network-fee-stream/bsc/getallgaspricestream.md).

# BSC GetAllGasPriceStream

Introducing the access method of BlockRazor BSC GetAllGasPriceStream

### Introduction

`GetAllGasPriceStream` provides gas price subscription service on BSC. It pushes the gas price of BSC transactions in recent block to users at all percentile based on gRPC stream. The endpoint is: <mark style="color:$primary;">grpc.bsc-fee.blockrazor.me:443</mark>

### Price

The price is $30 / day and $300 / month. <a href="https://blockrazor.io/#/login?redirect=pricing&#x26;purchaseMode=personalized&#x26;chain=bsc&#x26;serviceId=bsc_fee_stream&#x26;billing=day" class="button primary small">Subscribe</a>

### Request Parameter

<table><thead><tr><th width="131.4765625">Parameters</th><th width="131.76171875">Mandatory</th><th width="86.74609375">Format</th><th width="104.44140625">Example</th><th>Remarks</th></tr></thead><tbody><tr><td>blockRange</td><td>mandatory</td><td>int</td><td>20</td><td>Statistics of gas prices of transactions in the last N blocks, where N ranges from 1 to 20</td></tr></tbody></table>

### Request Example

```go
package main

import (
	"context"
	"crypto/tls"
	"log"

	pb "fee-test/bscfeepb"

	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials"
)

const (
	gRPCEndpoint = "grpc.bsc-fee.blockrazor.xyz:443"
	auth         = "your_auth"
)

func main() {
	conn, err := grpc.Dial(
		gRPCEndpoint,
		grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
		grpc.WithPerRPCCredentials(&Authentication{auth}),
	)
	if err != nil {
		panic(err)
	}
	defer conn.Close()

	client := pb.NewServerClient(conn)

	req := &pb.BlockRange{
		BlockRange: 5,
	}
	stream, err := client.GetAllGasPriceStream(context.Background(), req)
	if err != nil {
		panic(err)
	}

	for {
		message, err := stream.Recv()
		if err != nil {
			log.Printf("Failed to receive message: %v", err)
			break
		}
		log.Printf("Received Time: %s\n", message.Time.AsTime().Format("2006-01-02 15:04:05"))
		for _, gasPrice := range message.AllGasPrice {
			log.Printf("Received message percentile: %d\n", gasPrice.Percentile)
			log.Printf("Received message value: %s\n", gasPrice.Value)
		}
	}
}

type Authentication struct {
	auth string
}

func (a *Authentication) GetRequestMetadata(context.Context, ...string) (map[string]string, error) {
	return map[string]string{"apiKey": a.auth}, nil
}

func (a *Authentication) RequireTransportSecurity() bool {
	return false
}
```

#### Proto

```json
syntax = "proto3";

package bscfeepb;

import "google/protobuf/timestamp.proto";

option go_package = "./pb/bscfeepb";

service Server {
    rpc GetGasPriceStream(TransactionFee) returns(stream TransactionFeeStreamResponse) {};
    rpc GetAllGasPriceStream(BlockRange) returns(stream AllGasPriceStreamResponse) {};
}

message TransactionFee {
    int32 percentile = 1;
    int32 blockRange = 2;
}

message FeeValue {
    int32 percentile = 1;
    string value = 2;
}

message TransactionFeeStreamResponse {
    FeeValue gasPrice = 1;
    google.protobuf.Timestamp time = 2;
}

message BlockRange {
    int32 blockRange = 2;
}

message AllGasPriceStreamResponse {
    repeated FeeValue allGasPrice = 1;
    google.protobuf.Timestamp time = 2;
}
```

### Response Example

```json
2025/04/08 10:18:21 Received Time: 2025-04-08 02:18:21
2025/04/08 10:18:21 Received message percentile: 25
2025/04/08 10:18:21 Received message value: 1000000000 //// The gas price corresponding to the quantile, in wei
2025/04/08 10:18:21 Received message percentile: 50
2025/04/08 10:18:21 Received message value: 1100000000
2025/04/08 10:18:21 Received message percentile: 75
2025/04/08 10:18:21 Received message value: 2020000000
2025/04/08 10:18:21 Received message percentile: 95
2025/04/08 10:18:21 Received message value: 5000000000
2025/04/08 10:18:21 Received message percentile: 99
2025/04/08 10:18:21 Received message value: 20000000000
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.blockrazor.io/streams/network-fee-stream/bsc/getallgaspricestream.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
