# MercadoLibre Trends Scraper (`stilled_stalagmite/mercadolibre-trends-scraper`) Actor

Scrape trending searches and popular products on MercadoLibre to spot market trends early.

- **URL**: https://apify.com/stilled\_stalagmite/mercadolibre-trends-scraper.md
- **Developed by:** [Danilo Frias](https://apify.com/stilled_stalagmite) (community)
- **Categories:** E-commerce, Marketing
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 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

## MercadoLibre Trends Scraper

Scrapes **public, logged-out** trending searches and trending products from
MercadoLibre Mexico's trends surfaces (`tendencias.mercadolibre.com.mx`).
No login, no session cookies, no proxies, no CAPTCHA solving.

Who would use it: market researchers, ecommerce sellers, and SEO teams who
want to know what Mexican MercadoLibre shoppers are searching for right now
(e.g. spotting demand spikes for air conditioners, iPhones, or sneakers before
sourcing inventory).

### How it works

The trends pages server-render their data inside a
`__NORDIC_RENDERING_CTX__` JSON payload. The actor:

1. Fetches the start URL(s) (default: the Mexico trends homepage).
2. Parses the four trend modules (`featuredTrends`,
   `increasedSearchGrowthTrends`, `higherRevenueTrends`, `shortTailTrends`).
3. Discovers category trend pages from each page's navigation (category URLs
   follow the pattern `/{id-number}-{slug}`, e.g.
   `/1743-accesorios_para_vehiculos`) and crawls them up to a depth of 3.
4. Stops at `max_items` rows; dedupes repeated terms within a category.
5. Pushes one record per unique trend term.

### Inputs

| Field | Type | Default | Description |
|---|---|---|---|
| `start_urls` | array of strings | `["https://tendencias.mercadolibre.com.mx/"]` | Public trends page URLs to begin from. Category pages are discovered automatically. |
| `max_items` | integer | `200` | Maximum trend records to scrape before stopping. |
| `country` | string | `"mx"` | Country site. Supported: `mx`, `ar`, `co`, `cl`, `pe`, `br`, `uy`. Each maps to that country's `tendencias.*` host. |

### Sample output record

```json
{
  "trend_term": "magnum 22 inverter",
  "trend_url": "https://listado.mercadolibre.com.mx/magnum-22-inverter",
  "category": "ROOT",
  "rank": 1
}
```

Fields:

- `trend_term` (string): the trending search keyword.
- `trend_url` (string or null): the URL the trend entry points to. Stored as
  a string only; these pages are never fetched by this actor.
- `category` (string or null): the trends category page the term came from
  (e.g. `"Autos, Motos y Otros"`; `"ROOT"` for the homepage).
- `rank` (integer or null): 1-based position of the term within its trend
  module on that page.

### Coverage and limits

Covered surfaces (verified live, no login wall):

- Trends homepage: 2 live modules x ~20 terms (`higherRevenueTrends`,
  `shortTailTrends`).
- Vertical category trend pages, e.g. `/1743-accesorios_para_vehiculos`
  (Autos/Motos) and `/1744-autos_y_camionetas`, each up to ~37 terms.
- Two vertical pages exist but currently return zero trends
  (`/1459-inmuebles`, `/1540-servicios`).

Typical run yields roughly 100-160 rows; `max_items` above that will simply
stop early. A `RUN_SUMMARY` value is also stored with row counts, duration,
and the redirect/block/error log.

Deliberately avoided pages (login / account-verification walls):

- `listado.mercadolibre.com.mx` search-result pages (trend URLs point here,
  but the actor never requests them).
- `articulo.mercadolibre.com.mx` / product detail pages.
- Any URL that redirects to `jms/mlm/lgz/login` or serves a CAPTCHA: the URL,
  status code, and redirect target are recorded in the run log and the crawl
  moves on.

Rate limiting: plain HTTPS with a normal desktop User-Agent, at most 2
concurrent connections and ~1 second between requests. The client honors the
host's standard egress proxy from the `https_proxy` environment variable when
present (and its `SSL_CERT_FILE` CA bundle); with no proxy configured it
connects directly. A 403/429 stops the crawl politely and keeps
already-scraped rows.

### Data rules

- Public pages only. No login flows, no session cookies, no CAPTCHA solving,
  no proxy services.
- No personal data is collected: trend terms and public store/brand keywords
  only. No names, emails, or phone numbers of private individuals.

### Local run

```bash
cd mercadolibre-trends-scraper
mkdir -p storage/key_value_stores/default
cat > storage/key_value_stores/default/INPUT.json <<'EOF'
{"start_urls": ["https://tendencias.mercadolibre.com.mx/"], "max_items": 200, "country": "mx"}
EOF
/home/hatch/workspace/cash-ops/apify-actors/.venv/bin/python main.py
```

Results land in `storage/datasets/default/`; a `RUN_SUMMARY` value with the
run log lands in `storage/key_value_stores/default/`.

# Actor input Schema

## `country` (type: `string`):

MercadoLibre country site to scrape. Determines the tendencias host (for example, 'mx' uses tendencias.mercadolibre.com.mx).

## `max_items` (type: `integer`):

Maximum number of trend records to scrape before stopping. The live surfaces currently hold roughly 100-160 rows, so values above that may not be fully reached.

## `start_urls` (type: `array`):

Public MercadoLibre trends page URLs to begin the crawl from. Category trend pages are discovered automatically from each page's navigation. Defaults to the Mexico trends homepage.

## Actor input object example

```json
{
  "country": "mx",
  "max_items": 200,
  "start_urls": [
    {
      "url": "https://tendencias.mercadolibre.com.mx/"
    }
  ]
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("stilled_stalagmite/mercadolibre-trends-scraper").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("stilled_stalagmite/mercadolibre-trends-scraper").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 '{}' |
apify call stilled_stalagmite/mercadolibre-trends-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,stilled_stalagmite/mercadolibre-trends-scraper"
        }
    }
}
```

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/0I8SPFcHPUYBCXUTo/builds/Ls583enQU1JjGAUtR/openapi.json
