Skip to main content

Square Go SDK

Go client library for the Square API. Build powerful payment and commerce solutions with type-safe Go.

Get Started →

Overview

The Square Go SDK provides convenient access to the Square API from Go applications. It offers a comprehensive set of client libraries for managing payments, orders, customers, inventory, and more.

Installation

Install the SDK and get set up in minutes

Quickstart

Create your first payment in under 5 minutes

API Reference

Explore the complete API surface

Authentication

Learn how to authenticate requests

Key Features

Complete API Coverage

Access all Square APIs through 30+ resource clients including Payments, Orders, Customers, Catalog, and more.

Automatic Pagination

Built-in iterator support makes it easy to work with paginated results without manual cursor management.

Smart Retries

Automatic retry logic with exponential backoff handles transient failures gracefully.

Webhook Verification

Verify webhook signatures to ensure events originate from Square.

Multiple Environments

Seamlessly switch between sandbox and production environments for testing and deployment.

Type Safety

Fully typed request and response models provide compile-time safety and excellent IDE support.

Context-Based Timeouts

Use Go’s context package for fine-grained timeout and cancellation control.

Flexible Configuration

Customize HTTP clients, retry behavior, and request options to fit your needs.

Requirements

This SDK requires Go version 1.18 or higher.

Quick Example

Here’s a simple example of creating a payment:
package main

import (
    "context"
    "fmt"

    "github.com/square/square-go-sdk"
    squareclient "github.com/square/square-go-sdk/client"
    "github.com/square/square-go-sdk/option"
)

func main() {
    client := squareclient.NewClient(
        option.WithToken("YOUR_ACCESS_TOKEN"),
    )
    
    response, err := client.Payments.Create(
        context.TODO(),
        &square.CreatePaymentRequest{
            IdempotencyKey: "4935a656-a929-4792-b97c-8848be85c27c",
            SourceID:       "CASH",
            AmountMoney: &square.Money{
                Amount:   square.Int64(100),
                Currency: square.CurrencyUsd.Ptr(),
            },
        },
    )

    if err != nil {
        fmt.Println(err)
        return
    }

    fmt.Println(response.Payment)
}

What’s Next?

Install the SDK

Get started by installing the Square Go SDK

Follow the Quickstart

Build your first integration step by step

Learn Core Concepts

Understand pagination, retries, and error handling

Explore the API

Browse the full API reference documentation

Support

Build docs developers (and LLMs) love