Getting Started

Link to section

Prerequisites

Before you begin, ensure you have:

  1. A Square Developer account
  2. A Square application created in the Developer Console
  3. An access token (personal access token or OAuth token with REPORTING_READ scope)
  4. Basic familiarity with REST APIs and JSON
  5. A tool for making HTTP requests (cURL, Postman, or your preferred HTTP client)

Did you know?

New to Cube? The Reporting API is built on Cube's semantic layer. We explain all the key concepts (cubes, measures, dimensions) in this guide, but if you want to dive deeper, see the Cube documentation.

Note

  • OAuth Support: The Reporting API supports OAuth tokens with the REPORTING_READ permission. Personal access tokens are also supported for testing and development.
  • Security Best Practice: Never commit access tokens to source control. Use environment variables or secure secret management systems.
Link to section

Step 1: Set Up Your Environment

Store your access token as an environment variable:

# macOS/Linux export SQUARE_ACCESS_TOKEN="your_access_token_here" export SQUARE_API_BASE="https://connect.squareup.com/reporting" # Windows (PowerShell) $env:SQUARE_ACCESS_TOKEN="your_access_token_here" $env:SQUARE_API_BASE="https://connect.squareup.com/reporting"
Link to section

Step 2: Verify connectivity

Test your authentication by calling the metadata endpoint:

curl -X GET "${SQUARE_API_BASE}/v1/meta" \ -H "Authorization: Bearer ${SQUARE_ACCESS_TOKEN}" \ -H "Content-Type: application/json"

Expected response: A JSON object containing cubes, measures, dimensions, and segments.

If you receive a 403 Forbidden error, verify:

  • Your access token is correct
  • You're using a personal access token (not OAuth)
  • Your token has not expired
Link to section

Step 3: Explore available data

The /v1/meta response shows all available data, including views and cubes. Views are the recommended starting point — they combine data from multiple cubes into a simplified, curated interface.

Let's look at the Sales view:

curl -X GET "${SQUARE_API_BASE}/v1/meta" \ -H "Authorization: Bearer ${SQUARE_ACCESS_TOKEN}" | jq '.cubes[] | select(.name == "Sales") | {name, type, title, measures: [.measures[].name]}'

This command:

  1. Fetches metadata
  2. Filters to the Sales view
  3. Shows the view name and available measures

Sample output:

Note

Views vs Cubes: Views (like Sales) pre-join data from multiple cubes and pre-filter for common use cases. Cubes (like Orders) provide raw, granular access. For most reporting, start with views. See Metadata Discovery for details.

Link to section

Step 4: Run your first query

Let's query daily net sales for the last 30 days using the Sales view:

curl -X POST "${SQUARE_API_BASE}/v1/load" \ -H "Authorization: Bearer ${SQUARE_ACCESS_TOKEN}" \ -H "Content-Type: application/json" \ -d '{ "query": { "measures": ["Sales.net_sales"], "timeDimensions": [{ "dimension": "Sales.local_reporting_timestamp", "dateRange": "last 30 days", "granularity": "day" }] } }'

What this query does:

  • Measures: Calculates net_sales (gross sales minus discounts/returns)
  • Time Dimensions: Groups by day for the last 30 days
  • No segment needed: The Sales view automatically filters to closed (completed) orders
Link to section

Understanding the Response

Success response (HTTP 200):

Note

Note: Access your data via response.data.

Long-running query response (HTTP 200):

{ "error": "Continue wait" }

If you receive "Continue wait", the query is still processing. Retry the same request until you get results. This is expected behavior for complex queries.

Link to section

Step 5: Add dimensions for detailed breakdown

Let's break down sales by location name:

Response structure:

Notice how the Sales view gives you location_name directly — no need to look up location IDs separately.

Link to section

Step 6: Handle long-running queries

For queries that take time to process, implement retry logic:

Link to section

Using cURL with a retry loop

Link to section

Using Python

Link to section

Using JavaScript/Node.js

Link to section

Data freshness and propagation delay

Note

There is a delay between when a transaction occurs and when it appears in the Reporting API. Most cubes have approximately a 15-minute delay. Some cubes may offer faster freshness but might not be joinable with other cubes. Check the metadata endpoint (/v1/meta) for per-cube freshness details.

For real-time order data, use the Orders API instead.