Skip to content

Commit 6904a7c

Browse files
author
stlc-bot
committed
feat(api): return request_id on every response
Stainless-Generated-From: ff6069e
1 parent ca4de4e commit 6904a7c

33 files changed

Lines changed: 196 additions & 4 deletions

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ brand = client.brand.retrieve(
3636
domain="REPLACE_ME",
3737
type="by_domain",
3838
)
39-
print(brand.cache_metadata)
39+
print(brand.request_id)
4040
```
4141

4242
While you can provide an `api_key` keyword argument,
@@ -63,7 +63,7 @@ async def main() -> None:
6363
domain="REPLACE_ME",
6464
type="by_domain",
6565
)
66-
print(brand.cache_metadata)
66+
print(brand.request_id)
6767

6868

6969
asyncio.run(main())
@@ -100,7 +100,7 @@ async def main() -> None:
100100
domain="REPLACE_ME",
101101
type="by_domain",
102102
)
103-
print(brand.cache_metadata)
103+
print(brand.request_id)
104104

105105

106106
asyncio.run(main())
@@ -270,7 +270,7 @@ response = client.brand.with_raw_response.retrieve(
270270
print(response.headers.get('X-My-Header'))
271271

272272
brand = response.parse() # get the object that `brand.retrieve()` would have returned
273-
print(brand.cache_metadata)
273+
print(brand.request_id)
274274
```
275275

276276
These methods return an [`APIResponse`](https://github.com/context-dot-dev/context-python-sdk/tree/main/src/context/dev/_response.py) object.

‎src/context/dev/types/ai_extract_product_response.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ class AIExtractProductResponse(BaseModel):
103103
to the output was a hit; age_ms is the oldest contributing hit.
104104
"""
105105

106+
request_id: str
107+
"""Unique id of this API call, also sent in the X-Request-Id response header.
108+
109+
Quote it when contacting support about a failed request.
110+
"""
111+
106112
is_product_page: Optional[bool] = None
107113
"""Whether the given URL is a product detail page"""
108114

‎src/context/dev/types/ai_extract_products_response.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ class AIExtractProductsResponse(BaseModel):
101101
to the output was a hit; age_ms is the oldest contributing hit.
102102
"""
103103

104+
request_id: str
105+
"""Unique id of this API call, also sent in the X-Request-Id response header.
106+
107+
Quote it when contacting support about a failed request.
108+
"""
109+
104110
key_metadata: Optional[KeyMetadata] = None
105111
"""Credit usage, included whenever a valid API key is provided."""
106112

‎src/context/dev/types/batch_cancel_response.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ class BatchCancelResponse(BaseModel):
8383
progress: Progress
8484
"""How far the batch got before cancellation."""
8585

86+
request_id: str
87+
"""Unique id of this API call, also sent in the X-Request-Id response header.
88+
89+
Quote it when contacting support about a failed request.
90+
"""
91+
8692
status: Literal["cancelling"]
8793
"""Always `cancelling`.
8894

‎src/context/dev/types/batch_delete_response.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ class KeyMetadata(BaseModel):
1818

1919

2020
class BatchDeleteResponse(BaseModel):
21+
request_id: str
22+
"""Unique id of this API call, also sent in the X-Request-Id response header.
23+
24+
Quote it when contacting support about a failed request.
25+
"""
26+
2127
id: Optional[str] = None
2228
"""ID of the deleted batch."""
2329

‎src/context/dev/types/batch_get_results_response.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ class KeyMetadata(BaseModel):
214214

215215

216216
class BatchGetResultsResponse(BaseModel):
217+
request_id: str
218+
"""Unique id of this API call, also sent in the X-Request-Id response header.
219+
220+
Quote it when contacting support about a failed request.
221+
"""
222+
217223
data: Optional[List[Data]] = None
218224
"""Result records on this page."""
219225

‎src/context/dev/types/batch_list_response.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ class KeyMetadata(BaseModel):
169169

170170

171171
class BatchListResponse(BaseModel):
172+
request_id: str
173+
"""Unique id of this API call, also sent in the X-Request-Id response header.
174+
175+
Quote it when contacting support about a failed request.
176+
"""
177+
172178
data: Optional[List[Data]] = None
173179
"""Batches on this page."""
174180

‎src/context/dev/types/batch_retrieve_response.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ class BatchRetrieveResponse(BaseModel):
162162
progress: Progress
163163
"""Pages attempted so far. Use `status` to check completion."""
164164

165+
request_id: str
166+
"""Unique id of this API call, also sent in the X-Request-Id response header.
167+
168+
Quote it when contacting support about a failed request.
169+
"""
170+
165171
results: Optional[Results] = None
166172
"""
167173
Download links, available once the batch reaches a final status and null before

‎src/context/dev/types/batch_submit_response.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ class BatchSubmitResponse(BaseModel):
8989
mode: Literal["scrape", "crawl"]
9090
"""How pages will be selected."""
9191

92+
request_id: str
93+
"""Unique id of this API call, also sent in the X-Request-Id response header.
94+
95+
Quote it when contacting support about a failed request.
96+
"""
97+
9298
status: Literal["queued"]
9399
"""Always `queued`. An accepted batch has not started yet."""
94100

‎src/context/dev/types/brand_retrieve_response.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,12 @@ class BrandRetrieveResponse(BaseModel):
711711
to the output was a hit; age_ms is the oldest contributing hit.
712712
"""
713713

714+
request_id: str
715+
"""Unique id of this API call, also sent in the X-Request-Id response header.
716+
717+
Quote it when contacting support about a failed request.
718+
"""
719+
714720
brand: Optional[Brand] = None
715721
"""Detailed brand information"""
716722

0 commit comments

Comments
 (0)