To retrieve Google Ads API entities and reporting data, use one of these methods:
Вот основные отличия этих двух методов:
| GoogleAdsService.SearchStream | GoogleAdsService.Search | |
|---|---|---|
| Подходит для производственного кода | Да | Да |
| Услуга | GoogleAdsService | GoogleAdsService |
| Сценарий | Fetching objects and reports | Получение объектов и отчетов |
| Ответ | Поток объектов GoogleAdsRow | Pages of GoogleAdsRow objects |
| Поля ответа | Только те, которые указаны в запросе. | Только те, которые указаны в запросе. |
| Дневные лимиты | Суточные лимиты зависят от уровня доступа. | Суточные лимиты зависят от уровня доступа. |
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.
В случае с SearchStream загрузка пакетов данных начинается немедленно, а весь результат кэшируется в буфере данных. Ваш код может начать чтение буферизованных данных, не дожидаясь завершения всего потока.
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.
Пример
This example looks at a report that consists of 100,000 rows. The following table breaks down the accounting differences between the two methods.
| SearchStream | Поиск | |
|---|---|---|
| Размер страницы | Непригодный | 10,000 rows per page |
| Number of API requests | 1 request | 10 запросов |
| Количество ответов API | 1 непрерывный поток | 10 ответов |
Факторы производительности
В большинстве случаев мы рекомендуем SearchStream вместо Search по следующим причинам:
For single page reports (under 10,000 rows): No significant performance differences between the two methods.
Для отчетов, содержащих несколько страниц:
SearchStreamобычно работает быстрее, поскольку исключается множество обращений к серверу, а чтение или запись из дискового кэша оказывают меньшее влияние.
Ограничения скорости
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.