There are three methods for retrieving entities and reporting data with the Google Ads API.
GoogleAdsService.SearchStream
GoogleAdsService.Search
- GET requests
This guide primarily focuses on streaming data from
GoogleAdsService
. Here are high-level distinctions
for the three data retrieval methods:
GoogleAdsService.SearchStream | GoogleAdsService.Search | GET requests | |
---|---|---|---|
Suitable for production code | Yes | Yes | No (for debugging only) |
Service | GoogleAdsService |
GoogleAdsService |
Resource specific services (for example, CampaignService ) |
Scenario | Fetching objects and reports | Fetching objects and reports | Fetching objects |
Response | Stream of GoogleAdsRow objects |
Pages of GoogleAdsRow objects |
One object (for example, Campaign ) |
Response's fields | Only those specified in the query | Only those specified in the query | All fields populated |
Daily limits | Daily limits based on access levels | Daily limits based on access levels | 1,000 requests per day |
SearchStream versus Search
While Search
can send multiple paginated
requests to download the entire report,
SearchStream
sends a single request
and initiates a persistent connection with the Google Ads API regardless of report size.
For SearchStream
, data packets start to download immediately with the entire
result cached in a data buffer. Your code can start reading the buffered data
without having to wait for the entire stream to finish.
By eliminating the round-trip network time required to request each individual
page of a Search
response, depending on your app, SearchStream
can offer
improved performance over paging, especially for bigger reports.
Example
Take a report that consists of 100,000
rows for example. The following
table breaks down the accounting differences between the two methods.
SearchStream | Search | |
---|---|---|
Page size | Not Applicable | 10,000 rows per page |
Number of API requests | 1 request | 10 requests |
Number of API responses | 1 continuous stream | 10 responses |
Performance factors
In general, we recommend SearchStream
over Search
for the following reasons.
For single page reports (under 10,000 rows): No significant performance differences between the two methods.
For multiple page reports:
SearchStream
is typically faster since multiple roundtrips are avoided and reading/writing from disk cache is less of a factor.
Rate limits
Daily limits for both methods adhere to the standard limits and access levels of your developer token. A single query or report is counted as one operation regardless of the result being paged or streamed.