top of page

How to scrape alternative data from Trading Economics using the Minexa API

Trading Economics publishes a live stream of commodity prices, currency rates, and market indicators across hundreds of instruments. The data is public, structured, and updates continuously. Getting it into a pipeline programmatically is a different story.

This guide walks through how to extract structured alternative data from tradingeconomics.com/stream using the Minexa API. The workflow has two phases: train a scraper once using the Minexa Chrome extension, then call the API to pull data at whatever frequency your pipeline requires.

Watch the full walkthrough first

The video below covers the complete extraction workflow from opening the Trading Economics stream page to exporting structured JSON. Watch it before going through the screenshots.

Step-by-step: training the scraper

Open the Minexa Chrome extension and navigate to the Trading Economics stream page. The extension loads and presents the starting confirmation screen.

After confirming the page, the extension scans for pagination signals. For the Trading Economics stream, this step identifies whether the table loads additional rows dynamically or uses a standard next-page control.

Next, choose whether to extract the list only or follow each commodity link to its detail page. For most alternative data pipelines, the list-only option captures everything needed: price, change, symbol, and classification fields all appear at the stream level.

Select the simple scraping scenario and the extension highlights the full data container automatically. Click to confirm the selection.

All extracted columns appear in the preview panel. Use the navigation arrows to scroll through every field the scraper identified from the stream table.

The extension then generates a ready-to-run JSON config and Python snippet. Copy the scraper ID from this screen. That ID is the only value you need to call the API repeatedly going forward.

Calling the Minexa API

Once the scraper is trained, all future extractions go through a single POST request to the Minexa API endpoint. Pass your scraper ID, the target URL, and the columns you want returned. A basic Python call looks like this:

import requests

response = requests.post(
  'https://api.minexa.ai/data',
  headers={'Content-Type': 'application/json', 'x-api-key': 'YOUR_API_KEY'},
  json={
    'scraper_id': 6271,
    'urls': ['https://tradingeconomics.com/stream'],
    'columns': 'top_40'
  }
)
print(response.json())

Set up a cron job on your own infrastructure to call this endpoint at whatever interval your pipeline needs. The API returns the same structured JSON every time.

What the extracted data looks like

Each row in the response corresponds to one instrument on the stream. Here is a sample of three records with the key fields labelled:

[
  {
    "commodity_type": "Crude Oil",
    "commodity_symbol": "CL1:COM",
    "commodity_link": "/commodity/crude-oil",
    "actual": "72.226",
    "chg": "5.36%",
    "decimal_points": "3",
    "market_image_class": "market-positive-image",
    "market_widget_class": "market-widget-pct calendar-item calendar-item-positive",
    "row_class": "datatable-row"
  },
  {
    "commodity_type": "Gold",
    "commodity_symbol": "XAUUSD:CUR",
    "commodity_link": "/commodity/gold",
    "actual": "4105.22",
    "chg": "-1.43%",
    "decimal_points": "2",
    "market_image_class": "market-negative-image",
    "market_widget_class": "market-widget-pct calendar-item calendar-item-negative",
    "row_class": "datatable-row-alternating"
  },
  {
    "commodity_type": "EU Gas",
    "commodity_symbol": "NGEU:COM",
    "commodity_link": "/commodity/eu-natural-gas",
    "actual": "48.30",
    "chg": "8.92%",
    "decimal_points": "2",
    "market_image_class": "market-positive-image",
    "market_widget_class": "market-widget-pct calendar-item calendar-item-positive",
    "row_class": "datatable-row"
  }
]

Field spotlight: what each column actually gives you

market_image_class encodes the directional price signal as a CSS class string per row. Values are either market-positive-image or market-negative-image. This lets you filter instruments by direction in a single string comparison without parsing the numeric change value or running any conditional logic on the chg field.

market_widget_class goes further. It returns a compound class string that embeds both the display format and the directional state together. For example, market-widget-pct calendar-item calendar-item-positive tells you the widget renders as a percentage, belongs to the calendar item group, and is currently positive. A downstream rendering layer can consume this string directly without computing any of those states independently.

commodity_link returns a relative path per instrument, such as /commodity/crude-oil. Prepend the Trading Economics base domain and you have a direct URL to the full detail page for that instrument. This makes it straightforward to build a second scraper that follows each link and pulls historical data or additional metadata without any manual URL construction.

decimal_points surfaces the precision level per instrument as a string integer. Crude Oil returns 3, Gold returns 2, Natural Gas returns 4. If you are storing these values in a database or displaying them in a UI, this field tells you exactly how many decimal places to preserve or render per row without hardcoding precision rules per instrument type.

row_class alternates between datatable-row and datatable-row-alternating across consecutive records. This reflects the original table striping in the DOM and can serve as a lightweight sequence integrity check across paginated API runs. If two consecutive rows share the same class, it may indicate a duplicate or a missed row in the response.

Viewing the job and exporting results

Once the job completes, the full result set is available in a structured table. Export to Excel or JSON directly from this screen for offline analysis or to feed into a downstream system.

The scraper ID stays stable across runs. Every future API call using that ID targets the same field mapping, so the output schema remains consistent without any additional configuration.

For a related walkthrough covering another financial data source, see: Scraping tax and accounting data from IDX using the Minexa API.

Recent Posts

See All

Comments


Heading 2

bottom of page