Announcing Square’s New Python SDK
Tags: api, python, business, payments
Published: 2019-10-11 20:18:11

---
title: Announcing Square’s New Python SDK
published: true
description: Use the new Python SDK to integrate with Square APIs
tags: api,python,business,payments
canonical_url: https://developer.squareup.com/blog/announcing-squares-new-python-sdk
cover_image: https://images.ctfassets.net/1wryd5vd9xez/1U9eFmCSfdS7EJSdMKskIf/5c356a751f279c5bb65da58f08e2f0c2/thecorner_heroimage_python-sdk_v1_20190827.png?w=1458&h=400&q=100&fm=webp&fit=fill&bg=rgb%3A000000
---

We’re excited to announce the release of our new Python SDK. Run your business with Square APIs including Catalog, Customers, Employees, Inventory, Labor, Locations, Orders, and more.

To install the Python SDK, just `pip install squareup` from the command line. You can alternatively clone the SDK from GitHub and install it using `python setup.py install --user `. Next, all you need to do is provide your access token and you’re ready to use Square APIs.

```python
from square.client import Client

client = Client(
    access_token='SANDBOX_ACCESS_TOKEN',
    environment='sandbox',
)

api_locations = client.locations
result = api_locations.list_locations()
```

One of the great features in the new Python SDK is that the `response` object contains new rich information about both the request and response. These details can be used for control flow and debugging.

Below are examples of checking the basic response status.

```
result.is_success()
#=> true

result.is_error()
#=> false

result.errors
#=> []

result.reason_phrase
#=> OK

result.status_code
#=> 200
```

If you were previously using the `squareconnect`  SDK, you might be wondering how `squareup` compares. Let’s take a look! For example, let’s create the following customer along with their address:

```python
customer = {
    "given_name": "Amelia",
    "family_name": "Earhart",
    "email_address": "Amelia.Earhart@example.com",
}
```

First, let’s look at how we used to create a customer with the legacy `squareconnect` SDK:

```python
from __future__ import print_function
 
import squareconnect
from squareconnect.rest import ApiException
from squareconnect.apis.customers_api import CustomersApi
 
api_instance = CustomersApi()
api_instance.api_client.configuration.host = "https://connect.squareupsandbox.com"
api_instance.api_client.configuration.access_token = "SANDBOX_ACCESS_TOKEN"
 
try:
   # ListLocations
   api_response = api_instance.create_customer({
     "given_name": "Amelia",
     "family_name": "Earhart",
     "email_address": "Amelia.Earhart@example.com",
   })
   print(api_response.customer)
```

For comparison, let’s create the same customer with the new squareup SDK:

```python
from square.client import Client
 
client = Client(
access_token='SANBOX_ACCESS_TOKEN',
environment='sandbox',
)
api_customers = client.customers
result = api_customers.create_customer({
 "given_name": "Amelia",
 "family_name": "Earhart",
 "email_address": "Amelia.Earhart@example.com",
})
print(result.body["customer"])
```

That’s all there is to it!

As you can see, the new `squareup` Python SDK interface is much simpler and less verbose. The new SDK also ships with a ton of usability and debugging features.

Give the `squareup` Python SDK a try today by installing it with `pip install squareup`.

With the new `squareup` SDK it’s easier than ever to use Square as a platform to run your business with Python. We can’t wait to see what you’ll build! If you have any questions or feedback, [drop by our developer community](https://squ.re/slack). We’d love to hear from you.