# Retrieve Sales Performance Reports — Selling Partner API (SP-API)

> Fetches sales reports for visualization in third-party dashboarding tools. See the documentation

- Key: `amazon_selling_partner-retrieve-sales-performance-reports`
- Type: Action (Read-only)
- Version: 0.0.5
- App: Selling Partner API (SP-API) (`amazon_selling_partner`) — https://pipedream.com/apps/amazon-selling-partner.md
- This page (HTML): https://pipedream.com/apps/amazon-selling-partner/actions/retrieve-sales-performance-reports
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/amazon_selling_partner/actions/retrieve-sales-performance-reports/retrieve-sales-performance-reports.mjs

## Description

Fetches sales reports for visualization in third-party dashboarding tools. [See the documentation](https://developer-docs.amazon.com/sp-api/reference/getordermetrics)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `marketplaceId` | `string` | Yes | The Amazon Marketplace ID Options are loaded from the connected account. |
| `interval` | `string` | Yes | A time interval used for selecting order metrics. This takes the form of two dates separated by two hyphens (first date is inclusive; second date is exclusive). Dates are in ISO8601 format and must represent absolute time (either Z notation or offset notation). Example: 2018-09-01T00:00:00-07:00--2018-09-04T00:00:00-07:00 requests order metrics for Sept 1st, 2nd and 3rd in the -07:00 zone. |
| `granularity` | `string` | Yes | The granularity of the grouping of order metrics, based on a unit of time |
| `granularityTimeZone` | `string` | No | An IANA-compatible time zone for determining the day boundary. Required when specifying a granularity value greater than Hour. |
| `buyerType` | `string` | No | Filters the results by the buyer type that you specify, B2B (business to business) or B2C (business to customer). Example: B2B, if you want the response to include order metrics for only B2B buyers. |
| `fulfillmentNetwork` | `string` | No | Filters the results by the fulfillment network that you specify, MFN (merchant fulfillment network) or AFN (Amazon fulfillment network). Do not include this filter if you want the response to include order metrics for all fulfillment networks. Example: AFN, if you want the response to include order metrics for only Amazon fulfillment network. |
| `firstDayOfWeek` | `string` | No | Specifies the day that the week starts on when granularity=Week, either Monday or Sunday. Default: Monday. Example: Sunday, if you want the week to start on a Sunday. |
| `asin` | `string` | No | Filters the results by the ASIN that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all ASINs. Example: B0792R1RSN, if you want the response to include order metrics for only ASIN B0792R1RSN. |
| `sku` | `string` | No | Filters the results by the SKU that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all SKUs. Example: TestSKU, if you want the response to include order metrics for only SKU TestSKU. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "amazon_selling_partner",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "amazon_selling_partner-retrieve-sales-performance-reports",
  arguments: {
    marketplaceId: "Marketplace ID",
    interval: "Interval",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "amazon_selling_partner-retrieve-sales-performance-reports",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    amazon_selling_partner: { authProvisionId: "apn_xxxxxxx" },
    marketplaceId: "Marketplace ID",
    interval: "Interval",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "amazon_selling_partner-retrieve-sales-performance-reports",
    "configured_props": {
      "amazon_selling_partner": { "authProvisionId": "apn_xxxxxxx" },
      "marketplaceId": "Marketplace ID",
      "interval": "Interval"
    }
  }'
```

---

- App: https://pipedream.com/apps/amazon-selling-partner.md · All apps: https://pipedream.com/apps
