# Macys Trending Products (`pintostudio/macys-trending-products`) Actor

The Macy's Trending Products actor extracts trending and popular products from Macy's online store. It provides access to various product sorting options including featured items, price ranges, top-rated products, best sellers, and new arrivals.

- **URL**: https://apify.com/pintostudio/macys-trending-products.md
- **Developed by:** [Pinto Studio](https://apify.com/pintostudio) (community)
- **Categories:** E-commerce, Other, Developer tools
- **Stats:** 3 total users, 0 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$7.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Macy's Trending Products - Apify Actor Documentation

### Overview

The **Macy's Trending Products** actor extracts trending and popular products from Macy's online store. It provides access to various product sorting options including featured items, price ranges, top-rated products, best sellers, and new arrivals.

### Features

- ✅ Multiple sorting options (featured, price, ratings, popularity)
- ✅ Pagination support for large datasets
- ✅ Regional customization (US market)
- ✅ Currency selection (USD)
- ✅ Built-in rate limiting to respect website policies
- ✅ Comprehensive product data extraction

### Input Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `page` | Integer | No | `1` | Page number for pagination |
| `perPage` | Integer | No | `60` | Number of products per page (max 60) |
| `regionCode` | String | No | `'US'` | Region code for localized results |
| `currencyCode` | String | No | `'USD'` | Currency code for pricing |
| `sortBy` | String | **Yes** | `'featuredItems'` | Sort order for products |

#### Available Sort Options

| Key | Value | Description |
|-----|-------|-------------|
| `featuredItems` | `ORIGINAL` | Default featured products |
| `priceLowToHigh` | `PRICE_LOW_TO_HIGH` | Sort by price ascending |
| `priceHighToLow` | `PRICE_HIGH_TO_LOW` | Sort by price descending |
| `topRated` | `TOP_RATED` | Highest rated products first |
| `bestSellers` | `BEST_SELLERS` | Best selling products |
| `newItems` | `NEW_ITEMS` | Newest arrivals |

### Input Example

```json
{
  "page": 1,
  "perPage": 50,
  "regionCode": "US",
  "currencyCode": "USD",
  "sortBy": "bestSellers"
}
```

### Output Structure

The actor returns detailed product information including:

#### Product Details

- **Basic Info**: ID, name, brand, type
- **Pricing**: Regular price, sale price, discounts, promotional offers
- **Availability**: Stock status, active status
- **Reviews**: Average rating, review count
- **Images**: Primary and additional product images
- **Colors**: Available color variations with swatches
- **URLs**: Direct product page links

#### Example Output

```json
{
    "products": [
      {
        "id": 11318480,
        "detail": {
          "name": "Men's Modern-Fit Bi-Stretch Suit",
          "brand": "Nautica",
          "reviewStatistics": {
            "aggregate": {
              "rating": 3.9,
              "count": 2491
            }
          }
        },
        "pricing": {
          "price": {
            "tieredPrice": [
              {
                "label": "[PRICE]",
                "values": [{"value": 395, "formattedValue": "$395.00"}]
              },
              {
                "label": "Sale [PRICE]",
                "values": [{"value": 99.99, "formattedValue": "$99.99", "percentOff": [75]}]
              }
            ]
          }
        },
        "traits": {
          "colors": {
            "colorMap": [
              {"name": "Blue plaid", "normalName": "Blue"},
              {"name": "Light Blue", "normalName": "Blue"},
              {"name": "Charcoal solid", "normalName": "Black"}
            ]
          }
        },
        "url": "https://www.macys.com/shop/product/nautica-mens-modern-fit-bi-stretch-suit?ID=11318480"
      }
    ],
    "pagination": {
      "page": 1,
      "perPage": 61,
      "totalAvailable": 187815,
      "totalPages": 3079,
      "hasNext": true
    }
  }

```

### Usage Examples

#### Get Featured Items

```json
{
  "sortBy": "featuredItems",
  "page": 1,
  "perPage": 30
}
```

#### Find Budget-Friendly Options

```json
{
  "sortBy": "priceLowToHigh",
  "page": 1,
  "perPage": 50
}
```

#### Discover New Arrivals

```json
{
  "sortBy": "newItems",
  "page": 1,
  "perPage": 25
}
```

#### Browse Best Sellers

```json
{
  "sortBy": "bestSellers",
  "page": 2,
  "perPage": 60
}
```

### Rate Limiting

The actor implements built-in rate limiting with random delays (0-900ms) between requests to ensure respectful data extraction and avoid overwhelming Macy's servers.

### Error Handling

#### Common Errors

- **Missing sortBy**: Actor will throw an error if no sortBy parameter is provided
- **Invalid sortBy**: Actor validates against available options and provides helpful error messages
- **Network Issues**: Built-in retry mechanisms handle temporary connection problems

#### Error Response Example

```
Error: Invalid sortBy option: 'invalidOption'. Available options are: featuredItems, priceLowToHigh, priceHighToLow, topRated, bestSellers, newItems
```

### Data Storage

- Results are automatically pushed to the default dataset
- Complete results are stored in the `output` key-value store
- Each successful run generates structured JSON output

### Best Practices

1. **Start Small**: Begin with smaller `perPage` values to test your workflow
2. **Respect Rate Limits**: The actor includes delays, but avoid running multiple instances simultaneously
3. **Monitor Pagination**: Use `hasNext` field to determine if more pages are available
4. **Handle Large Datasets**: For large scraping jobs, implement proper pagination loops
5. **Data Validation**: Always validate the output structure matches your needs

### Technical Requirements

- **Platform**: Apify
- **Node.js**: Compatible with Apify's runtime environment
- **Dependencies**: Uses Apify SDK and custom product extraction modules
- **Memory**: Recommended minimum 1GB for optimal performance

### Support & Troubleshooting

If you encounter issues:

1. Verify your input parameters match the required format
2. Check that `sortBy` uses one of the valid options
3. Ensure pagination parameters are within reasonable limits
4. Monitor actor logs for detailed error messages

For additional support, refer to the Apify documentation or contact us.

# Actor input Schema

## `currencyCode` (type: `string`):

The currency code

## `regionCode` (type: `string`):

The region code

## `page` (type: `string`):

The page Index

## `perPage` (type: `string`):

Limit per Page

## `sortBy` (type: `string`):

Select the sorting method for the items.

## Actor input object example

```json
{
  "currencyCode": "USD",
  "regionCode": "US",
  "page": "1",
  "perPage": "20",
  "sortBy": "featuredItems"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "currencyCode": "USD",
    "regionCode": "US",
    "page": "1",
    "perPage": "20",
    "sortBy": "featuredItems"
};

// Run the Actor and wait for it to finish
const run = await client.actor("pintostudio/macys-trending-products").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "currencyCode": "USD",
    "regionCode": "US",
    "page": "1",
    "perPage": "20",
    "sortBy": "featuredItems",
}

# Run the Actor and wait for it to finish
run = client.actor("pintostudio/macys-trending-products").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "currencyCode": "USD",
  "regionCode": "US",
  "page": "1",
  "perPage": "20",
  "sortBy": "featuredItems"
}' |
apify call pintostudio/macys-trending-products --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,pintostudio/macys-trending-products"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/G8BDirC0ijRvgeHgh/builds/jeIXnzADeoM8RWKny/openapi.json
