Code Monkey home page Code Monkey logo

btcpayserver-go's Introduction

Go library for BTCPayServer API

https://btcpayserver.org/

This is a go library for interacting with the BTCPayServer api.

API https://docs.btcpayserver.org/API/Greenfield/v1/

Install

go get github.com/negasus/btcpayserver-go

Usage

Create a new client with your server address and access token.

client := btcpayserver.New("server address", "token")

Use the client to interact with the api.

client.APIKeys.GetCurrent()
client.Invoices.Get(storeID, invoiceID)
client.Webhooks.Delete(storeID, webhookID)

etc...

Serve Webhooks

package main

import (
    "context"
    "fmt"
    "net"
	"os"
	"os/signal"
    
    "github.com/negasus/btcpayserver-go"
    "github.com/negasus/btcpayserver-go/models"
)

func main() {
	client := btcpayserver.New("server address", "token")

	ln, errLn := net.Listen("tcp", ":2000")
	if errLn != nil {
		panic(errLn)
	}
	defer ln.Close()

	ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
	defer cancel()

	webhookSecret := "123"

	err := client.Webhooks.Serve(ctx, ln, webhookSecret, handler)
	if err != nil {
		panic(err)
	}
}

func handler(event *models.WebhookEvent) {
	fmt.Printf("Got webhook event: %+v\n", event)
}

Status

At the moment, a small part of the methods has been implemented. I will be adding more methods as I need them. If you need a method that is not implemented, feel free to open an issue or a pull request.

btcpayserver-go's People

Contributors

negasus avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.