Skip to main content

GetCollectionByID Access API Method

Gets a collection by ID.

Updated on
Oct 4, 2023

GetCollectionByID Access API Method

Parameters

Id
string
REQUIRED
The collection id

Returns

collection
object
The collection object with the following fields:
id
string
The collection id
transaction_ids
array
The list of transaction ids associated with the collection
Request
1
package main
2
3
import (
4
"context"
5
"encoding/hex"
6
"encoding/json"
7
"fmt"
8
"log"
9
10
"github.com/onflow/flow/protobuf/go/flow/access"
11
)
12
13
func main() {
14
15
// Requires authenticating before making the request. Refer to Intro Page on how Authentication can be done.
16
client, err := getAccessClientWithBasicAuth("ENDPOINT-NAME", "TOKEN_GOES_HERE")
17
ctx := context.Background()
18
if err != null {
19
log.Fatalf("err: %v", err)
20
}
21
22
// Get Collection by ID
23
collectionId, err := hex.DecodeString("eb6733050812a58450310980032ea2fdbee8a7c5f6aad252abf1ef9d82fd8ff5")
24
collectionResp, err := client.GetCollectionByID(ctx, &access.GetCollectionByIDRequest{Id: collectionId})
25
respJSON, err := json.Marshal(collectionResp)
26
if err != null {
27
log.Fatal("get collection by ID failed: ", err)
28
}
29
fmt.Println("Get Collection by ID:", string(respJSON))
30
}
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free