--- layout: default title: Golang SDK nav_order: 1 parent: SDK has_children: false permalink: /sdk/golang.html --- # Golang SDK ```go import "github.com/photon-storage/gw3-sdk-go" ``` ## Index - [Constants](<#constants>) - [type Client](<#type-client>) - [func NewClient(accessKey, accessSecret string) (*Client, error)](<#func-newclient>) - [func (c *Client) AuthDAGAdd(root, filePath string, size int) (string, error)](<#func-client-authdagadd>) - [func (c *Client) AuthDAGImport(size int, boundary string) (string, error)](<#func-client-authdagimport>) - [func (c *Client) AuthDAGRemove(root, filePath string) (string, error)](<#func-client-authdagremove>) - [func (c *Client) AuthPost(size int) (string, error)](<#func-client-authpost>) - [func (c *Client) CreateIPNS(value string) (string, error)](<#func-client-createipns>) - [func (c *Client) DAGAdd(root, path string, data []byte) (string, error)](<#func-client-dagadd>) - [func (c *Client) DAGImport(src any) (string, error)](<#func-client-dagimport>) - [func (c *Client) DAGRemove(root, path string) (string, error)](<#func-client-dagremove>) - [func (c *Client) Get(cid string) ([]byte, error)](<#func-client-get>) - [func (c *Client) GetIPNS(name string) ([]byte, error)](<#func-client-getipns>) - [func (c *Client) Pin(cid string) error](<#func-client-pin>) - [func (c *Client) Post(data []byte) (string, error)](<#func-client-post>) - [func (c *Client) Unpin(cid string) error](<#func-client-unpin>) - [func (c *Client) UpdateIPNS(name, value string) error](<#func-client-updateipns>) ## Constants ```go const ( EmptyDAGRoot = "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" ) ``` ## type [Client]() Client represents a Gateway3 client for interacting with the Gateway3. ```go type Client struct { // contains filtered or unexported fields } ``` ### func [NewClient]() ```go func NewClient(accessKey, accessSecret string) (*Client, error) ``` NewClient creates a new Gateway3 client with the provided access key and access secret. ### func \(\*Client\) [AuthDAGAdd]() ```go func (c *Client) AuthDAGAdd(root, filePath string, size int) (string, error) ``` AuthDAGAdd requests Gateway3 for an authorized redirect URL for subsequently adding a new CID and path to the existing dag. ### func \(\*Client\) [AuthDAGImport]() ```go func (c *Client) AuthDAGImport(size int, boundary string) (string, error) ``` AuthDAGImport requests Gateway3 for an authorized redirect URL for uploading a CAR file. ### func \(\*Client\) [AuthDAGRemove]() ```go func (c *Client) AuthDAGRemove(root, filePath string) (string, error) ``` AuthDAGRemove requests Gateway3 for an authorized redirect URL for subsequently removing a path from the existing dag, generating a new dag root. ### func \(\*Client\) [AuthPost]() ```go func (c *Client) AuthPost(size int) (string, error) ``` AuthPost gets the authorized URL from the Gateway3. ### func \(\*Client\) [CreateIPNS]() ```go func (c *Client) CreateIPNS(value string) (string, error) ``` CreateIPNS creates a new IPNS record and binds it to the given CID. This function should only be used for creating a new record. To update an existing IPNS record, use the UpdateIPNS interface. ### func \(\*Client\) [DAGAdd]() ```go func (c *Client) DAGAdd(root, path string, data []byte) (string, error) ``` DAGAdd adds a new CID and path to the existing dag, generating a new dag root. ### func \(\*Client\) [DAGImport]() ```go func (c *Client) DAGImport(src any) (string, error) ``` DAGImport imports the given src input as a CAR format and returns its root CID. The \`src\` can be a path to a directory, a byte array or a io.Reader. ### func \(\*Client\) [DAGRemove]() ```go func (c *Client) DAGRemove(root, path string) (string, error) ``` DAGRemove removes a path from the existing dag, generating a new dag root. ### func \(\*Client\) [Get]() ```go func (c *Client) Get(cid string) ([]byte, error) ``` Get retrieves data from the Gateway3 for the given CID. ### func \(\*Client\) [GetIPNS]() ```go func (c *Client) GetIPNS(name string) ([]byte, error) ``` GetIPNS retrieves data from the IPFS network using the given IPNS. ### func \(\*Client\) [Pin]() ```go func (c *Client) Pin(cid string) error ``` Pin requests Gateway3 to pin the given CID. ### func \(\*Client\) [Post]() ```go func (c *Client) Post(data []byte) (string, error) ``` Post uploads the given data to Gateway3 and returns the corresponding CID. ### func \(\*Client\) [Unpin]() ```go func (c *Client) Unpin(cid string) error ``` Unpin requests Gateway3 to unpin the given CID. ### func \(\*Client\) [UpdateIPNS]() ```go func (c *Client) UpdateIPNS(name, value string) error ``` UpdateIPNS updates the value for the IPNS record specified by the given name. Generated by [gomarkdoc]()