일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- solvesql
- airflow 설치
- hackerrank
- SQLite
- join
- 프로그래머스
- 그로스해킹
- TRUNCATE
- pandas
- 데이터분석
- matplotlib
- 데이터리안 웨비나
- SUM
- 전처리
- seaborn
- airflow.cfg
- having
- 결측값
- 파이썬
- Round
- SQL
- not in
- 머신러닝
- Limit
- GROUPBY
- 데이터시각화
- PostgreSQL
- 다중 JOIN
- MySQL
- Oracle
Archives
- Today
- Total
Milky's note
[Google Ads] API 버전 업그레이드 본문
프로젝트에서 Google Ads API를 호출하여 데이터를 전처리하는 부분이 있다.
OAuth로 인증받고
로직 잘 돌아가고 있었는데 갑자기 아래와 같은 메일이 왔다 !!
![](https://t1.daumcdn.net/keditor/emoticon/niniz/large/020.gif)
그리고 Airflow에서 2월 5일이 되자마자 오류가 발생하였다.ㅠㅠ
v16이 지원이 중단 되었다고 한다.
<_SingleThreadedRendezvous of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "UNKNOWN:Error received from peer ipv4:199.36.153.8:443 {created_time:"2025-02-05T01:30:16.346757668+00:00", grpc_status:3, grpc_message:"Request contains an invalid argument."}"
>
errors {
error_code {
request_error: UNSUPPORTED_VERSION
}
message: "Version v16 is deprecated. Requests to this version will be blocked."
}
더보기
참고로 위 IP (199.36.153.8)는
온프레미스 호스트의 비공개 Google 액세스를 사용하기 위한 특수 도메인이다 !
https://cloud.google.com/vpc/docs/configure-private-google-access-hybrid?hl=ko
오류가 발생한 호출 코드는 다음과 같다.
googleads_client = GoogleAdsClient(developer_token=developer_token, credentials=credentials)
gads_service = googleads_client.get_service("GoogleAdsService")
adgroup_query = f"""
SELECT
ad_group.id,
ad_group.name,
ad_group.campaign,
segments.ad_network_type,
metrics.impressions,
metrics.clicks
FROM ad_group
WHERE segments.date BETWEEN '{dashboard}' AND '{dashboard}'
ORDER BY ad_group.id"""
adgroups = []
adgroup_stream = gads_service.search_stream(customer_id=customer_id, query=adgroup_query)
for batch in adgroup_stream:
for row in batch.results:
adgroup = {
"campaign_id": row.ad_group.campaign,
"adgroup_id": row.ad_group.id,
"adgroup_name": row.ad_group.name,
"network": row.segments.ad_network_type,
"impressions": row.metrics.impressions,
"clicks": row.metrics.clicks
}
adgroups.append(adgroup)
adgroup_df = pd.DataFrame(adgroups)
혹시나 v16까지 지원되는 dimension이나 metrics이 있는지 docs부터 확인하였지만
v18에도 모두 지원되는 값들이었다.
계속 감을 못 잡고 있었는데 google ads api의 버전 업그레이드는 아래처럼
호출해주는 부분에 버전만 기재해주면 된다 !!!!
googleads_client = GoogleAdsClient(developer_token=developer_token, credentials=credentials)
gads_service = googleads_client.get_service("GoogleAdsService", version="v18")
생각보다 ,,, 넘 간단,,,
찾아보니까 google ads api의 수명은 12개월 정도이다.
그래서 업데이트가 다른 api 수명에 비해 잦은 편이고 그에 맞춰서 노티가 오면 버전을 수정해주면 된다 !
물론 버전을 업그레이드 해도 오류가 발생한다면,
더이상 지원하지 않는 파라미터들이니 docs를 참고해서 대체하는 값으로 바꿔주면 된다 !!!!!
'Python > API Connect' 카테고리의 다른 글
[Meta Ads] Meta(Facebook) Marketing API 연결 (7) | 2024.05.13 |
---|---|
Google Analystic4(GA4) API 연결 (GCP 환경) (1) | 2024.04.30 |
🛠 [LinkedIn Ads] Advertising API 호출하기! (0) | 2024.03.12 |
Comments