文档中心 > Miravia Open Platform

Miravia - Feed API best practice

更新时间:2023/08/25 访问次数:945

FeedAPI API call flow

There are in toal of 5 API endpoints included in the FeedAPI, please find below the recommended flowfrom Miravia to call our Feed API:

image

Recommend Prerequisite

Batch Validation Endpoint : For PRODUCT_LISTING , It is strongly recommended that use this endpoint to verify your listing request before creating a Feed task. This endpoint will return all errors regarding your request.

Step 1 CreateFeedDocument

API Document

Initiate a task to create documents which can be accessd by Miravia, specifying the content type for the feed that you are submitting. returns a feedDocumentId value and a URL for uploading the feed contents. We only support "application/json" at the moment.

Request example:

{
    "content_type":"application/json"
}

Response example:

{
    "feed_result":{
        "result":{
            "feed_document_id":"e702ddea-e703-43e2-b30a-5f9c5944c044.4000002768003",
            "url":"https://airse-open-feed.oss-eu-central-1.aliyuncs.com/e702ddea-e703-43e2-b30a-5f9c5944c044.4000002768003.json?Expires=1658472289&OSSAccessKeyId=LTAI5tPS8gpPYr9xZ5WcvRLU&Signature=G10tIi2NDqh%2BIIkcBkEYJCHvwgo%3D"
        },
        "success":true
    },
    "code":"0",
    "request_id":"21038f5516584686892251082"
}

Upload your feed document

Upload your feed document (which must be in JSON format) using the URL of the CreateFeedDocument API response.

Request Method: PUT

HTTP Request Example

<dependency>    
  <groupId>org.apache.httpcomponents</groupId>     
  <artifactId>httpclient</artifactId>     
  <version>${your version}</version> 
</dependency>
HttpPut httpPut = new HttpPut("/feed/createFeedDocument api response url"); 
BasicHttpEntity httpEntity = new BasicHttpEntity(); 
httpEntity.setContent("your file InputStream"); 
httpEntity.setContentLength("your file size"); 
httpEntity.setContentType("/feed/createFeedDocument api input parameter content_type"); 
httpPut.setEntity(httpEntity); 
CloseableHttpClient httpClient = HttpClients.createDefault(); 
CloseableHttpResponse response = httpClient.execute(httpPut, HttpClientContext.create());
  • After successful transmission, it will respond with http code 200.
  • The feed document format will be shown at the end of the article.

Step 2 CreateFeed

API Document

Call the CreateFeed operation to specify the feed document identifier, the feed type.

Request example:

{
    "feed_type":"PRODUCT_LISTING",
    "feed_document_id":"9d350a9a-7861-46b5-b404-2e05f22765c2.1001"
}
  • "feed_document_id" cannot be reused

Response example:

{
    "feed_result":{
        "result":52,
        "success":true
    },
    "code":"0",
    "request_id":"21038f5516584687399921083"
}
  • Save the feedId value. Pass this value in the getFeed operation

Step 3 GetFeed

API Document

After you call the createFeed operation, Miravia receives the request and begins to process the feed. You must confirm that processing has completed before you continue.

Request example:

{
    "feed_id":"52"
}

Response example:

feed Document processing completed response

{
    "feed_result":{
        "result":{
            "processing_end_time":"2022-07-22 13:46:03",
            "created_time":"2022-07-22 07:45:40",
            "processing_status":"DONE",
            "result_feed_document_id":"ddead6cc-fb4b-487c-9ddb-e97557e847bc.4000002768003",
            "feed_type":"PRODUCT_LISTING",
            "processing_start_time":"2022-07-22 13:46:02",
            "feed_id":52
        },
        "success":true
    },
    "code":"0",
    "request_id":"21038f5516584771545771123"
}

feed document is processing the response

{
    "feed_result":{
        "result":{
            "created_time":"2022-07-22 07:19:26",
            "processing_status":"IN_PROGRESS",
            "feed_type":"PRODUCT_LISTING",
            "processing_start_time":"2022-07-22 13:20:02",
            "feed_id":51
        },
        "success":true
    },
    "code":"0",
    "request_id":"21038f5516584771752521124"
}

The following processingStatus values confirm that processing is complete:

  • DONE - feed processing is complete.
  • CANCELLED - the feed was cancelled before it began to process. If you want to resubmit the feed, go to CreateFeedDocument
  • FATAL - the feed was abandoned due to a fatal error. Some, none, or all of the operations within the feed might have completed successfully.

Get the result from the response URL

Request Method: GET

Content-Type: application/json

Response Example

Processing success

{
    "Product":{
        "feedId":54,
        "gmtCreate":1658456282000,
        "gmtModified":1658456282000,
        "id":25,
        "index":"Product",
        "status":"SUCCESS"
    }
}

Processing Failure

{
    "Product":{
        "detail":"{\"traceId\":\"210380cf16584781216872846dac87\",\"message\":\"{\\\"errorCode\\\":\\\"500\\\",\\\"errorDetail\\\":[{\\\"code\\\":\\\"THD_IC_ERR_F_IC_INFRA_PRODUCT_036\\\",\\\"seller_sku\\\":\\\"\\\",\\\"field\\\":\\\"Product\\\",\\\"message\\\":\\\"THD_IC_ERR_F_IC_INFRA_PRODUCT_036:Insert sku outer id relation failed, outerId already exists, sell ID:4,000,002,768,003,sku ID:2,068,481,467,064,734,outer ID:test-product-creatation-for-api-chasetest11123,serverIP:33.27.90.239\\\"}],\\\"errorMsg\\\":\\\"E500: Create product failed\\\",\\\"errors\\\":[{\\\"code\\\":\\\"THD_IC_ERR_F_IC_INFRA_PRODUCT_036\\\",\\\"field\\\":\\\"Product\\\",\\\"sellerSku\\\":\\\"\\\",\\\"message\\\":\\\"THD_IC_ERR_F_IC_INFRA_PRODUCT_036:Insert sku outer id relation failed, outerId already exists, sell ID:4,000,002,768,003,sku ID:2,068,481,467,064,734,outer ID:test-product-creatation-for-api-chasetest11123,serverIP:33.27.90.239\\\"}],\\\"success\\\":false}\"}",
        "feedId":55,
        "gmtCreate":1658456522000,
        "gmtModified":1658456522000,
        "id":26,
        "index":"Product",
        "status":"FAIL"
    }
}

Feed document example (JSON format)

PRODUCT_LISTING

Optional attributes can be added or removed, the rules are the same as the createproduct api

{
    "Product":{
        "PrimaryCategory":62198631,
        "Images":{
            "Image":[
                "https://fb-es.mrvcdn.com/kf/Ed72d9145a56c45668e374567eb5e283df.jpg"
            ]
        },
        "Attributes":{
            "name":"test product creatation",
            "short_description":"test product highlights",
            "description":"test product description",
            "brand":"No Brand",
            "model":"test model",
            "type_tools":"Electronic",
            "warranty_type":"Local Supplier Warranty",
            "warranty":"12 Years",
            "Hazmat":"Battery,Flammable"
        },
        "Skus":{
            "Sku":[
                {
                    "quantity":"1",
                    "SellerSku":"test-product-creatation-for-api-chasetest11123",
                    "color_family":"Black",
                    "ean_code":"123",
                    "special_price":"11",
                    "price":"23",
                    "package_length":"1",
                    "package_weight":"1",
                    "package_content":"test what's in the box",
                    "package_width":"1",
                    "package_height":"1",
                    "Images":{
                        "Image":[
                            "https://fb-es.mrvcdn.com/kf/Ed72d9145a56c45668e374567eb5e283df1.jpg"
                        ]
                    }
                }
            ]
        }
    },
    "Product2":{
    },
    "Product3":{
    }
}

POST_PRODUCT_PRICING_QUATITY_DATA

{
    "updateTask1":{
        "Sku":{
            "ItemId":"1355777715065245",
            "SkuId":"2068481483383197",
            "SellerSku":"test-product-creatation-for-api-chasetest11123",
            "Price":"1000",
            "SalePrice":"995",
            "Quantity":"1000"
        }
    },
    "updateTask2":{
    }
}

UPDATE_PRODUCT_SELLABLE_STOCK

{
  "test_nacho_feeds_22032023_2_1":{
    "Sku":{
      "ItemId":"1356100789103878",
      "SellerSku":"test_nacho_feeds_22032023_2_1",
      "MultiWarehouseInventories":{
        "MultiWarehouseInventory":[
          {
            "WarehouseCode":"dropshipping",
            "SellableQuantity":40
          }
        ]
      }
    }
  },
  "test_nacho_feeds_22032023_2_2":{
    "Sku":{
      "ItemId":"1356100789103878",
      "SellerSku":"test_nacho_feeds_22032023_2_1",
      "MultiWarehouseInventories":{
        "MultiWarehouseInventory":[
          {
            "WarehouseCode":"dropshipping",
            "SellableQuantity":40
          }
        ]
      }
    }
  }
}

FAQ

关于此文档暂时还没有FAQ
返回
顶部