Streamline your application flow with fewer, faster, and more compact data transfers using Square GraphQL.
GraphQL queries can improve performance and reduce development time by letting you request exactly the data you need. GraphQL can be especially beneficial for resource-constrained mobile applications and in modern frontend development.
Square GraphQL features include:
- A standards compliant endpoint serving multiple Square graphs. One GraphQL query can retrieve data that requires multiple Square API calls.
- Support for OAuth access management.
- Support for testing in the Square Sandbox environment.
- A statically typed schema that enables developer tooling. You can view the schema documentation when you sign in to GraphQL Explorer.
Square GraphQL supports query operations only; mutations and subscriptions aren't supported. Applications can use both GraphQL for faster querying and Square APIs or Square SDKs for write operations. Note that Square SDKs cannot be used to send GraphQL queries.
Applications that use OAuth require specific READ permissions to access Square data in GraphQL queries. For more information, see Authorization process.
Rate limits are applied to Square GraphQL queries.
The API Logs feature in the Developer Console doesn't include GraphQL queries.
Not all Square APIs have corresponding GraphQL support. Supported graphs generally provide access to the same data as the corresponding Square APIs and might provide expanded direct access to referenced objects that cross API boundaries. However, supported graphs aren't always at parity with corresponding Square APIs.
The following are examples of how Square GraphQL support might differ from Square APIs:
- Deprecated fields might not be available.
- Compared to corresponding list or search endpoints, GraphQL might provide more or fewer filters.
- Only catalog and customer custom attributes are supported. Custom attributes for other objects (such as locations and orders) aren't currently accessible in GraphQL queries.
Although Square graphs are continually updated to reflect the latest version of the corresponding Square APIs, there might be exceptions. You should use the current schema as the source of truth for GraphQL support. You can view the schema in GraphQL Explorer or by using the introspection system, as shown in the following simple introspection query:
{ __schema { types { name description kind } } }For more information, see Introspection at graphql.org.
Square GraphQL supports query operations for the following Square graphs:
Entry points:
bookings
- Retrieves a merchant's bookings (appointments).bookingAvailability
- Retrieves information about time slots that can be booked.locationBookingProfiles
- Retrieves booking information for business locations, such as whether the location is enabled for booking.businessBookingProfile
- Retrieves booking information for a merchant, such as whether bookings are allowed and the cancellation policy.teamMemberBookingProfiles
- Retrieves booking information for team members, such as whether the team member is enabled for booking.
Entry point:
cardsOnFile
- Retrieves stored credit or debit cards that can be used for card-on-file payments.
Entry points:
cashDrawerShiftEvents
- Retrieves events for a specified cash drawer shift.cashDrawerShifts
- Retrieves cash drawer shifts for a specified location.
Entry points:
catalog
- Retrieves catalog objects of any type.catalogItems
- RetrievesITEM
andITEM_VARIATION
catalog object types.
Entry point:
customerCustomAttributeDefinitions
- Retrieves the definitions of custom attributes that can be applied to customer profiles. Only definitions that are visible to your application are returned.To retrieve custom attribute values that are set on customer profiles, query the
customers
entry point and include thecustomAttributes
field.
Entry point:
customers
- Retrieves customer profiles from the Customer Directory.
Entry point:
giftCards
- Retrieves gift cards. Gift card details include the gift card number (GAN), balance, state, and linked customers.
Entry point:
giftCardActivities
- Retrieves activities that represent changes to the balance or state of gift cards.
Entry points:
inventoryChanges
- Retrieves count, adjustment, and transfer-related changes to inventory items.inventoryCounts
- Retrieves the current count and state of inventory items.
Entry points:
breakTypes
- Retrieves the break types that can be added to a shift.shifts
- Retrieves a list of labor shifts.teamMemberWages
- Retrieves available wage types for team members. Wage types include the title and pay rate for jobs that team members can perform for a shift.workweekConfigs
- Retrieves the day of the week and hour of the day that a business starts the workweek. This information is used to calculate overtime pay.
Entry points:
loyaltyAccounts
- Retrieves loyalty accounts for customers who are enrolled in a loyalty program.loyaltyEvents
- Retrieves events that represent changes to the point balance of loyalty accounts.loyaltyProgram
- Retrieves the merchant's loyalty program.loyaltyPromotions
- Retrieves loyalty promotions associated with a loyalty program.loyaltyRewards
- Retrieves loyalty rewards that are used to redeem points for discounts.
Entry points:
currentMerchant
- Retrieves information about the merchant associated with the access token provided in the request. You can querycurrentMerchant
to get the merchant ID required by most queries.merchants
- Retrieves information about a specified merchant (seller).
Entry point:
orders
- Retrieves orders.
Entry point:
payments
- Retrieves payments.
Entry point:
payoutEntries
- Retrieves payout entries associated with payouts.payouts
- Retrieves payouts to a seller.
Entry point:
paymentRefunds
- Retrieves refunds.
Entry points:
subscriptions
- Retrieves subscriptions.subscriptionEvents
- Retrieves information about changes to subscriptions.
A graph provides similar read access to data as the corresponding Square API and might provide extended access to data that crosses API boundaries. For example, an orders
query can return the email address, phone number, and other attributes of the customer associated with the order. After signing in to GraphQL Explorer, you can browse the full schema in the Documentation Explorer pane.
The open-source GraphQL standard defines both a query language and a runtime that retrieves data using queries.
Square provides two endpoints where you can send GraphQL queries:
- For queries in the production environment, call:
https://connect.squareup.com/public/graphql
- For queries in the Sandbox test environment, call:
https://connect.squareupsandbox.com/public/graphql
Unlike Square API requests, a GraphQL query specifies the exact data to return from one or more supported graphs. For example, the following simple query gets the name and email address of customers for a specified seller:
{ customers( filter: { merchantId: { equalToAnyOf: ["<MERCHANT_ID>"] } } ) { nodes { givenName familyName emailAddress } } }
The data
object in the response contains the query results. A response can contain both data
with partial query results and errors
with any errors encountered while processing the query.
To get started with Square GraphQL:
Build and send queries in GraphQL Explorer. Just sign in, choose your access token, and send sample queries or write your own from scratch. For a feature overview and setup steps, see GraphQL Explorer.
Explore our documentation:
- Read about concepts, patterns, and other GraphQL basics.
- Learn how to use the find available data and valid syntax in the schema as you build your first query in GraphQL Explorer.
- Check out some query examples for common scenarios.
Try our samples, which include scripts to upload test data to your Square account:
- Run built-in queries with the Square and GraphQL - Code Example (Node.js) sample application.
- See GraphQL used in a real-world scenario in the Square Dev GraphQL and PKCE Example Application (React Native) mobile application.
Send queries to Square GraphQL endpoints using third-party tools, such as Postman and GraphiQL. For example, the following cURL query retrieves an order and the customer who made the order:
curl https://connect.squareupsandbox.com/public/graphql \ -X POST \ -H 'Authorization: Bearer <ACCESS_TOKEN>' \ -H 'Content-Type: application/json' \ -d '{ "query": "{ orders( filter: { id: { equalToAnyOf: [\"<ORDER_ID>\"]} merchantId: { equalToAnyOf: [\"<MERCHANT_ID>\"]}}) { nodes { state updatedAt customer { id emailAddress }}}}" }'
Most queries require that you filter by a merchant ID. If you need to get the ID of the merchant (seller) associated with the access token, query currentMerchant
for the id
field.
{ currentMerchant { id } }