# Getting started

Once you've installed your packages as described in the [last section](/feed-transformer/quickstart.md), you can start converting feeds. It's really simple.

### Convert a feed file

Say you want to convert your `POST_PRODUCT_IMAGE_FEED` into a forward-compatible JSON format. Here's all you need to do:

```php
use SellingPartnerApi\FeedTransformer\Transformer;
use SellingPartnerApi\FeedTransformer\FeedTypes\ProductImage;

$feedPath = 'path/to/your/feed.xml';
$json = Transformer::fromFile(
    ProductImage::$feedType,  // -> POST_PRODUCT_IMAGE_DATA
    $feedPath,
    'ATVPDKIKX0DER'  // -> US Selling Partner API marketplace ID
);

$jsonFeedPath = 'path/to/new/feed.json';
file_put_contents($jsonFeedPath, json_encode($json));
```

The third parameter, `marketplaceId`, should be a valid Selling Partner API marketplace ID (full list [here](https://developer-docs.amazon.com/sp-api/docs/marketplace-ids)) corresponding to the marketplace that you're uploading the feed to.

That's it! You can now upload the file at `$jsonFeedPath` to Amazon the same way you were uploading your original feed, but replacing the original feed type (`POST_PRODUCT_IMAGE_FEED`) with `JSON_LISTINGS_FEED` in your request.

### Convert a feed file from a string

Instead of passing a file path to the converter, you can pass the feed contents to `Converter::convertFromString()` instead:

```php
use SellingPartnerApi\FeedTransformer\Transformer;
use SellingPartnerApi\FeedTransformer\FeedTypes\ProductImage;

$feedContents = '.....';
$json = Transformer::fromString(
    ProductImage::$feedType,  // -> POST_PRODUCT_IMAGE_DATA
    $feedContents,
    'ATVPDKIKX0DER'  // -> US Selling Partner API marketplace ID
);

$jsonFeedPath = 'path/to/new/feed.json';
file_put_contents($jsonFeedPath, json_encode($json));
```

### Feed-specific options

There's a fourth, optional argument to `Converter::convert()` and `Converter::convertFromString()`: an array of feed-type-specific parameters. Some feed types do not have any extra parameters, like the `POST_PRODUCT_IMAGE_FEED` used in the example above

All flat file feed types require an extra `merchantId` parameter. You can find your region-specific Amazon merchant ID [here](/feed-transformer/feed-types/xml.md).

{% hint style="info" %}
(If you primarily sell outside the US and that merchant ID link doesn't work for you, try copying it and replacing `sellercentral.amazon.com` with the Seller Central URL that you usually use.)
{% endhint %}

Here's what it looks like to pass feed-type-specific parameters:

```php
use SellingPartnerApi\FeedTransformer\Transformer;
use SellingPartnerApi\FeedTransformer\FeedTypes\Invloader;

$feedFile = 'path/to/your/feed.xml';
$json = Transformer::fromFile(
    Invloader::$feedType,  // -> POST_FLAT_FILE_INVLOADER_DATA
    $feedFile,
    'ATVPDKIKX0DER',
    ['merchantId' => 'A2DI..........']
);

$jsonFeedPath = 'path/to/new/feed.json';
file_put_contents($jsonFeedPath, json_encode($json));
```

Feed-specific parameters are defined on the individual feed type documentation pages.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.highsidelabs.co/feed-transformer/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
