### Get Authorization Code Request Example Source: https://github.com/saleweaver/python-amazon-sp-api/blob/master/docs/_static/redoc/authorization.html This example demonstrates how to make a GET request to obtain an authorization code. Ensure you provide the correct sellingPartnerId, developerId, and mwsAuthToken as query parameters. ```javascript const __redoc_state = {"menu":{"activeItemIdx":-1},"spec":{"data":{"openapi":"3.0.0","info":{"description":"The Selling Partner API for Authorization helps developers manage authorizations and check the specific permissions associated with a given authorization.","version":"v1","title":"Selling Partner API for Authorization","contact":{"name":"Selling Partner API Developer Support","url":"https://sellercentral.amazon.com/gp/mws/contactus.html"},"license":{"name":"Apache License 2.0","url":"http://www.apache.org/licenses/LICENSE-2.0"}},"paths":{"/authorization/v1/authorizationCode":{"get":{"tags":["authorization"],"summary":"Returns the Login with Amazon (LWA) authorization code for an existing Amazon MWS authorization.","description":"With the getAuthorizationCode operation, you can request a Login With Amazon (LWA) authorization code that will allow you to call a Selling Partner API on behalf of a seller who has already authorized you to call Amazon Marketplace Web Service (Amazon MWS). You specify a developer ID, an MWS auth token, and a seller ID. Taken together, these represent the Amazon MWS authorization that the seller previously granted you. The operation returns an LWA authorization code that can be exchanged for a refresh token and access token representing authorization to call the Selling Partner API on the seller's behalf. By using this API, sellers who have already authorized you for Amazon MWS do not need to re-authorize you for the Selling Partner API.\n\n**Usage Plan:**\n\n| Rate (requests per second) | Burst |\n| ---- | ---- |\n| 1 | 5 |\n\nFor more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.","operationId":"getAuthorizationCode","parameters":[{"name":"sellingPartnerId","in":"query","description":"The seller ID of the seller for whom you are requesting Selling Partner API authorization. This must be the seller ID of the seller who authorized your application on the Marketplace Appstore.","required":true,"allowEmptyValue":false,"schema":{"type":"string"}},{"name":"developerId","in":"query","description":"Your developer ID. This must be one of the developer ID values that you provided when you registered your application in Developer Central.","required":true,"allowEmptyValue":false,"schema":{"type":"string"}},{"name":"mwsAuthToken","in":"query","description":"The MWS Auth Token that was generated when the seller authorized your application on the Marketplace Appstore.","required":true,"allowEmptyValue":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Success.","headers":{"x-amzn-RateLimit-Limit":{"description":"Your rate limit (requests per second) for this operation.","schema":{"type":"string"}},"x-amzn-RequestId":{"description":"Unique request reference ID.","schema":{"type":"string"}}},"x-amzn-api-sandbox":{"static":[{"request":{"parameters":{}},"response":{"payload":{"authorizationCode":"ANDMxqpCmqWHJeyzdbMH"}}}]},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAuthorizationCodeResponse"}},"payload":{"examples":{"response":{"value":{"authorizationCode":"ANDMxqpCmqWHJeyzdbMH"}}}}}},"400":{"description":"Request has missing or invalid parameters and cannot be parsed.","headers":{"x-amzn-RateLimit-Limit":{"description":"Your rate limit (requests per second) for this operation.","schema":{"type":"string"}},"x-amzn-RequestId":{"description":"Unique request reference ID.","schema":{"type":"string"}}},"x-amzn-api-sandbox":{"static":[{"request":{"parameters":{"mwsAuthToken":{"value":"TEST_CASE_400"}}},"response":{"errors":[{"code":"InvalidInput","message":"Invalid input."}]}}]},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAuthorizationCodeResponse"}},"errors":{"examples":{"response":{"value":[{"code":"1001","message":"Authorization code you provided is invalid."}]}}}}},"403":{"description":"Indicates that access to the resource is forbidden. Possible reasons include Access Denied, Unauthorized, Expired Token, or Invalid Signature.","headers":{"x-amzn-RequestId":{"description":"Unique request reference ID.","schema":{"type":"string"}}},"content":{"application/json":{"$ref":"#/components/schemas/GetAuthorizationCodeResponse"}}},"404":{"description":"The resource specified does not exist.","headers":{"x-amzn-RateLimit-Limit":{"description":"Your rate limit (requests per second) for this operation.","schema":{"type":"string"}},"x-amzn-RequestId":{"de ``` -------------------------------- ### Get Orders Example Source: https://github.com/saleweaver/python-amazon-sp-api/blob/master/docs/_static/redoc/feeds_2021-06-30.html Example of how to retrieve orders using the SP API client. Specify parameters like MarketplaceId and CreatedAfter. ```python from sp_api.api import SPAPI from sp_api.base import Marketplaces client = SPAPI() # Example: Get orders created after a specific date in the US marketplace response = client.get_orders(marketplaceIds=[Marketplaces.US.marketplaceId], CreatedAfter='2023-01-01T00:00:00Z') # Process the response if response.payload: for order in response.payload.get('Orders', []): print(f"Order ID: {order['AmazonOrderId']}, Status: {order['OrderStatus']}") else: print("No orders found or an error occurred.") print(response.error) ``` -------------------------------- ### Get Fulfillment Preview Response Example Source: https://github.com/saleweaver/python-amazon-sp-api/blob/master/docs/_static/redoc/fulfillmentOutbound_2020-07-01.html Example successful response for the GetFulfillmentPreview operation. This shows estimated shipping details and fees for a fulfillment order. ```json { "fulfillmentPreviews": [ { "shippingSpeedCategory": "Standard", "isFulfillable": true, "estimatedShippingWeight": { "unit": "POUNDS", "value": "22" }, "estimatedFees": [ { "name": "FBAPerUnitFulfillmentFee", "amount": { "currencyCode": "USD", "value": "19.71" } } ], "fulfillmentPreviewShipments": [ { "earliestShipDate": "2020-02-11T18:16:16Z", "latestShipDate": "2020-02-11T18:16:16Z", "earliestArrivalDate": "2020-02-17T18:16:16Z", "latestArrivalDate": "2020-02-17T18:16:16Z", "fulfillmentPreviewItems": [ { "sellerSku": "PSMM-TEST-SKU-Jan-21_19_39_23-0788", "quantity": 1, "sellerFulfillmentOrderItemId": "OrderItemID2", "estimatedShippingWeight": { "unit": "POUNDS", "value": "20" }, "shippingWeightCalculationMethod": "Package" } ] } ], "unfulfillablePreviewItems": [], "marketplaceId": "ATVPDKIKX0DER", "featureConstraints": [ { "featureName": "BLANK_BOX", "featureFulfillmentPolicy": "Required" }, { "featureName": "BLOCK_AMZL", "featureFulfillmentPolicy": "Required" } ] } ] } ``` -------------------------------- ### Example Request for Solicitation Actions Source: https://github.com/saleweaver/python-amazon-sp-api/blob/master/docs/_static/redoc/solicitations.html This example demonstrates how to structure a request to get available solicitation actions for an order, including the necessary parameters like amazonOrderId and marketplaceIds. ```json { "request": { "parameters": { "amazonOrderId": {"value": "123-1234567-1234567"}, "marketplaceIds": {"value": ["ATVPDKIKX0DER"]} } }, "response": { "_links": { "actions": [ { "href": "/solicitations/v1/orders/123-1234567-1234567/solicitations/productReviewAndSellerFeedback?marketplaceIds=ATVPDKIKX0DER", "name": "productReviewAndSellerFeedback" } ], "self": { "href": "/solicitations/v1/orders/123-1234567-1234567?marketplaceIds=ATVPDKIKX0DER" } } } } ``` -------------------------------- ### Initialize Mark.js with Options Source: https://github.com/saleweaver/python-amazon-sp-api/blob/master/docs/_static/redoc/fbaInbound.html Demonstrates how to initialize the Mark.js library with custom options for wildcard and synonym handling. Ensure options are correctly configured before use. ```javascript var instance = new Mark(document.querySelector("div")).mark("lorem ipsum", { wildcards: "withSpaces", separateWordSearch: true, synonyms: { "dolor": "sit", "amet": "consectetur" } }); ``` -------------------------------- ### Generate Schema Example Source: https://github.com/saleweaver/python-amazon-sp-api/blob/master/docs/_static/redoc/tokens_2021-03-01.html Generates an example value for a given JSON schema. Handles references, examples, and default values. Use this to get a sample data structure based on your schema. ```javascript function ml(e,t,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(void 0===e)return null;if(e.$ref){if(!n)throw new Error("Your schema contains $ref. You must provide full specification in the third parameter.");var i=decodeURIComponent(e.$ref);i.startsWith("#")&&(i=i.substring(1));var s,l=Ka().get(n,i);return!0!==dl[i]?(dl[i]=!0,s=ml(l,t,n,r),dl[i]=!1):s=cl(fl(l)),ul(hl,r),s}if(void 0!==e.example)return ul(hl,r),{value:e.example,readOnly:e.readOnly,writeOnly:e.writeOnly,type:e.type};if(void 0!==e.allOf)return ul(hl,r),function(e,t,n,r,o){var i,s=ml(e,n,r),l=[],c=ro(t);try{for(c.s();!(i=c.n()).done;){var u=i.value,p=ml(a({type:s.type},u),n,r,o),f=p.type,d=p.readOnly,h=p.writeOnly,m=p.value;s.type&&f&&f!==s.type&&(console.warn("allOf: schemas with different types can't be merged"),s.type=f),s.type=s.type||f,s.readOnly=s.readOnly||d,s.writeOnly=s.writeOnly||h,null!=m&&l.push(m)}}catch(e){c.e(e)}finally{c.f()}if("object"===s.type)return s.value=ll.apply(void 0,[s.value||{}].concat(es(l.filter((function(e){return"object"==typeof e})))),s;"array"===s.type&&(n.quiet||console.warn('OpenAPI Sampler: found allOf with \"array\" type. Result may be incorrect'));var v=l[l.length-1];return s.value=null!=v?v:s.value,s}(a(a({},e),{},{allOf:void 0}),e.allOf,t,n,r);if(e.oneOf&&e.oneOf.length)return e.anyOf&&(t.quiet||console.warn("oneOf and anyOf are not supported on the same level. Skipping anyOf")),ul(hl,r),ml(e.oneOf[0],t,n,r);if(e.anyOf&&e.anyOf.length)return ul(hl,r),ml(e.anyOf[0],t,n,r);if(e.if&&e.then)return ml(ll(e.if,e.then),t,n,r);var c=null,u=null;if(void 0!==e.default)c=e.default;else if(void 0!==e.const)c=e.const;else if(void 0!==e.enum&&e.enum.length)c=e.enum[0];else if(void 0!==e.examples&&e.examples.length)c=e.examples[0];else{u=e.type,Array.isArray(u)&&e.type.length>0&&(u=e.type[0]),u||(u=fl(e));var p=xl[u];p&&(c=p(e,t,n,r))}return ul(hl,r),{value:c,readOnly:e.readOnly,writeOnly:e.writeOnly,type:u}} ``` -------------------------------- ### Lunr.js Initialization and Configuration Source: https://github.com/saleweaver/python-amazon-sp-api/blob/master/docs/_static/redoc/fulfillmentInboundV0.html Demonstrates the basic setup for Lunr.js, including building a search index with specific pipeline functions. ```javascript var o,s,a,u,c,l,f,h,p,d,v,y,g,m,x,w,b,E,S,L,k,T,P,O,Q,j=function(e){var t=new R.Builder;return t.pipeline.add(R.trimmer,R.stopWordFilter,R.stemmer),t.searchPipeline.add(R.stemmer),e.call(t,t),t.build()};R.version="2.3.9",R.utils={},R.utils.warn=(o=this,function(e){o.console&&console.warn&&console.warn(e)}),R.utils.asString=function(e){return null==e?"":e.toString()},R.utils.clone=function(e){if(null==e)return e;for(var t=Object.create(null),r=Object.keys(e),n=0;n=1;--a) if(47===(n=e.charCodeAt(a))){ if(!i){o=a;break}} else i=!1; return-1===o?r?"/":".":r&&1===o?"//":e.slice(0,o) ``` -------------------------------- ### Redoc Initialization with Options Source: https://github.com/saleweaver/python-amazon-sp-api/blob/master/docs/_static/redoc/sales.html Initializes the Redoc component with specified options and handles the loading state. It takes spec, specUrl, options, and an onLoaded callback. ```javascript Tb=function(e){var t=e.spec,n=e.specUrl,r=e.options,o=void 0===r?{}:r,i=e.onLoaded,a=xo(o.hideLoading,!1),l=new ko(o);return s.createElement(Ra,null,s.createElement(gc,{spec:t,specUrl:n,options:o,onLoaded:i},(function(e){var t=e.loading,n=e.store;return t?null:s.createElement(Cb,{store:n})})))} ``` -------------------------------- ### Get Catalog Items Example Source: https://github.com/saleweaver/python-amazon-sp-api/blob/master/docs/_static/redoc/feeds_2021-06-30.html Retrieves details about products in your catalog. Requires a list of ASINs or SKUs. ```python from sp_api.api import Catalog from sp_api.base import Marketplaces client = Catalog() # Example: Get catalog items for a list of ASINs in the US marketplace asins = ['B0EXAMPLE1', 'B0EXAMPLE2'] response = client.get_catalog_items(marketplaceIds=[Marketplaces.US.marketplaceId], asins=asins) if response.payload: for item in response.payload.get('items', []): print(f"ASIN: {item['asin']}, Product Type: {item['productType']}") else: print("No catalog items found or an error occurred.") print(response.error) ``` -------------------------------- ### Get Orders Source: https://github.com/saleweaver/python-amazon-sp-api/blob/master/docs/_static/redoc/listingsItems_2021-08-01.html Example of fetching orders using the SP API client. Specify order filter criteria. ```python from sp_api.api import SPAPI from sp_api.base.models import OrderFilter spapi = SPAPI(refresh_token='YOUR_REFRESH_TOKEN', client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET', aws_access_key_id='YOUR_AWS_ACCESS_KEY_ID', aws_secret_access_key='YOUR_AWS_SECRET_ACCESS_KEY', region='us-east-1') # Define order filters filters = OrderFilter(marketplaceIds=['ATVPDKIKX0DER'], CreatedAfter='2023-01-01T00:00:00Z') # Get orders response = spapi.orders.get_orders(filters=filters) # Process the response print(response.payload) ``` -------------------------------- ### Initialize and build an index Source: https://github.com/saleweaver/python-amazon-sp-api/blob/master/docs/_static/redoc/productPricingV0.html Demonstrates how to initialize a new index builder, set the reference field, and add fields. This is a prerequisite for adding documents to the index. ```javascript R.Builder.prototype.ref=function(e){this._ref=e} ```