Skip to content

Files

rpc

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 17, 2023
Sep 5, 2024
Nov 5, 2024
Apr 4, 2024
Aug 21, 2024
Nov 29, 2023
Nov 29, 2023
Jun 3, 2024
May 31, 2023
Dec 4, 2023
Nov 29, 2023
Mar 22, 2024
Oct 9, 2023
Dec 3, 2024
Nov 29, 2023
May 31, 2023
Aug 22, 2023
Aug 17, 2023
Feb 7, 2024
Nov 29, 2023
Dec 3, 2024

coreiface.CoreAPI over http rpc

IPFS CoreAPI implementation using HTTP API

This package implements coreiface.CoreAPI over the HTTP API.

Documentation

https://pkg.go.dev/github.com/ipfs/kubo/client/rpc

Example

Pin file on your local IPFS node based on its CID:

package main

import (
	"context"
	"fmt"

	"github.com/ipfs/boxo/path"
	"github.com/ipfs/go-cid"
	"github.com/ipfs/kubo/client/rpc"
)

func main() {
	// "Connect" to local node
	node, err := rpc.NewLocalApi()
	if err != nil {
		fmt.Println(err)
		return
	}
	// Pin a given file by its CID
	ctx := context.Background()
	c, err := cid.Decode("bafkreidtuosuw37f5xmn65b3ksdiikajy7pwjjslzj2lxxz2vc4wdy3zku")
	if err != nil {
		fmt.Println(err)
		return
	}
	p := path.FromCid(c)
	err = node.Pin().Add(ctx, p)
	if err != nil {
		fmt.Println(err)
		return
	}
}