Square eCommerce APIs

Learn how Square APIs can be used to create custom eCommerce solutions.

Link to section

Overview

Square eCommerce APIs in the Square Developer platform are building blocks for online marketplaces. By connecting various features and services, developers can create seamless shopping experiences for any business type.

Square APIs for eCommerce solutions offer:

  • Scalability for businesses to easily expand their online presence and offerings.
  • Flexible online experiences that meet specific needs of different businesses.
  • Comprehensive functionality through the integration of various Square products and services.
Link to section

Square Online store

Sellers use the Square Online eCommerce platform to build and launch an online store. Square Online integrates with Square Point of Sale, enabling sellers to keep online and in-person orders, items, and inventory in sync — all in one place. Square Online checkouts use Payment Links for PCI-DSS compliant payment processing and provide free fraud protection and payment dispute management.

Square partner integrations are also available to help sellers with shipping and other eCommerce needs. Learn more or see all eCommerce apps available in the App Marketplace.

Link to section

Common eCommerce API integrations

Developers can integrate Square features into their eCommerce solutions by calling RESTful Square APIs directly, using language-based platform SDKs, or sending Square GraphQL queries. Square also provides online and mobile payment SDKs. Many Square APIs have built-in integrations with other APIs that you can leverage in your custom solutions.

Link to section

Payment processing

All eCommerce solutions need some way to accept online payments. Square provides options that support low code to advanced customizations and support one-time or recurring payments securely processed by Square.

Online payment APIs and SDKs options include:

Link to section

Order management

Order management features help streamline and automate efficient end-to-end order processing. Key features include building orders for the cart, inventory control, and helping coordinate workflows for picking, packing, and shipping order fulfillments.

The Orders API is the primary API for managing the order lifecycle. Combine the Orders API with other APIs to build custom order management functionality:

  • Catalog API - Include detailed itemization and automatic taxes and discounts, with built-in Inventory API integration that automatically updates inventory levels for catalog item variations.
  • Payments API and Refunds API - Automatically update order details, including payment and refund history with detailed transaction information.
  • Customers API and other customer engagement features - Facilitate customer service requests, inform customer analytics, and implement loyalty and gifting programs.
Link to section

Inventory control

Use the Inventory API to manage and track product inventory levels in real-time, helping to prevent stockouts and overstocking.

The Inventory API is the primary API for inventory control, including updating and tracking inventory changes and retrieving inventory counts. The Inventory API is used with the following APIs:

  • Catalog API - Manage the product catalog. Inventory quantities are tracked on item variations in the catalog.
  • Orders API - Automatically update inventory levels for item variations sold or returned in an order.
  • Locations API - Find stock availability for in-person pickups.
Link to section

Customer engagement

Engaged customers are more likely to make purchases and often spend more. Regular engagement can build strong customer relationships that improve customer retention and increase referrals.

The Customers API is the primary API for customer relationship management (CRM). Combine the Customers API with other APIs for custom engagement strategies:

Link to section

Recurring payments with subscriptions

Subscriptions offer a convenient recurring delivery of products or services to customers as well as a consistent and predictable revenue stream for businesses with automated payments.

The Subscriptions API is the primary API for managing subscriptions. It's used with the following APIs:

  • Catalog API - Configure the subscription plan and plan variation.
  • Orders API - Create optional order templates for recurring orders for catalog items.
  • Customers API - Allow customers to enroll in subscriptions.
Link to section

Square APIs for eCommerce

Square APIs can be used for eCommerce, brick and mortar businesses, or both. Understanding the purpose and functionality of API capabilities can help you create a comprehensive eCommerce solution using multiple APIs.

Process online payments securely — from instant payment links to recurring billing for subscription-based products and services — with support for various payment methods, acceptance flows, and levels of coding and customization.

Online Payment APIs and SDKs

tab-image
Link to section

Security considerations

Security is a critical concern for eCommerce API integrations. While many security features are built into Square APIs, developers must ensure that their calls to API endpoints are secure and data is encrypted both in transit and at rest. To prevent common security threats, developers should:

  • Use HTTPS to prevent man-in-the-middle attacks.
  • Apply strict input validation to protect against SQL injection and XSS.
  • Keep access tokens, application credentials, and sensitive data secure and out of the codebase and use environment variables or secrets management tools.

For more information, see:

Link to section

Performance optimization

To ensure fast and reliable API performance:

  • Implement caching strategies to reduce the load on API servers.
  • When possible, use batch and bulk requests to minimize the number of API calls.
  • Optimize API calls by requesting only the data needed and reducing payload size. Consider integrating Square GraphQL queries to minimize data transfer requests.
  • Subscribe for webhook notifications to reduce the need for polling.
Link to section

Error handling and debugging

Effective error handling and debugging are crucial for maintaining a functional eCommerce API integration. Developers should:

  • Implement comprehensive error logging to track and resolve issues promptly.
  • Monitor responses for 429 RATE_LIMITED errors and use a retry mechanism with an exponential backoff schedule to resend the requests at an increasingly slower rate. It's also a good practice to use a randomized delay (jitter) in your retry schedule.
  • Use debugging tools and monitor API response codes to identify and fix errors. For example, use API logs to view the logs of the API calls from your application.
Link to section

API testing

API testing ensures that integrations work as expected and can handle various scenarios. Developers should conduct:

  • Unit tests to validate individual API functions.
  • Integration tests to ensure APIs work together seamlessly.
  • End-to-end tests to simulate real-world scenarios with different product catalogs.