Oligon Receipts is in private beta — request access.
SDKs
Go

Go SDK

Official Go client. Idiomatic: context.Context first, errors as values, options pattern. Zero deps beyond the standard library.

Install

go get github.com/oligon/receipts-go

Requires Go 1.22+.

Quickstart

package main
 
import (
    "context"
    "fmt"
    "log"
    "os"
 
    oligon "github.com/oligon/receipts-go"
)
 
func main() {
    client := oligon.NewClient(os.Getenv("OLIGON_API_KEY"))
 
    f, err := os.Open("receipt.jpg")
    if err != nil { log.Fatal(err) }
    defer f.Close()
 
    r, err := client.Extract(context.Background(), oligon.ExtractParams{
        File: f, Type: oligon.ReceiptTypeNFe,
    })
    if err != nil { log.Fatal(err) }
 
    fmt.Println(r.MerchantName, r.Total)
}

Configuration (With… options)

OptionDefaultDescription
WithBaseURL(url)https://api.receipts.oligontech.comOverride host.
WithTimeout(d)30sPer-request timeout.
WithMaxRetries(n)5Auto-retries on 429/5xx.
WithBackoff(min, max)300ms8sExponential window.
WithHTTPClient(c)new clientInject (proxies, mTLS, mocks).
WithAPIKey(k)When you prefer options-only.
WithHeader(k,v)Extra header on every request.

Pagination

err := client.ListReceipts(ctx, oligon.ListReceiptsParams{
    Type: oligon.ReceiptTypeNFe, Limit: 100,
}, func(r *oligon.Receipt) (bool, error) {
    fmt.Println(r.ID)
    return true, nil   // false to stop early
})

Or a single page with client.ListReceiptsPage(ctx, params).

Errors

import "errors"
 
r, err := client.Extract(ctx, params)
if err != nil {
    var rate *oligon.RateLimitError
    var auth *oligon.AuthError
    switch {
    case errors.As(err, &rate):
        time.Sleep(rate.RetryAfter)
    case errors.As(err, &auth):
        rotateKey()
    case oligon.IsRetryable(err):
        // back off and retry yourself
    default:
        return err
    }
}

Webhook verification

ok := oligon.VerifyWebhook(rawBody, r.Header.Get("X-Oligon-Signature"), secret)

Constant-time comparison via crypto/hmac.Equal.

Source

github.com/oligon/receipts-go (opens in a new tab)