Skip to main content
The Devices API allows you to retrieve and manage information about Square hardware devices, including Square Terminals and card readers.

Overview

The Devices client provides methods to:
  • List all devices associated with a merchant
  • Retrieve details about a specific device
  • View device components (battery, WiFi, card reader, etc.)

Client Initialization

import (
    "context"
    "github.com/square/square-go-sdk/v3"
    "github.com/square/square-go-sdk/v3/core"
)

client := square.NewClient(
    &core.RequestOptions{
        Token: "YOUR_ACCESS_TOKEN",
    },
)

Methods

List Devices

Retrieves a list of devices associated with the merchant. Currently, only Terminal API devices are supported.
devices/client/client.go
request := &square.ListDevicesRequest{
    Cursor:     square.String("cursor_value"),
    SortOrder:  square.SortOrderDesc.Ptr(),
    Limit:      square.Int(10),
    LocationID: square.String("LOCATION_ID"),
}

response, err := client.Devices.List(context.TODO(), request)
if err != nil {
    // Handle error
}

for _, device := range response.Devices {
    fmt.Printf("Device: %s (Type: %s)\n", *device.Attributes.Name, device.Attributes.Type)
}
cursor
*string
A pagination cursor from a previous call. Provide this to retrieve the next set of results.
sort_order
*SortOrder
The order in which results are listed:
  • ASC: Oldest to newest
  • DESC: Newest to oldest (default)
limit
*int
The number of results to return in a single page
location_id
*string
If present, only returns devices at the target location
devices
[]*Device
Array of device objects

Get Device

Retrieves details about a specific device.
devices/client/client.go
request := &square.GetDevicesRequest{
    DeviceID: "DEVICE_ID",
}

response, err := client.Devices.Get(context.TODO(), request)
if err != nil {
    // Handle error
}

device := response.Device
fmt.Printf("Device Name: %s\n", *device.Attributes.Name)
fmt.Printf("Manufacturer: %s\n", device.Attributes.Manufacturer)
fmt.Printf("Model: %s\n", *device.Attributes.Model)

// Check device status
if device.Status != nil && device.Status.Category != nil {
    fmt.Printf("Status: %s\n", *device.Status.Category)
}

// Inspect components
for _, component := range device.Components {
    fmt.Printf("Component Type: %s\n", component.Type)
}
deviceID
string
required
The unique ID for the desired device
device
Device
The requested device object

Response Types

Device

Represents a Square hardware device.
id
string
A synthetic identifier for the device (generated from key device fields)
attributes
DeviceAttributes
required
A collection of attributes representing the device
components
[]*Component
List of components applicable to the device
status
DeviceStatus
The current operational status of the device

DeviceAttributes

type
DeviceType
required
The device type:
  • TERMINAL: A Square Terminal device
  • HANDHELD: A handheld device
manufacturer
string
required
The maker of the device (e.g., “Square”)
model
string
The specific model of the device
name
string
A seller-specified name for the device
manufacturers_id
string
The manufacturer-supplied identifier (often a serial number)
updated_at
string
The RFC 3339 timestamp of the most recent update to device information
version
string
The current version of software installed on the device

Component

Represents a device component (battery, WiFi, card reader, etc.).
type
ComponentType
required
The type of component:
  • APPLICATION: Software application
  • CARD_READER: Card reader hardware
  • BATTERY: Battery component
  • WIFI: WiFi interface
  • ETHERNET: Ethernet interface
  • PRINTER: Printer component
application_details
ApplicationDetails
Details for APPLICATION components
card_reader_details
CardReaderDetails
Details for CARD_READER components
battery_details
BatteryDetails
Details for BATTERY components
  • visible_percent: Battery percentage
  • external_power: Power connection status
wifi_details
WiFiDetails
Details for WIFI components
  • active: Whether WiFi is active
  • ssid: Network name
  • ip_address_v4: IPv4 address
  • signal_strength: Signal strength measurement
ethernet_details
EthernetDetails
Details for ETHERNET components
  • active: Whether Ethernet is active
  • ip_address_v4: IPv4 address

DeviceStatus

category
DeviceStatusCategory
The status category:
  • AVAILABLE: Device is available and operational
  • NEEDS_ATTENTION: Device requires attention
  • OFFLINE: Device is offline

Use Cases

Check Device Battery Status

response, err := client.Devices.Get(context.TODO(), &square.GetDevicesRequest{
    DeviceID: "DEVICE_ID",
})
if err != nil {
    log.Fatal(err)
}

for _, component := range response.Device.Components {
    if component.Type == square.ComponentComponentTypeBattery {
        if component.BatteryDetails != nil {
            fmt.Printf("Battery: %d%%\n", *component.BatteryDetails.VisiblePercent)
            if component.BatteryDetails.ExternalPower != nil {
                fmt.Printf("Power Status: %s\n", *component.BatteryDetails.ExternalPower)
            }
        }
    }
}

List Devices at a Specific Location

request := &square.ListDevicesRequest{
    LocationID: square.String("LOCATION_ID"),
    Limit:      square.Int(20),
}

response, err := client.Devices.List(context.TODO(), request)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Found %d devices\n", len(response.Devices))
for _, device := range response.Devices {
    fmt.Printf("- %s (Model: %s)\n", 
        *device.Attributes.Name,
        *device.Attributes.Model,
    )
}

Check Network Connectivity

response, err := client.Devices.Get(context.TODO(), &square.GetDevicesRequest{
    DeviceID: "DEVICE_ID",
})
if err != nil {
    log.Fatal(err)
}

for _, component := range response.Device.Components {
    switch component.Type {
    case square.ComponentComponentTypeWifi:
        if component.WifiDetails != nil && component.WifiDetails.Active != nil {
            if *component.WifiDetails.Active {
                fmt.Printf("WiFi: Connected to %s\n", *component.WifiDetails.Ssid)
                fmt.Printf("IP: %s\n", *component.WifiDetails.IPAddressV4)
            }
        }
    case square.ComponentComponentTypeEthernet:
        if component.EthernetDetails != nil && component.EthernetDetails.Active != nil {
            if *component.EthernetDetails.Active {
                fmt.Printf("Ethernet: Connected\n")
                fmt.Printf("IP: %s\n", *component.EthernetDetails.IPAddressV4)
            }
        }
    }
}

Error Handling

response, err := client.Devices.Get(context.TODO(), request)
if err != nil {
    // Check for API errors
    if response != nil && len(response.Errors) > 0 {
        for _, e := range response.Errors {
            fmt.Printf("Error: %s - %s\n", e.Category, e.Detail)
        }
    }
    return err
}

Build docs developers (and LLMs) love