You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否通过Square Connect API按日期条件检索客户、订单及交易数据?

Hey there! Great question—yes, you absolutely can filter customer, order, and transaction data by date using the Square Connect APIs. Let's break this down for each endpoint you're asking about:

Filtering Customer Data by Date

First off, your example call is on the right track! The Customers API supports the begin_time and end_time query parameters to filter customers based on their creation timestamp.

Key Details:

  • The parameters require an ISO 8601 formatted timestamp in UTC (like 2016-01-15T00:00:00Z). Your example is almost perfect—just note the trailing Z is mandatory to denote UTC (your sample link misses it at the end of the end_time value).
  • This filters customers created between the begin_time (inclusive) and end_time (exclusive).

Example Request:

GET /v2/customers?begin_time=2016-01-15T00:00:00Z&end_time=2016-01-31T00:00:00Z

Keep in mind: If you get a large volume of results, you'll need to handle pagination using the cursor parameter returned in the response.

Filtering Order Data by Date

For orders, you'll use the SearchOrders endpoint (a POST request) instead of a simple GET. Date filters are defined in the request body's query object.

Key Details:

  • You can filter by either created_at or updated_at timestamps.
  • Use the date_time_filter object to set your start and end times (again, UTC ISO 8601 format is required).

Example Request Body:

{
  "location_ids": ["YOUR_LOCATION_ID"],
  "query": {
    "filter": {
      "date_time_filter": {
        "created_at": {
          "start_at": "2024-01-01T00:00:00Z",
          "end_at": "2024-01-31T23:59:59Z"
        }
      }
    }
  }
}

Pro Tip:

If you want to filter by when orders were updated instead of created, just replace created_at with updated_at in the date_time_filter object.

Filtering Transaction Data by Date

The Transactions API (specifically the ListTransactions endpoint) uses begin_time and end_time query parameters, similar to the Customers API, to filter transactions by their creation time.

Key Details:

  • Timestamps must be in UTC ISO 8601 format.
  • This filters transactions created between the begin_time (inclusive) and end_time (exclusive).

Example Request:

GET /v2/locations/YOUR_LOCATION_ID/transactions?begin_time=2024-01-01T00:00:00Z&end_time=2024-01-31T23:59:59Z

As with customers, pagination using the cursor parameter applies if you have more transactions than the default page limit.

General Notes:

  • Always use UTC timestamps to avoid timezone mismatches—Square's APIs operate exclusively in UTC.
  • Double-check your API permissions: Ensure your access token has the necessary scopes (like CUSTOMERS_READ, ORDERS_READ, PAYMENTS_READ) to retrieve this data.
  • If you run into issues, verify the timestamp format is exact (no typos, correct T and Z separators).

内容的提问来源于stack exchange,提问作者Rahul Nataraj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:55:28