├── .gitignore ├── README.md ├── LICENSE └── SPAPI.postman_collection.json /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Selling Partner API Postman Sandbox 2 | Postman Collection to lunch&play with Amazon Selling Partner API. \ 3 | Feel free to contribute to this repo! 4 | 5 | ## Requirements 6 | - [Postman](https://www.postman.com/) 7 | 8 | ## How to run? 9 | - Import collection to Postman 10 | - Follow [Self Authorization](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/developer-guide/SellingPartnerApiDeveloperGuide.md#self-authorization) and receive `refresh_token` 11 | - __Edit collection's variables__ 12 | - Create new Environment like: `SP Api Env` 13 | - Run `Init` folder to `assumeRole` get `accessToken` using `SP Api Env` Environment to set up Env variables 14 | - Run `ApiCalls` using `SP Api Env` Environment 15 | 16 | ## Troubleshooting 17 | - AccessToken last only one hour, then you should Run `Init` folder to refresh it 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Pavlo Cherniavsyi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SPAPI.postman_collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "09e74677-8251-44aa-8e2e-5343ffd40228", 4 | "name": "SP API", 5 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" 6 | }, 7 | "item": [ 8 | { 9 | "name": "Init", 10 | "item": [ 11 | { 12 | "name": "AssumeRole", 13 | "event": [ 14 | { 15 | "listen": "test", 16 | "script": { 17 | "id": "f2ef163f-210a-4115-a3f8-8ad6396296c5", 18 | "exec": [ 19 | "var credentials = xml2Json(responseBody).AssumeRoleResponse.AssumeRoleResult.Credentials;", 20 | "", 21 | "pm.environment.set(\"AccessKeyId\", credentials.AccessKeyId);", 22 | "pm.environment.set(\"SecretAccessKey\", credentials.SecretAccessKey);", 23 | "pm.environment.set(\"SessionToken\", credentials.SessionToken);" 24 | ], 25 | "type": "text/javascript" 26 | } 27 | } 28 | ], 29 | "request": { 30 | "auth": { 31 | "type": "awsv4", 32 | "awsv4": [ 33 | { 34 | "key": "region", 35 | "value": "{{awsRegion}}", 36 | "type": "string" 37 | }, 38 | { 39 | "key": "secretKey", 40 | "value": "{{awsUserSecret}}", 41 | "type": "string" 42 | }, 43 | { 44 | "key": "accessKey", 45 | "value": "{{awsUserKey}}", 46 | "type": "string" 47 | }, 48 | { 49 | "key": "service", 50 | "value": "sts", 51 | "type": "string" 52 | }, 53 | { 54 | "key": "addAuthDataToQuery", 55 | "value": false, 56 | "type": "boolean" 57 | }, 58 | { 59 | "key": "sessionToken", 60 | "value": "", 61 | "type": "string" 62 | } 63 | ] 64 | }, 65 | "method": "GET", 66 | "header": [], 67 | "url": { 68 | "raw": "https://sts.amazonaws.com/?Version={{awsStsVersion}}&Action=AssumeRole&RoleSessionName=postmanSpApi&RoleArn={{RoleArn}}", 69 | "protocol": "https", 70 | "host": [ 71 | "sts", 72 | "amazonaws", 73 | "com" 74 | ], 75 | "path": [ 76 | "" 77 | ], 78 | "query": [ 79 | { 80 | "key": "Version", 81 | "value": "{{awsStsVersion}}" 82 | }, 83 | { 84 | "key": "Action", 85 | "value": "AssumeRole" 86 | }, 87 | { 88 | "key": "RoleSessionName", 89 | "value": "postmanSpApi" 90 | }, 91 | { 92 | "key": "RoleArn", 93 | "value": "{{RoleArn}}" 94 | } 95 | ] 96 | } 97 | }, 98 | "response": [] 99 | }, 100 | { 101 | "name": "GetAccessToken", 102 | "event": [ 103 | { 104 | "listen": "test", 105 | "script": { 106 | "id": "43018038-d28f-4454-868f-b5a909d4aee3", 107 | "exec": [ 108 | "var jsonData = pm.response.json();", 109 | "pm.environment.set(\"accessToken\", jsonData.access_token);" 110 | ], 111 | "type": "text/javascript" 112 | } 113 | } 114 | ], 115 | "request": { 116 | "method": "POST", 117 | "header": [], 118 | "body": { 119 | "mode": "urlencoded", 120 | "urlencoded": [ 121 | { 122 | "key": "grant_type", 123 | "value": "refresh_token", 124 | "type": "text" 125 | }, 126 | { 127 | "key": "refresh_token", 128 | "value": "{{refreshToken}}", 129 | "type": "text" 130 | }, 131 | { 132 | "key": "client_id", 133 | "value": "{{appClientID}}", 134 | "type": "text" 135 | }, 136 | { 137 | "key": "client_secret", 138 | "value": "{{appClientSecret}}", 139 | "type": "text" 140 | } 141 | ] 142 | }, 143 | "url": { 144 | "raw": "https://{{apiOAuthUrl}}/auth/o2/token", 145 | "protocol": "https", 146 | "host": [ 147 | "{{apiOAuthUrl}}" 148 | ], 149 | "path": [ 150 | "auth", 151 | "o2", 152 | "token" 153 | ] 154 | } 155 | }, 156 | "response": [] 157 | } 158 | ], 159 | "protocolProfileBehavior": {} 160 | }, 161 | { 162 | "name": "ApiCalls", 163 | "item": [ 164 | { 165 | "name": "Orders - Yesterday", 166 | "event": [ 167 | { 168 | "listen": "prerequest", 169 | "script": { 170 | "id": "346698a3-7e74-4fc5-8f17-6e2c859a3c33", 171 | "exec": [ 172 | "function getYesterdaysDate() {", 173 | " let today = new Date();", 174 | " let yesterday = new Date(today);", 175 | " yesterday.setDate(yesterday.getDate() - 1);", 176 | " return yesterday.toISOString();", 177 | "}", 178 | "", 179 | "pm.environment.set(\"dateYesterday\", getYesterdaysDate());" 180 | ], 181 | "type": "text/javascript" 182 | } 183 | }, 184 | { 185 | "listen": "test", 186 | "script": { 187 | "id": "4e8b47ed-552c-4a40-b929-f7daccd9b7f7", 188 | "exec": [ 189 | "var orders = pm.response.json().payload.Orders;", 190 | "console.log('Found '+orders.length+' orders');" 191 | ], 192 | "type": "text/javascript" 193 | } 194 | } 195 | ], 196 | "request": { 197 | "auth": { 198 | "type": "awsv4", 199 | "awsv4": [ 200 | { 201 | "key": "sessionToken", 202 | "value": "{{SessionToken}}", 203 | "type": "string" 204 | }, 205 | { 206 | "key": "secretKey", 207 | "value": "{{SecretAccessKey}}", 208 | "type": "string" 209 | }, 210 | { 211 | "key": "accessKey", 212 | "value": "{{AccessKeyId}}", 213 | "type": "string" 214 | }, 215 | { 216 | "key": "addAuthDataToQuery", 217 | "value": false, 218 | "type": "boolean" 219 | }, 220 | { 221 | "key": "service", 222 | "value": "execute-api", 223 | "type": "string" 224 | }, 225 | { 226 | "key": "region", 227 | "value": "us-east-1", 228 | "type": "string" 229 | } 230 | ] 231 | }, 232 | "method": "GET", 233 | "header": [ 234 | { 235 | "key": "x-amz-access-token", 236 | "type": "text", 237 | "value": "{{accessToken}}", 238 | "description": "Header name must be in LOWERCASE!" 239 | } 240 | ], 241 | "url": { 242 | "raw": "https://{{apiUrl}}/orders/v0/orders?MarketplaceIds=ATVPDKIKX0DER&CreatedAfter={{dateYesterday}}", 243 | "protocol": "https", 244 | "host": [ 245 | "{{apiUrl}}" 246 | ], 247 | "path": [ 248 | "orders", 249 | "v0", 250 | "orders" 251 | ], 252 | "query": [ 253 | { 254 | "key": "MarketplaceIds", 255 | "value": "ATVPDKIKX0DER" 256 | }, 257 | { 258 | "key": "CreatedAfter", 259 | "value": "{{dateYesterday}}", 260 | "description": "See Pre-request Script" 261 | } 262 | ] 263 | } 264 | }, 265 | "response": [] 266 | } 267 | ], 268 | "protocolProfileBehavior": {} 269 | } 270 | ], 271 | "event": [ 272 | { 273 | "listen": "prerequest", 274 | "script": { 275 | "id": "df489ff2-e94f-492b-8ff6-9c6e4fc36af5", 276 | "type": "text/javascript", 277 | "exec": [ 278 | "" 279 | ] 280 | } 281 | }, 282 | { 283 | "listen": "test", 284 | "script": { 285 | "id": "2c641a7e-daec-4792-a114-333473c72a87", 286 | "type": "text/javascript", 287 | "exec": [ 288 | "" 289 | ] 290 | } 291 | } 292 | ], 293 | "variable": [ 294 | { 295 | "id": "a05b5ea2-2645-48a6-aff2-dceb4d64bdcc", 296 | "key": "apiUrl", 297 | "value": "sellingpartnerapi-na.amazon.com" 298 | }, 299 | { 300 | "id": "89d36b08-4b51-4729-95b9-e4862de00105", 301 | "key": "apiOAuthUrl", 302 | "value": "api.amazon.com" 303 | }, 304 | { 305 | "id": "bcc784f0-5ba4-4b1f-b3e5-63b755bc6a68", 306 | "key": "awsStsVersion", 307 | "value": "2011-06-15" 308 | }, 309 | { 310 | "id": "73c40cc9-ae91-492d-b152-7d5dee1a3861", 311 | "key": "awsRegion", 312 | "value": "us-east-1" 313 | }, 314 | { 315 | "id": "c702ce5a-295a-4b57-83b7-88b93df10691", 316 | "key": "RoleArn", 317 | "value": "!REQUIRED!" 318 | }, 319 | { 320 | "id": "385e7ada-b549-459f-941c-3cd08ca22bd6", 321 | "key": "appClientID", 322 | "value": "!REQUIRED!" 323 | }, 324 | { 325 | "id": "ef2e6771-2e9f-4b10-a0f8-1adfba43264c", 326 | "key": "appClientSecret", 327 | "value": "!REQUIRED!" 328 | }, 329 | { 330 | "id": "beac28f0-af29-4101-8cc0-a78fcf7471e2", 331 | "key": "awsUserKey", 332 | "value": "!REQUIRED!" 333 | }, 334 | { 335 | "id": "2a9c05f1-b30b-445e-bc0e-9c1b414e7866", 336 | "key": "awsUserSecret", 337 | "value": "!REQUIRED!" 338 | }, 339 | { 340 | "id": "07f7e09c-751a-4037-b252-ca0cdcc50c53", 341 | "key": "refreshToken", 342 | "value": "!REQUIRED!" 343 | } 344 | ], 345 | "protocolProfileBehavior": {} 346 | } --------------------------------------------------------------------------------