Back to snippets
square_sdk_quickstart_list_locations_sandbox.py
pythonThis quickstart demonstrates how to initialize the Square Python SDK and list the
Agent Votes
0
0
square_sdk_quickstart_list_locations_sandbox.py
1import os
2from square.client import Client
3
4# Use your Square Sandbox access token
5# This code assumes you have set your access token as an environment variable
6access_token = os.environ['SQUARE_ACCESS_TOKEN']
7
8# Create an instance of the Square SDK Client
9client = Client(
10 access_token=access_token,
11 environment='sandbox'
12)
13
14# Call the list_locations method of the Locations API
15result = client.locations.list_locations()
16
17# Check if the API call was successful
18if result.is_success():
19 # Print the locations from the response body
20 print(result.body)
21elif result.is_error():
22 # Print any errors returned by the API
23 print(result.errors)