/ client / rpc / README.md
README.md
 1  # `coreiface.CoreAPI` over http `rpc`
 2  
 3  > IPFS CoreAPI implementation using HTTP API
 4  
 5  This package implements [`coreiface.CoreAPI`](https://pkg.go.dev/github.com/ipfs/kubo/core/coreiface#CoreAPI) over the HTTP API.
 6  
 7  ## Documentation
 8  
 9  https://pkg.go.dev/github.com/ipfs/kubo/client/rpc
10  
11  ### Example
12  
13  Pin file on your local IPFS node based on its CID:
14  
15  ```go
16  package main
17  
18  import (
19  	"context"
20  	"fmt"
21  
22  	"github.com/ipfs/boxo/path"
23  	"github.com/ipfs/go-cid"
24  	"github.com/ipfs/kubo/client/rpc"
25  )
26  
27  func main() {
28  	// "Connect" to local node
29  	node, err := rpc.NewLocalApi()
30  	if err != nil {
31  		fmt.Println(err)
32  		return
33  	}
34  	// Pin a given file by its CID
35  	ctx := context.Background()
36  	c, err := cid.Decode("bafkreidtuosuw37f5xmn65b3ksdiikajy7pwjjslzj2lxxz2vc4wdy3zku")
37  	if err != nil {
38  		fmt.Println(err)
39  		return
40  	}
41  	p := path.FromCid(c)
42  	err = node.Pin().Add(ctx, p)
43  	if err != nil {
44  		fmt.Println(err)
45  		return
46  	}
47  }
48  ```