DocumentationManage 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 v2 endpoints. They do not currently provide methods for communicating with v1 or OAuth endpoints.

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.

Generating client libraries and other tools with Swagger

Version 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 v1 and OAuth endpoints are not currently defined with Swagger.