Get Object Data via go-ipfs-http-client library

I am able to get traits of project using cURL as below

curl -X POST -u “projectId:projectSecreat” “

How to get same data via golang library

package main

import (






    ipfsApi "" // v0.1.0

    path ""


func main() {

    projectId := "1ylb...."

    projectSecret := "1f9...."

    httpClient := &http.Client{}

    httpApi, err := ipfsApi.NewURLApiWithClient("", httpClient)

    if err != nil {




    httpApi.Headers.Add("Authorization", "Basic "+basicAuth(projectId, projectSecret))

    //content := strings.NewReader("Infura IPFS - Getting started demo.")

    mypath := path.New("Qmb5zeyvU7ZpotLDzkUmSeMDA71MExp8eJyNeefGdoeA2x")

    files, err := httpApi.Object().Get(context.Background(), mypath)

    if err != nil {




    for i := 0; i < len(files.Links()); i++ {





func basicAuth(projectId, projectSecret string) string {

    auth := projectId + ":" + projectSecret

    return base64.StdEncoding.EncodeToString([]byte(auth))


This give me right number of links, how to get data which we receive via cURL from links object ?

A Node implements the Block interface so you can use RawData() to get the content:

However, if you are trying to download normal “unixfs” files from the API, you should use the UnixFS() functions not the Object ones.

You will need to cast the resulting files.Node into a files.File or files.Directory as needed, and then you can read stuff.