Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blockfrost/blockfrost-go
Golang SDK for Blockfrost.io
https://github.com/blockfrost/blockfrost-go
blockfrost cardano golang ipfs
Last synced: 3 months ago
JSON representation
Golang SDK for Blockfrost.io
- Host: GitHub
- URL: https://github.com/blockfrost/blockfrost-go
- Owner: blockfrost
- License: apache-2.0
- Created: 2021-09-13T09:09:45.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-02-19T11:36:02.000Z (11 months ago)
- Last Synced: 2024-09-30T08:02:24.125Z (4 months ago)
- Topics: blockfrost, cardano, golang, ipfs
- Language: Go
- Homepage:
- Size: 296 KB
- Stars: 23
- Watchers: 2
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Official Blockfrost SDK Client
[![Build status](https://github.com/blockfrost/blockfrost-go/actions/workflows/test.yml/badge.svg?branch=staging)](https://github.com/blockfrost/blockfrost-go/actions/workflows/test.yml)
[![Go report card](https://goreportcard.com/badge/github.com/blockfrost/blockfrost-go)](https://goreportcard.com/report/github.com/blockfrost/blockfrost-go)
[![GoDoc](https://godoc.org/github.com/blockfrost/blockfrost-go?status.svg)](https://godoc.org/github.com/blockfrost/blockfrost-go)## Getting started
To use this SDK, you first need to log in to [blockfrost.io](https://blockfrost.io), create your project and retrieve the API token.
## Installation
`blockfrost-go` can be installed through go get
```console
$ go get https://github.com/blockfrost/blockfrost-go
```## Usage
### Cardano API
```go
package mainimport (
"context"
"fmt"
"log""github.com/blockfrost/blockfrost-go"
)func main() {
api, err := blockfrost.NewAPIClient(
blockfrost.APIClientOptions{
ProjectID: "YOUR_PROJECT_ID_HERE", // Exclude to load from env:BLOCKFROST_PROJECT_ID
},
)
if err != nil {
log.Fatal(err)
}info, err := api.Info(context.TODO())
if err != nil {
log.Fatal(err)
}fmt.Printf("API Info:\n\tUrl: %s\n\tVersion: %s", info.Url, info.Version)
}
```### IPFS
```go
package mainimport (
"context"
"flag"
"fmt"
"log""github.com/blockfrost/blockfrost-go"
)var (
fp = flag.String("file", "", "Path to file")
)func main() {
flag.Parse()
// Load project_id from env:BLOCKFROST_IPFS_PROJECT_ID
ipfs := blockfrost.NewIPFSClient(blockfrost.IPFSClientOptions{})ipo, err := ipfs.Add(context.TODO(), *fp)
if err != nil {
log.Fatal(err)
}fmt.Printf("IPFS Object: %+v\n", ipo)
// Pin item to avoid being garbage collected.
pin, err := ipfs.Pin(context.TODO(), ipo.IPFSHash)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Pin: %+v", pin)
}
```More examples of usage can be found in [`example`](https://github.com/blockfrost/blockfrost-go/tree/master/example) folder.
## Developing
To run specific test:
```
go test -run
```To run all tests:
```
make test
```## License
Licensed under the [Apache License 2.0](https://opensource.org/licenses/Apache-2.0), see [`LICENSE`](https://github.com/blockfrost/blockfrost-go/blob/master/LICENSE)