This SDK is in beta and may change in the future.
Please let us know if you encounter any issues or have suggestions for improvement.
Prerequisites
Project Setup
Initialize Project Directory
mkdir get-started-with-neynar-go-sdk
cd get-started-with-neynar-go-sdk
go mod init getting_started
Add Neynar Go SDK as a dependency
go get github.com/neynarxyz/go-sdk/generated/rust_sdk
Implementation: Look up a user by their verified address
Replace the contents of main.go with your Go code using the Neynar Go SDK.
package getting_started
import (
"context"
"fmt"
openapiclient "github.com/neynarxyz/go-sdk/generated/neynar_sdk"
)
func main() {
configuration := openapiclient.NewConfiguration()
configuration.AddDefaultHeader("x-api-key", "NEYNAR_API_DOCS")
apiClient := openapiclient.NewAPIClient(configuration)
request := apiClient.UserAPI.
FetchBulkUsersByEthOrSolAddress(context.Background()).
Addresses("0xBFc7CAE0Fad9B346270Ae8fde24827D2D779eF07").
AddressTypes([]openapiclient.BulkUserAddressType{openapiclient.AllowedBulkUserAddressTypeEnumValues[1]})
resp, httpRes, err := request.Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
defer httpRes.Body.Close()
fmt.Printf("Users: %+v\n", resp)
}
Running the project
Result
You should see a response similar to this (formatted for readability):
Users: [{
fid: 20603,
username: "topocount.eth",
display_name: "Topocount",
// ...other fields...
}]
Congratulations! You successfully set up the Neynar Go SDK and used it to look up a user by their address!
Ready to start building?
Get your subscription at neynar.com and reach out to us on Slack with any questions!