Get Started with Square API

Get introduced to Square and Square API.

Square offers digital payments and financial services to its customers. The idea for Square was conceived by Jack Dorsey in order to help his friend, Jim McKelvey, complete some sales. Square helps businesses of almost all types to expand their outreach.

Square offers a wide range of business tools and equitable loans to its customers. They have a wide range of customers ranging from retail companies to beauty professionals. With a broad set of flexible tools, we only need to pay for the tools we need. They also work with third-party services to enhance our retail experience.

Square API

Square API is structured to cover almost all core business workflows. For example, creating customer records, taking orders, making payments, creating invoices, and issuing refunds.

Square provides a RESTful API. Therefore, whether you’re a beginner or you’ve ever worked with an API before, learning Square API should not be a problem.

In this course, we’ll look into the following Square APIs:

  • Merchants
  • Payments
  • Orders
  • Locations
  • Refunds
  • Invoices

Square developer account

Before we begin with the course, let’s first create a Square account that will enable us to test all Square APIs and start developing. To create a Square developer account, follow these steps:

  1. Go to Square Developer Sign up page, enter the required information (email, password, and the country where the account is being created) and then click “Continue.” Square creates an account and redirects to the Developer Dashboard.
  2. On the Developer Dashboard, click the “+” (Plus) button to create an application.
  3. Enter the name of the application, “Test Application 1” for instance, in the “Application name” box and then click “Save.” It creates an application and opens the Applications page.
  4. The Applications page displays all the applications created so far, which is one in our case. Click the “Open” button associated with your application which redirects to the credentials page.
  5. Get the Access token by clicking the “Show” button under “Sandbox Access token.”

After getting the Access token, save it in the widget below. To do so:

  1. Click the “Edit” button in the following widget.
  2. Paste the value of the Access token in the field ACCESS_TOKEN.
  3. Click “Save.”

Just to check if everything is up and running, run the following code, which calls a simple endpoint of the Square API. Don’t worry about the code as of now; we’ll discuss this code in detail later in the course.

from square.client import Client
from pprint import pprint
client = Client(
access_token= '{{ACCESS_TOKEN}}',
environment='sandbox'
)
result = client.merchants.list_merchants()
if result.is_success():
pprint(result.body)
elif result.is_error():
pprint(result.errors)