@@ -6,14 +6,23 @@ Developer-friendly & type-safe Python SDK specifically catered to leverage *ttd-
66[ ![ License: MIT] ( https://img.shields.io/badge/LICENSE_//_MIT-3b5bdb?style=for-the-badge&labelColor=eff6ff )] ( https://mit-license.org/ )
77
88
9- <br /><br />
10- > [ !IMPORTANT]
11- > This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [ workspace] ( https://app.speakeasy.com/org/thetradedesk/data-api ) . Delete this section before > publishing to a package manager.
9+
1210
1311<!-- Start Summary [summary] -->
1412## Summary
1513
14+ TTD Data API: Python SDK for The Trade Desk Data API. Provides operations for ingesting advertiser data,
15+ third-party data, and offline conversions, as well as handling data subject deletion and opt-out requests.
16+
17+ For more information, see the official API documentation:
18+ - [ Advertiser targeting data (1PD)] ( https://open.thetradedesk.com/advertiser/docsApp/GuidesAdvertiser/data/doc/post-data-advertiser-firstparty )
19+ - [ Third-party targeting data (3PD)] ( https://open.thetradedesk.com/provider/docsApp/GuidesProvider/audience/doc/post-data-thirdparty )
20+ - [ Offline conversions (CAPI)] ( https://open.thetradedesk.com/advertiser/docsApp/GuidesAdvertiser/data/doc/post-providerapi-offlineconversion )
1621
22+ Deletions and opt-outs:
23+ - [ Advertiser] ( https://open.thetradedesk.com/advertiser/docsApp/GuidesAdvertiser/data/doc/post-data-deletion-optout-advertiser )
24+ - [ Third party] ( https://open.thetradedesk.com/provider/docsApp/GuidesProvider/audience/doc/post-data-deletion-optout-thirdparty )
25+ - [ Merchant] ( https://open.thetradedesk.com/provider/docsApp/GuidesProvider/retail/doc/post-data-deletion-optout-merchant )
1726<!-- End Summary [summary] -->
1827
1928<!-- Start Table of Contents [toc] -->
@@ -111,49 +120,151 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
111120- [ PyCharm Pydantic Plugin] ( https://docs.pydantic.dev/latest/integrations/pycharm/ )
112121<!-- End IDE Support [idesupport] -->
113122
114- <!-- Start SDK Example Usage [usage] -->
115123## SDK Example Usage
116124
117- ### Example
125+ ### 1. Advertiser targeting Data (1PD)
118126
119127``` python
120- # Synchronous Example
121- from ttd_data import DataClient
128+ from ttd_data import DataClient, models
129+
130+ with DataClient() as client:
131+ response = client.advertiser.ingest_advertiser_data(
132+ ttd_auth = TTD_AUTH_TOKEN ,
133+ advertiser_id = ADVERTISER_ID ,
134+ items = [
135+ models.AdvertiserDataItem(
136+ tdid = " <TDID>" ,
137+ data = [
138+ models.AdvertiserData(name = " loyalty_members" ),
139+ ],
140+ )
141+ ],
142+ )
122143
144+ ```
123145
124- with DataClient() as data_client:
146+ ### 2. Third Party Targeting Data (3PD)
125147
126- res = data_client.advertiser.ingest_advertiser_data(ttd_auth = " <value>" , advertiser_id = " <id>" )
148+ ``` python
149+ from ttd_data import DataClient, models
150+
151+ with DataClient() as client:
152+ response = client.third_party.ingest_third_party_data(
153+ ttd_auth = TTD_AUTH_TOKEN ,
154+ data_provider_id = DATA_PROVIDER_ID ,
155+ items = [
156+ models.ThirdPartyDataItem(
157+ tdid = " <TDID>" ,
158+ data = [
159+ models.ThirdPartyData(name = " in_market_auto" ),
160+ ],
161+ )
162+ ],
163+ )
164+ ```
127165
128- assert res.advertiser_data_server_response is not None
166+ ### 3. Offline Conversions Data (CAPI)
129167
130- # Handle response
131- print (res.advertiser_data_server_response)
168+ ``` python
169+ from ttd_data import DataClient, models
170+
171+ with DataClient() as client:
172+ response = client.offline_conversion.ingest_offline_conversion_data(
173+ ttd_auth = TTD_AUTH_TOKEN ,
174+ data_provider_id = DATA_PROVIDER_ID ,
175+ items = [
176+ models.OfflineConversionDataItem(
177+ tracking_tag_id = TRACKING_TAG_ID ,
178+ timestamp_utc = datetime.now(timezone.utc),
179+ tdid = " <TDID>" ,
180+ )
181+ ],
182+ )
183+ ```
184+
185+ ### 4. Optouts and Deletion - Advertiser - Data Subject Request
186+
187+ ``` python
188+ from ttd_data import DataClient, models
189+
190+ with DataClient() as client:
191+ response = client.deletion_opt_out.data_subject_request_advertiser_data(
192+ ttd_auth = TTD_AUTH_TOKEN ,
193+ advertiser_id = ADVERTISER_ID ,
194+ request_type = models.PartnerDsrRequestType.DELETION ,
195+ items = [
196+ models.PartnerDsrDataItem(tdid = " <TDID>" ),
197+ models.PartnerDsrDataItem(daid = " <DAID>" ),
198+ models.PartnerDsrDataItem(euid = " <EUID>" ),
199+ ],
200+ )
201+ ```
202+
203+ ### 5. Optouts and Deletion - Data Provider - Data Subject Request
204+
205+ ``` python
206+ from ttd_data import DataClient, models
207+
208+ with DataClient() as client:
209+ response = client.deletion_opt_out.data_subject_request_third_party_data(
210+ ttd_auth = TTD_AUTH_TOKEN ,
211+ data_provider_id = DATA_PROVIDER_ID ,
212+ request_type = models.PartnerDsrRequestType.OPT_OUT ,
213+ items = [
214+ models.PartnerDsrDataItem(tdid = " <TDID>" ),
215+ models.PartnerDsrDataItem(ramp_id = " <RAMP_ID>" ),
216+ ],
217+ )
218+ ```
219+
220+ ### 6. Optouts and Deletion - Merchant - Data Subject Request
221+
222+ ``` python
223+ from ttd_data import DataClient, models
224+
225+ with DataClient() as client:
226+ response = client.deletion_opt_out.data_subject_request_merchant_data(
227+ ttd_auth = TTD_AUTH_TOKEN ,
228+ merchant_id = MERCHANT_ID ,
229+ request_type = models.PartnerDsrRequestType.DELETION ,
230+ items = [
231+ models.PartnerDsrDataItem(tdid = " <TDID>" ),
232+ ],
233+ )
132234```
133235
134- </br >
236+
237+ ### 7. Async usage
135238
136239The same SDK client can also be used to make asynchronous requests by importing asyncio.
137240
138241``` python
139242# Asynchronous Example
140243import asyncio
141- from ttd_data import DataClient
244+ from ttd_data import DataClient, models
142245
143246async def main ():
144247
145248 async with DataClient() as data_client:
146-
147- res = await data_client.advertiser.ingest_advertiser_data_async(ttd_auth = " <value>" , advertiser_id = " <id>" )
148-
149- assert res.advertiser_data_server_response is not None
249+ response = client.advertiser.ingest_advertiser_data(
250+ ttd_auth = TTD_AUTH_TOKEN ,
251+ advertiser_id = ADVERTISER_ID ,
252+ items = [
253+ models.AdvertiserDataItem(
254+ tdid = " <TDID>" ,
255+ data = [
256+ models.AdvertiserData(name = " loyalty_members" ),
257+ ],
258+ )
259+ ],
260+ )
150261
151262 # Handle response
152- print (res .advertiser_data_server_response)
263+ print (response .advertiser_data_server_response)
153264
154265asyncio.run(main())
155266```
156- <!-- End SDK Example Usage [usage] -->
267+ <!-- No SDK Example Usage [usage] -->
157268
158269<!-- Start Available Resources and Operations [operations] -->
159270## Available Resources and Operations
0 commit comments