GitHub의 googleads/googleads-shopping-samples 저장소에는 각 클라이언트 라이브러리의 일반적인 작업에 관한 샘플 코드가 포함되어 있습니다. 예를 들어 googleads-shopping-samples/python/shopping/content/products/의 샘플은 Python으로 products 리소스를 사용하는 일반적인 작업의 코드를 제공합니다. 이 가이드에서는 빈 파일로 시작하여 새 제품을 삽입하는 예시를 빌드하여 콘텐츠 API와 통합되는 애플리케이션의 기본 구조와 필수 구성요소를 확인할 수 있습니다. 최종 결과는 products/insert.py 샘플 파일의 예와 비슷합니다. 그런 다음 products.list 메서드의 API 탐색기를 사용하여 제품이 성공적으로 추가되었는지 확인할 수 있습니다.
첫 번째 통화를 걸려면 다음 단계를 완료하세요.
- googleads-shopping-samples/python/shopping/content/products/ 디렉터리에서 빈 my-insert.py 파일을 만듭니다. 다음 단계의 코드를 모두 이 파일에 추가합니다. 
- 필수 모듈의 가져오기 문을 추가합니다. - my-insert.py 시작 부분에 다음 코드를 추가합니다. - from __future__ import print_function import sys # The common module provides setup functionality used by the samples, # such as authentication and unique id generation. from shopping.content import common
- 고유한 제품 ID를 정의하고 제품 정의가 포함된 딕셔너리를 만듭니다. - my-insert.py 끝에 다음 코드를 추가합니다. - offer_id = 'book#%s' % common.get_unique_id() product = { 'offerId': offer_id, 'title': 'A Tale of Two Cities', 'description': 'A classic novel about the French Revolution', 'link': 'http://my-book-shop.com/tale-of-two-cities.html', 'imageLink': 'http://my-book-shop.com/tale-of-two-cities.jpg', 'contentLanguage': 'en', 'targetCountry': 'US', 'channel': 'online', 'availability': 'in stock', 'condition': 'new', 'googleProductCategory': 'Media > Books', 'gtin': '9780007350896', 'price': { 'value': '2.50', 'currency': 'USD' }, 'shipping': [{ 'country': 'US', 'service': 'Standard shipping', 'price': { 'value': '0.99', 'currency': 'USD' } }], 'shippingWeight': { 'value': '200', 'unit': 'grams' } }
- 명령줄에서 스크립트를 실행할 때 실행되는 함수를 만듭니다. 이 함수는 Content API와 상호작용하는 서비스 객체를 구성하고, 구성 파일에서 판매자 ID를 가져오고, 요청을 구성하고, API 호출을 실행하기 위해 요청을 실행합니다. - my-insert.py 끝에 다음 코드를 추가합니다. - def main(argv): # Construct the service object to interact with the Content API. service, config, _ = common.init(argv, __doc__) # Get the merchant ID from merchant-info.json. merchant_id = config['merchantId'] # Create the request with the merchant ID and product object. request = service.products().insert(merchantId=merchant_id, body=product) # Execute the request and print the result. result = request.execute() print('Product with offerId "%s" was created.' % (result['offerId'])) # Allow the function to be called with arguments passed from the command line. if __name__ == '__main__': main(sys.argv)
- 스크립트를 실행하고 API 호출을 실행하려면 터미널 창에서 googleads-shopping-samples/python/으로 이동하여 다음을 실행합니다. - python -m shopping.content.products.my-insert- 호출이 성공하면 서비스에서 터미널에 다음 메시지를 출력합니다. offerId가 'offerId'인 제품이 생성되었습니다. 
- 제품이 성공적으로 추가되었는지 확인하려면 - products.list메서드의 API 탐색기를 사용하여 판매자 센터 계정의 모든 제품을 반환합니다.- products.list메서드의 API 탐색기에 다음 값을 입력합니다.- merchantId를 입력합니다.
 - 사용자 인증 정보 섹션에서 Google OAuth 2.0 및 API 키를 선택합니다.
- 실행 버튼을 클릭합니다.
- 메시지가 표시되면 판매자 센터 계정과 연결된 Google 계정으로 로그인합니다.
 - 제품이 성공적으로 추가되면 제품 데이터가 API 탐색기 응답에 표시됩니다. 
판매자는 쇼핑 광고 및 무료 등록정보 정책을 준수해야 합니다. Google 쇼핑은 이러한 정책을 시행하고 정책을 위반하는 콘텐츠나 행동을 발견할 경우 적절하게 대응할 권리를 보유합니다.