-
-
Save thornewolf/01e3652b8355192b2d73c3e623006e9e to your computer and use it in GitHub Desktop.
Product Studio TiDe API Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import pprint | |
| API_KEY = 'YOUR-API-KEY' # @param {type: "string"} | |
| PROJECT = 'YOUR-GCP-PROJECT' # @param {type: "string"} | |
| URI = f'https://productstudio.googleapis.com/v1/projects/{PROJECT}' | |
| API_ENDPOINT = f'{URI}:generateProductText' | |
| title = 'Matching Shirt and Shorts pajama set' # @param {type: "string"} | |
| description = 'This Mr. Beast brand purple shirt and shorts set is perfect for a casual day at the movies. Size M. This is a day-to-day outfit that you can wear out looking well put together, yet still casual. Get a few sets to share with your friends!' # @param {type: "string"} | |
| optional_image_url = '' # @param {type: "string"} | |
| payload = {} | |
| payload |= {'output_spec': {'workflow_id': 'tide'}} | |
| payload |= {'product_info':{'product_attributes': {'title': title, 'description': description, 'brand': 'Mr. Beast', 'color': 'purple'}}} | |
| if optional_image_url: | |
| payload['product_info'] |= {'product_image':{'uri':optional_image_url}} | |
| response = requests.post(API_ENDPOINT, params={'key': API_KEY}, json=payload) | |
| pprint.pprint(payload) | |
| print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment