drkbcn/json_listings_feed

Transform legacy Amazon XML feeds into the new JSON_LISTINGS_FEED format for SP-API.

dev-main 2025-07-26 10:20 UTC

This package is auto-updated.

Last update: 2025-07-26 10:22:47 UTC


README

Transform your legacy Amazon XML feeds into the new JSON_LISTINGS_FEED format for SP-API. Free and Open Source!

Ko-fi

๐Ÿš€ Why this project?

Amazon is deprecating its legacy XML and flat-file feeds and migrating to the new JSON_LISTINGS_FEED format for SP-API. While the excellent jlevers/selling-partner-api library provides comprehensive SP-API access (and is completely free!), the author also created a separate commercial feed transformer tool by Highside Labs that charges $299-$899 per feed type to handle this migration.

At @labelgrupnetworks, we faced the same situation and needed a cost-effective solution, so we built this free and open-source transformer for the community.

โœจ Features

  • ๐Ÿ”„ Transform legacy Amazon XML to JSON_LISTINGS_FEED
  • ๐Ÿ›’ Supports inventory, pricing, product, image, and relationship feeds
  • ๐Ÿงฉ Direct integration with jlevers/selling-partner-api
  • ๐Ÿ†“ 100% Open Source and free
  • ๐Ÿท๏ธ Designed for migrations and automations
  • ๐Ÿ› ๏ธ Easy to use, no commercial dependencies
  • ๐Ÿ“ฆ Uses PATCH operations for optimal performance

๐Ÿ“ฆ Installation

git clone https://github.com/drkbcn/json_listings_feed.git
cd json_listings_feed
composer install

Copy .env.example to .env and configure your Amazon SP-API credentials.

๐Ÿ“ Quick Usage

Basic Transformation

use Labelgrup\AmazonTransformer\Transformer;

$transformer = new Transformer($sellerId, $marketplaceId);
$json = $transformer->transformXmlToJson($xmlContent);
echo $json;

Complete Workflow (Inventory Update)

use Labelgrup\AmazonTransformer\{AmazonXMLFunctions, Transformer};
use SellingPartnerApi\{FeedType, Api\FeedsV20210630Api};

// Generate XML (for compatibility with existing systems)
$xmlBuilder = new AmazonXMLFunctions($sellerId);
$messages = [$xmlBuilder->getQtyMessage($sku, $newQuantity)];
$xmlContent = $xmlBuilder->buildXmlInventoryData($messages);

// Transform to JSON
$transformer = new Transformer($sellerId, $marketplaceId);
$jsonOutput = $transformer->transformXmlToJson($xmlContent);

// Send to Amazon
$feedsApi = new FeedsV20210630Api($config);
// ... (see examples for complete implementation)

๐Ÿง‘โ€๐Ÿ’ป Migration Examples

Inventory Update

Old XML Format:

<AmazonEnvelope>
  <Header>
    <DocumentVersion>1.01</DocumentVersion>
    <MerchantIdentifier>A3UM3SGRVK155I</MerchantIdentifier>
  </Header>
  <MessageType>Inventory</MessageType>
  <Message>
    <MessageID>1</MessageID>
    <OperationType>Update</OperationType>
    <Inventory>
      <SKU>B0182SJFQQ</SKU>
      <Quantity>5</Quantity>
    </Inventory>
  </Message>
</AmazonEnvelope>

New JSON Format (Generated):

{
  "header": {
    "sellerId": "A3UM3SGRVK155I",
    "version": "2.0",
    "issueLocale": "es_ES"
  },
  "messages": [
    {
      "messageId": 1,
      "sku": "B0182SJFQQ",
      "operationType": "PATCH",
      "productType": "PRODUCT",
      "patches": [
        {
          "op": "replace",
          "path": "/attributes/fulfillment_availability",
          "value": [
            {
              "fulfillment_channel_code": "DEFAULT",
              "quantity": 5
            }
          ]
        }
      ]
    }
  ]
}

Price Update

Old XML Format:

<AmazonEnvelope>
  <MessageType>Price</MessageType>
  <Message>
    <MessageID>1</MessageID>
    <OperationType>Update</OperationType>
    <Price>
      <SKU>RS-7IGC-AFXK</SKU>
      <StandardPrice currency="EUR">18.78</StandardPrice>
    </Price>
  </Message>
</AmazonEnvelope>

New JSON Format (Generated):

{
  "messages": [
    {
      "messageId": 1,
      "sku": "RS-7IGC-AFXK",
      "operationType": "PATCH",
      "productType": "PRODUCT",
      "patches": [
        {
          "op": "replace",
          "path": "/attributes/purchasable_offer",
          "value": [
            {
              "audience": "ALL",
              "currency": "EUR",
              "our_price": [
                {
                  "schedule": [
                    {
                      "value_with_tax": 18.78
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

๐Ÿงช Examples & Testing

Available Examples

  • examples/inventory.php โ€” Complete inventory update workflow
  • examples/pricing.php โ€” Complete pricing update workflow

Utility Scripts

  • check_feed.php โ€” Monitor feed processing status
  • check_product.php โ€” Get product information and pricing details

Running Examples

# Update inventory
php examples/inventory.php

# Update pricing
php examples/pricing.php

# Check feed status
php check_feed.php [feedId] [--detailed]

# Get product info
php check_product.php [SKU]

๐Ÿ”ง Supported Feed Types

  • โœ… POST_INVENTORY_AVAILABILITY_DATA - Inventory quantity updates
  • โœ… POST_PRODUCT_PRICING_DATA - Product pricing updates
  • โœ… POST_PRODUCT_DATA - Product information updates
  • โœ… POST_PRODUCT_IMAGE_DATA - Product image updates
  • โœ… POST_PRODUCT_RELATIONSHIP_DATA - Variation relationships

๐Ÿข About Us

Created with โค๏ธ by @drkbcn at Labelgrup Networks.

๐Ÿค Contributing

Did this project save you money? Consider:

  • โญ Starring this repository
  • ๐Ÿ› Reporting issues or requesting features
  • ๐Ÿ”€ Contributing code improvements
  • โ˜• Buying me a coffee

๐Ÿ“„ License

MIT License - Free to use, modify, and distribute!

๏ฟฝ Credits

  • Inspiration: Amazon Sellers community facing migration challenges
  • Built on: jlevers/selling-partner-api (the excellent free SP-API library)
  • Alternative to: Highside Labs' commercial Feed Transformer (which charges $299-$899 per feed type)

๐Ÿ“š Resources

We hope this helps you migrate your Amazon integrations without breaking the bank! ๐Ÿ’ฐ