Menu Apps
Manage Apps

Connect API client libraries

Connect v2 client libraries are available for a selection of programming languages:

Setup instructions for these client libraries are below.

Client libraries provide methods for communicating with all V1 and V2 endpoints. They do not currently provide methods for communicating with the OAuth flow endpoints.

Alternatively, explore the APIs with Postman, or generate your own SDK using Swagger in any language.

PHP client library

Installation

The PHP client library is hosted on Packagist and is available for installation via Composer.

To add it to your project, first add the following dependency to your application's composer.json file:

{
  "require": {
    "square/connect": "*",
    <OTHER DEPENDENCIES>
  }
}

(You can also add this dependency by running php composer.phar require square/connect)

Then, download your application's dependencies by running:

php composer.phar install

Usage

To include the client library in your code, use the following require statement:

require 'vendor/autoload.php';

Sample implementation

This article walks you through using the PHP SDK to accept an ecommerce payment.

Additionally, source for the client library is available on Github. You can use this source to generate ApiGen reference for the library.

Ruby client library

Installation

The Ruby client library is available as a gem. To install it, run the following command:

gem install square_connect

Usage

To include the client library in your code, use the following require statement:

require 'square_connect'

Sample implementation

This article walks you through using the Ruby SDK to accept an ecommerce payment.

Additionally, source for the client library is available on Github. You can use this source to generate RDoc reference for the library.

.NET client library (C#)

Installation

The C# client library is available as a nuget package.

On Windows, run the following command from the Nuget Package Manager Console:

Install-Package Square.Connect

On Mac and Linux, run the following command:

nuget install Square.Connect

Usage

Include the installed Square.Connect.dll in your project, and use the following namespaces to include the client library in your code:

using Square.Connect.Api;
using Square.Connect.Client;
using Square.Connect.Model;

Sample implementation

A sample implementation that uses the C# client library is available on Github, as are documentation and source code.

Python client library

Installation

The Python client library is available as a pypi package. To install it, run the following command:

pip install squareconnect

Usage

To include the client library in your code, use the following import statement:

import squareconnect

Sample implementation

A sample implementation that uses the Python client library is available on Github, as are documentation and source code.

Java client library

Maven

The java client library is available as a maven dependency. To install it, edit your project's POM to include:

<dependency>
    <groupId>com.squareup</groupId>
    <artifactId>connect</artifactId>
    <version>2.1.0</version>
    <scope>compile</scope>
</dependency>

Gradle

If using Gradle, add this dependency to your project's build file:

compile "com.squareup:connect:2.1.0"

Usage and Sample implementation

Documentation and source code are available on Github.

Running Postman to explore APIs

Postman is an app for easy RESTful API exploration. Use our "Postman Collection" to try Square's Connect endpoints. Read our blog post on setting up Postman and configuring it with your API credentials.

Click Run in Postman below to explore our V1 and V2 API Collection.

Run in Postman

Generating client libraries and other tools with Swagger

Version 1 and 2 of the Connect API is defined with the Swagger specification. The definition is available on Github. You can use this definition to do any of the following:

  • Generate your own Connect client library for another language with the Swagger Code Generator
  • Import the definition into a REST tool such as Postman to simplify manual testing

Note that the OAuth flow endpoints are not currently defined with Swagger.

Was this page helpful?