Để thảo luận và đưa ra ý kiến phản hồi về các sản phẩm của chúng tôi, hãy tham gia kênh Discord chính thức của Google Ads trong máy chủ Cộng đồng quảng cáo và đo lường của Google.
Mặc dù Search có thể gửi nhiều yêu cầu phân trang để tải toàn bộ báo cáo xuống, nhưng SearchStream sẽ gửi một yêu cầu duy nhất và bắt đầu một kết nối liên tục với API Google Ads bất kể kích thước báo cáo.
Đối với SearchStream, các gói dữ liệu sẽ bắt đầu tải xuống ngay lập tức và toàn bộ kết quả sẽ được lưu vào bộ nhớ đệm trong một vùng đệm dữ liệu. Mã của bạn có thể bắt đầu đọc dữ liệu được lưu vào bộ nhớ đệm mà không cần phải đợi toàn bộ luồng hoàn tất.
Bằng cách loại bỏ thời gian khứ hồi cần thiết để yêu cầu từng trang riêng lẻ của một phản hồi Search, tuỳ thuộc vào ứng dụng của bạn, SearchStream có thể mang lại hiệu suất cao hơn so với phân trang, đặc biệt là đối với các báo cáo lớn hơn.
Ví dụ:
Ví dụ này xem xét một báo cáo có 100,000 hàng. Bảng sau đây trình bày chi tiết sự khác biệt về kế toán giữa hai phương pháp này.
SearchStream
Tìm kiếm
Kích thước trang
Không áp dụng
10.000 hàng mỗi trang
Số lượng yêu cầu API
1 yêu cầu
10 yêu cầu
Số lượng phản hồi của API
1 luồng phát liên tục
10 câu trả lời
Các yếu tố ảnh hưởng đến hiệu suất
Đối với hầu hết các trường hợp sử dụng, bạn nên dùng SearchStream thay vì Search vì những lý do sau:
Đối với báo cáo một trang (dưới 10.000 hàng): Không có sự khác biệt đáng kể về hiệu suất giữa hai phương thức.
Đối với báo cáo nhiều trang: SearchStream thường nhanh hơn vì tránh được nhiều chuyến khứ hồi và việc đọc hoặc ghi từ bộ nhớ đệm trên ổ đĩa ít ảnh hưởng hơn.
Giới hạn số lượng yêu cầu
Hạn mức hằng ngày cho cả hai phương thức đều tuân theo hạn mức tiêu chuẩn và cấp truy cập của mã thông báo nhà phát triển. Một truy vấn hoặc báo cáo duy nhất được tính là một thao tác, bất kể kết quả được phân trang hay truyền trực tuyến.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-09-05 UTC."],[[["\u003cp\u003eThe Google Ads API offers two primary methods for retrieving data: \u003ccode\u003eSearchStream\u003c/code\u003e and \u003ccode\u003eSearch\u003c/code\u003e, both suitable for production environments and fetching objects and reports.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSearchStream\u003c/code\u003e delivers results as a continuous stream, ideal for large reports, while \u003ccode\u003eSearch\u003c/code\u003e provides paginated responses.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSearchStream\u003c/code\u003e often offers performance advantages by reducing network round trips, especially for reports exceeding 10,000 rows.\u003c/p\u003e\n"],["\u003cp\u003eBoth methods are subject to the same daily limits and access levels, with a single query or report counting as one operation regardless of the method.\u003c/p\u003e\n"],["\u003cp\u003eGoogle recommends using \u003ccode\u003eSearchStream\u003c/code\u003e for most use cases due to its performance benefits for larger reports.\u003c/p\u003e\n"]]],[],null,["# Report streaming using GoogleAdsService\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nTo retrieve Google Ads API entities and reporting data, use one of these methods:\n\n- [`GoogleAdsService.SearchStream`](/google-ads/api/reference/rpc/v21/GoogleAdsService/SearchStream)\n- [`GoogleAdsService.Search`](/google-ads/api/reference/rpc/v21/GoogleAdsService/Search)\n\nHere are the high-level distinctions for the two methods:\n\n| | GoogleAdsService.SearchStream | GoogleAdsService.Search |\n| Suitable for production code | **Yes** | **Yes** |\n| Service | [`GoogleAdsService`](/google-ads/api/reference/rpc/v21/GoogleAdsService) | [`GoogleAdsService`](/google-ads/api/reference/rpc/v21/GoogleAdsService) |\n| Scenario | Fetching objects and reports | Fetching objects and reports |\n| Response | **Stream** of [`GoogleAdsRow`](/google-ads/api/reference/rpc/v21/GoogleAdsRow) objects | Pages of [`GoogleAdsRow`](/google-ads/api/reference/rpc/v21/GoogleAdsRow) objects |\n| Response's fields | Only those specified in the query | Only those specified in the query |\n| Daily limits | Daily limits based on [access levels](/google-ads/api/docs/access-levels) | Daily limits based on [access levels](/google-ads/api/docs/access-levels) |\n|------------------------------|----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|\n\n`SearchStream` versus `Search`\n------------------------------\n\nWhile [`Search`](/google-ads/api/reference/rpc/v21/GoogleAdsService/Search) can send multiple\npaginated requests to download the entire report, [`SearchStream`](/google-ads/api/reference/rpc/v21/GoogleAdsService/SearchStream) sends a single request and\ninitiates a persistent connection with the Google Ads API regardless of report size.\n\nFor `SearchStream`, data packets start to download immediately with the entire\nresult cached in a data buffer. Your code can start reading the buffered data\nwithout having to wait for the entire stream to finish.\n\nBy eliminating the round-trip network time required to request each individual\npage of a `Search` response, depending on your app, `SearchStream` can offer\nimproved performance over paging, especially for bigger reports.\n\n### Example\n\nThis example looks at a report that consists of `100,000` rows. The following\ntable breaks down the accounting differences between the two methods.\n\n| | SearchStream | Search |\n| Page size | Not Applicable | 10,000 rows per page |\n| Number of API requests | 1 request | 10 requests |\n| Number of API responses | 1 continuous stream | 10 responses |\n|-------------------------|---------------------|----------------------|\n\n### Performance factors\n\nFor most use cases, we recommend `SearchStream` over `Search` for the following\nreasons:\n\n- For single page reports (under 10,000 rows): No significant performance\n differences between the two methods.\n\n- For multiple page reports: `SearchStream` is typically faster since multiple\n round trips are avoided, and reading or writing from disk cache is less of a\n factor.\n\n### Rate limits\n\nDaily limits for both methods adhere to the standard limits and [access\nlevels](/google-ads/api/docs/access-levels) of your developer token. A single query or report\nis counted as one operation regardless of the result being paged or streamed."]]