|
28 | 28 | }, |
29 | 29 | { |
30 | 30 | "cell_type": "code", |
31 | | - "execution_count": null, |
32 | 31 | "id": "ef145f6d-ce8c-4c21-804e-254ca8190350", |
33 | | - "metadata": {}, |
34 | | - "outputs": [], |
| 32 | + "metadata": { |
| 33 | + "ExecuteTime": { |
| 34 | + "end_time": "2025-09-29T12:14:48.174450Z", |
| 35 | + "start_time": "2025-09-29T12:14:46.832477Z" |
| 36 | + } |
| 37 | + }, |
35 | 38 | "source": [ |
36 | 39 | "pip install amzn-sp-api==1.2.0" |
37 | | - ] |
| 40 | + ], |
| 41 | + "outputs": [ |
| 42 | + { |
| 43 | + "name": "stdout", |
| 44 | + "output_type": "stream", |
| 45 | + "text": [ |
| 46 | + "Requirement already satisfied: amzn-sp-api==1.2.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (1.2.0)\r\n", |
| 47 | + "Requirement already satisfied: urllib3<3.0.0,>=2.1.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from amzn-sp-api==1.2.0) (2.3.0)\r\n", |
| 48 | + "Requirement already satisfied: certifi>=2025.1.31 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from amzn-sp-api==1.2.0) (2025.8.3)\r\n", |
| 49 | + "Requirement already satisfied: requests>=2.32.3 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from amzn-sp-api==1.2.0) (2.32.3)\r\n", |
| 50 | + "Requirement already satisfied: six>=1.17.0 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from amzn-sp-api==1.2.0) (1.17.0)\r\n", |
| 51 | + "Requirement already satisfied: charset-normalizer<4,>=2 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from requests>=2.32.3->amzn-sp-api==1.2.0) (3.4.1)\r\n", |
| 52 | + "Requirement already satisfied: idna<4,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from requests>=2.32.3->amzn-sp-api==1.2.0) (3.10)\r\n", |
| 53 | + "\r\n", |
| 54 | + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip is available: \u001B[0m\u001B[31;49m23.2.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m25.2\u001B[0m\r\n", |
| 55 | + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49m/usr/local/bin/python3 -m pip install --upgrade pip\u001B[0m\r\n", |
| 56 | + "Note: you may need to restart the kernel to use updated packages.\n" |
| 57 | + ] |
| 58 | + } |
| 59 | + ], |
| 60 | + "execution_count": 1 |
38 | 61 | }, |
39 | 62 | { |
40 | 63 | "cell_type": "markdown", |
|
59 | 82 | }, |
60 | 83 | { |
61 | 84 | "cell_type": "code", |
62 | | - "execution_count": null, |
63 | 85 | "id": "4b7d9770-ccdc-4edd-a910-242916c578f7", |
64 | | - "metadata": {}, |
65 | | - "outputs": [], |
| 86 | + "metadata": { |
| 87 | + "ExecuteTime": { |
| 88 | + "end_time": "2025-09-29T12:15:13.908703Z", |
| 89 | + "start_time": "2025-09-29T12:15:13.887970Z" |
| 90 | + } |
| 91 | + }, |
66 | 92 | "source": [ |
67 | 93 | "from spapi.models.datakiosk_v2023_11_15 import GetDocumentResponse, CreateQueryResponse, GetQueriesResponse, Query\n", |
68 | 94 | "from spapi import SPAPIConfig, SPAPIClient, ApiException, QueriesApi, ListingsApi\n", |
|
85 | 111 | "data_kiosk_api = QueriesApi(client.api_client)\n", |
86 | 112 | "listings_api = ListingsApi(client.api_client)\n", |
87 | 113 | "print(\"💻 API Client initiated\")" |
88 | | - ] |
| 114 | + ], |
| 115 | + "outputs": [ |
| 116 | + { |
| 117 | + "name": "stdout", |
| 118 | + "output_type": "stream", |
| 119 | + "text": [ |
| 120 | + "💻 API Client initiated\n" |
| 121 | + ] |
| 122 | + } |
| 123 | + ], |
| 124 | + "execution_count": 5 |
89 | 125 | }, |
90 | 126 | { |
91 | 127 | "cell_type": "markdown", |
|
118 | 154 | "- Check their status\n", |
119 | 155 | "- Download results\n", |
120 | 156 | " \n", |
121 | | - "🙌 Time to get seller data with the power of GraphQL!\n" |
| 157 | + "🙌 Time to get seller data with the power of GraphQL!" |
122 | 158 | ] |
123 | 159 | }, |
124 | 160 | { |
| 161 | + "metadata": {}, |
125 | 162 | "cell_type": "code", |
| 163 | + "outputs": [], |
126 | 164 | "execution_count": null, |
| 165 | + "source": "pip install pandas", |
| 166 | + "id": "6cc8eb127ee0292b" |
| 167 | + }, |
| 168 | + { |
| 169 | + "cell_type": "code", |
127 | 170 | "id": "7250c7cd-62cd-4ce3-9c40-db746184a37f", |
128 | | - "metadata": {}, |
129 | | - "outputs": [], |
| 171 | + "metadata": { |
| 172 | + "ExecuteTime": { |
| 173 | + "end_time": "2025-09-29T12:15:50.137187Z", |
| 174 | + "start_time": "2025-09-29T12:15:49.991204Z" |
| 175 | + } |
| 176 | + }, |
130 | 177 | "source": [ |
131 | 178 | "graphql_query_str = (\"query { analytics_economics_2024_03_15 { economics( marketplaceIds: [\\\"ATVPDKIKX0DER\\\"], \"\n", |
132 | 179 | " \"startDate: \\\"2025-06-01\\\", endDate: \\\"2025-06-05\\\", \"\n", |
|
192 | 239 | "\n", |
193 | 240 | "plt.tight_layout()\n", |
194 | 241 | "plt.show()\n" |
195 | | - ] |
| 242 | + ], |
| 243 | + "outputs": [ |
| 244 | + { |
| 245 | + "name": "stdout", |
| 246 | + "output_type": "stream", |
| 247 | + "text": [ |
| 248 | + "📃 Query: \n", |
| 249 | + " query { analytics_economics_2024_03_15 { economics( marketplaceIds: [\"ATVPDKIKX0DER\"], startDate: \"2025-06-01\", endDate: \"2025-06-05\", aggregateBy: { date: DAY, productId: MSKU } ) { startDate endDate msku marketplaceId sales { unitsOrdered netUnitsSold netProductSales { amount currencyCode } } netProceeds { total { amount currencyCode } } } } }\n", |
| 250 | + "✅ Query submitted! Response: {'query_id': '1000001'}\n", |
| 251 | + "⏱️ Query status: {'created_time': datetime.datetime(2025, 7, 17, 11, 25, 13, 645000, tzinfo=tzutc()),\n", |
| 252 | + " 'data_document_id': 'usecase_1_document_id.amzn.100001',\n", |
| 253 | + " 'error_document_id': None,\n", |
| 254 | + " 'pagination': None,\n", |
| 255 | + " 'processing_end_time': datetime.datetime(2025, 7, 17, 11, 25, 13, 645000, tzinfo=tzutc()),\n", |
| 256 | + " 'processing_start_time': datetime.datetime(2025, 7, 17, 11, 25, 13, 645000, tzinfo=tzutc()),\n", |
| 257 | + " 'processing_status': 'DONE',\n", |
| 258 | + " 'query': 'query { analytics_economics_2024_03_15 { economics( marketplaceIds: '\n", |
| 259 | + " '[\"ATVPDKIKX0DER\"], startDate: \"2025-06-01\", endDate: \"2025-06-05\", '\n", |
| 260 | + " 'aggregateBy: { date: DAY, productId: MSKU } ) { startDate endDate '\n", |
| 261 | + " 'msku marketplaceId sales { unitsOrdered netUnitsSold '\n", |
| 262 | + " 'netProductSales { amount currencyCode } } netProceeds { total { '\n", |
| 263 | + " 'amount currencyCode } } } } }',\n", |
| 264 | + " 'query_id': '1000001'}\n", |
| 265 | + "📊 Here's your data: {'document_id': 'usecase_1_document_id.amzn.100001',\n", |
| 266 | + " 'document_url': \"{'data': {'analytics_economics_2024_03_15': {'economics': \"\n", |
| 267 | + " \"[{'startDate': '2025-06-01', 'endDate': '2025-06-01', \"\n", |
| 268 | + " \"'msku': 'MOTOR-GEAR-US', 'marketplaceId': 'ATVPDKIKX0DER', \"\n", |
| 269 | + " \"'sales': {'unitsOrdered': 0, 'netUnitsSold': 0, \"\n", |
| 270 | + " \"'netProductSales': {'amount': 0.0, 'currencyCode': 'USD'}}, \"\n", |
| 271 | + " \"'netProceeds': {'total': {'amount': 0.0, 'currencyCode': \"\n", |
| 272 | + " \"'USD'}}}, {'startDate': '2025-06-01', 'endDate': \"\n", |
| 273 | + " \"'2025-06-01', 'msku': 'MOTOR-GEAR-CA', 'marketplaceId': \"\n", |
| 274 | + " \"'A2EUQ1WTGCTBG2', 'sales': {'unitsOrdered': 50, \"\n", |
| 275 | + " \"'netUnitsSold': 50, 'netProductSales': {'amount': 1000.0, \"\n", |
| 276 | + " \"'currencyCode': 'CAD'}}, 'netProceeds': {'total': {'amount': \"\n", |
| 277 | + " \"800.0, 'currencyCode': 'CAD'}}}, {'startDate': '2025-06-01', \"\n", |
| 278 | + " \"'endDate': '2025-06-01', 'msku': 'MOTOR-GEAR-MX', \"\n", |
| 279 | + " \"'marketplaceId': 'A1AM78C64UM0Y8', 'sales': {'unitsOrdered': \"\n", |
| 280 | + " \"50, 'netUnitsSold': 50, 'netProductSales': {'amount': \"\n", |
| 281 | + " \"1000.0, 'currencyCode': 'Mex'}}, 'netProceeds': {'total': \"\n", |
| 282 | + " \"{'amount': 800.0, 'currencyCode': 'Mex'}}}]}}}\"}\n" |
| 283 | + ] |
| 284 | + }, |
| 285 | + { |
| 286 | + "ename": "ModuleNotFoundError", |
| 287 | + "evalue": "No module named 'pandas'", |
| 288 | + "output_type": "error", |
| 289 | + "traceback": [ |
| 290 | + "\u001B[31m---------------------------------------------------------------------------\u001B[39m", |
| 291 | + "\u001B[31mModuleNotFoundError\u001B[39m Traceback (most recent call last)", |
| 292 | + "\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[6]\u001B[39m\u001B[32m, line 22\u001B[39m\n\u001B[32m 19\u001B[39m \u001B[38;5;28mprint\u001B[39m(\u001B[33m\"\u001B[39m\u001B[33m📊 Here\u001B[39m\u001B[33m'\u001B[39m\u001B[33ms your data:\u001B[39m\u001B[33m\"\u001B[39m, get_document)\n\u001B[32m 21\u001B[39m \u001B[38;5;28;01mimport\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34;01mast\u001B[39;00m\n\u001B[32m---> \u001B[39m\u001B[32m22\u001B[39m \u001B[38;5;28;01mimport\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34;01mpandas\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;28;01mas\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34;01mpd\u001B[39;00m\n\u001B[32m 23\u001B[39m \u001B[38;5;28;01mimport\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34;01mmatplotlib\u001B[39;00m\u001B[34;01m.\u001B[39;00m\u001B[34;01mpyplot\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;28;01mas\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34;01mplt\u001B[39;00m\n\u001B[32m 25\u001B[39m \u001B[38;5;66;03m# Safely convert the string to a dictionary\u001B[39;00m\n", |
| 293 | + "\u001B[31mModuleNotFoundError\u001B[39m: No module named 'pandas'" |
| 294 | + ] |
| 295 | + } |
| 296 | + ], |
| 297 | + "execution_count": 6 |
196 | 298 | }, |
197 | 299 | { |
198 | 300 | "cell_type": "markdown", |
|
377 | 479 | "patch_listing = listings_api.patch_listings_item('AMY7FKRUBY7XV', 'MOTOR-GEAR-US',['ATVPDKIKX0DER'], body)\n", |
378 | 480 | "print(\"💾 Submission result: \\n\", json.dumps(patch_listing.to_dict(), indent=4, default=str))" |
379 | 481 | ] |
| 482 | + }, |
| 483 | + { |
| 484 | + "metadata": {}, |
| 485 | + "cell_type": "code", |
| 486 | + "outputs": [], |
| 487 | + "execution_count": null, |
| 488 | + "source": "", |
| 489 | + "id": "207ce43df479a203" |
380 | 490 | } |
381 | 491 | ], |
382 | 492 | "metadata": { |
383 | 493 | "kernelspec": { |
384 | | - "display_name": "conda_python3", |
| 494 | + "display_name": "Python 3 (ipykernel)", |
385 | 495 | "language": "python", |
386 | | - "name": "conda_python3" |
| 496 | + "name": "python3" |
387 | 497 | }, |
388 | 498 | "language_info": { |
389 | 499 | "codemirror_mode": { |
|
0 commit comments