Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rpcnode/api-sdk-go

Official Go client for the RpcNode Public API: dedicated fullnode RPC (Ethereum, Solana, Bitcoin, Tron, BNB Chain, Polygon, Arbitrum, Optimism, Base, and more), HMAC-signed merchant HTTP, address watch webhooks, and crypto payments.

API: https://api.rpcnode.dev

Module: github.com/rpcnode/api-sdk-go
Repo: github.com/rpcnode/api-sdk-go

Install

go get github.com/rpcnode/api-sdk-go@latest

Or clone:

git clone git@github.com:rpcnode/api-sdk-go.git
cd api-sdk-go && go test ./...

Auth

Every request is HMAC-signed. Query string is not part of the signature.

Header Value
X-Api-Key Key prefix (pk_live_…)
X-Timestamp Unix seconds (±300s)
X-Signature hex(hmac_sha256(secret, canonical))
{timestamp}\n{METHOD}\n{path}\n{sha256_hex(body)}

Empty body → SHA-256 of "". Headers are added by the client.

Quickstart

package main

import (
	"fmt"
	"os"

	rpcnode "github.com/rpcnode/api-sdk-go"
)

func main() {
	base := os.Getenv("PUBLIC_API_BASE")
	if base == "" {
		base = "https://api.rpcnode.dev"
	}

	c := rpcnode.NewClient(base, os.Getenv("PUBLIC_API_KEY"), os.Getenv("PUBLIC_API_SECRET"))

	account, err := c.GetAccount()
	if err != nil {
		panic(err)
	}

	fmt.Println(account)
}

Methods

Client HTTP
GetAccount() GET /v1/account
GetAccountUsage(days) GET /v1/account/usage
ListEndpoints() GET /v1/endpoints
ListAvailableNetworks() GET /v1/endpoints/available-networks
GetWorkspaceUsage(days) GET /v1/endpoints/usage
CreateEndpoint(body) POST /v1/endpoints
GetEndpointUsage(id, days) GET /v1/endpoints/{id}/usage
UpdateEndpointStatus(id, status) PATCH /v1/endpoints/{id}/status
UpdateEndpointAllowedIPs(id, ips) PATCH /v1/endpoints/{id}/allowed-ips
GetAddressWatchAccount() GET /v1/address-watch/account
ListAddresses(params) GET /v1/address-watch/addresses
AddAddress(networkSlug, address) POST /v1/address-watch/addresses
DeleteAddress(watchID) DELETE /v1/address-watch/addresses
ListEvents(params) GET /v1/address-watch/events
GetWebhook() GET /v1/address-watch/webhook
SetWebhook(body) PUT /v1/address-watch/webhook
ListPayments(params) GET /v1/payments
CreatePayment(body) POST /v1/payments
GetPayment(paymentID) GET /v1/payments/{id}
GetPaymentByOrderID(orderID) GET /v1/payments/orders/{orderId}
ListNetworkTokens(networkSlug, includeNative) GET /v1/network-tokens

Tests

cp .env.example .env   # PUBLIC_API_KEY + PUBLIC_API_SECRET for live smokes
go test ./...

HMAC unit tests run without credentials. Live reads use .env or the environment. Writes: PUBLIC_API_SMOKE_MUTATE=1, PUBLIC_API_SMOKE_CREATE_PAYMENT=1.

License

MIT

About

RpcNode Public API SDK for Go

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages