# Twelve Data Market Status Scraper (`acquistion-automation/twelve-data-market-status-scraper`) Actor

Scrapes the Twelve Data market status API and returns each exchange as a flat row with name, code, country, open or closed state, and session timing. Supports demo and paid API keys, optional exchange filtering, and export to CSV, JSON, Excel, or XML.

- **URL**: https://apify.com/acquistion-automation/twelve-data-market-status-scraper.md
- **Developed by:** [Acquisition Automation Co.](https://apify.com/acquistion-automation) (community)
- **Categories:** Jobs
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.62 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

[![Acquisition Automation](https://api.apify.com/v2/key-value-stores/AOdPHdOpeDpzEPS5f/records/banner.jpg)](https://apify.com/acquistion-automation)

### Twelve Data Market Status Scraper

**Scrape live market status from the Twelve Data API for any exchange, with open or closed state, time to open, and time to close.** Every market comes back as a flat row with its country, code, and session timing. Export to CSV, JSON, Excel, or XML.

Twelve Data's market status endpoint tells you which exchanges are open right now, but calling it by hand means writing a script, handling pagination, and shaping the JSON yourself. This Actor reads the Twelve Data market status API directly, filters by exchange code, and returns each market as one clean row. It works with a free demo key for testing or your own Twelve Data API key for production runs.

| Who uses it | What they scrape Twelve Data for |
|---|---|
| Trading desk operators | Which global exchanges are open or closed at this moment |
| Fintech product managers | Feeding market session state into dashboards and alerts |
| Quantitative researchers | Building datasets of trading session timing per exchange |
| Market data engineers | Replacing manual Twelve Data API calls with scheduled runs |

### What it does

This Actor collects market status records from the Twelve Data API and returns each exchange as a flat row with its name, code, country, open or closed state, and session timing fields.

- 🌍 **All exchanges or one:** leave the exchange field empty for every market, or pass a code like NYSE or NASDAQ.
- 🔑 **Demo or paid key:** use 'demo' for a quick preview, or your own Twelve Data API key for full access.
- 📦 **Flat row output:** each market returns as one record with its name, code, country, and open or closed state.
- ⏱️ **Session timing included:** time to open, time to close, and time after open come back with every market.

Results export to CSV, JSON, Excel, or XML, or straight from the API.

### What you can do with Twelve Data data

**🕒 Monitor which markets are open right now.**

A trading desk operator runs the Actor every few minutes with no exchange filter and checks the open or closed state for every global market before routing orders.

**📊 Build a trading session calendar.**

A quant researcher pulls market status for all exchanges once a day and stores the time to open and time to close fields to map session boundaries over a month.

**🔔 Feed market state into alerts.**

A fintech product manager schedules the Actor for NYSE only and uses the isMarketOpen field to trigger in-app notifications when the US market opens or closes.

**🧪 Test Twelve Data integration without writing code.**

A market data engineer runs the Actor with the demo key to inspect the exact JSON fields before committing to a paid Twelve Data plan.

### Why choose this scraper

| | What you get |
|---|---|
| **No code to write** | Call the Twelve Data market status endpoint without building a script |
| **One fixed schema** | Every exchange returns the same flat fields, ready for CSV or a database |
| **Exchange filter built in** | Target NYSE, NASDAQ, or any single exchange instead of pulling all markets |
| **Demo key supported** | Test with the free demo key before you commit your own API key |

### What a Twelve Data record looks like

Every record returns as one flat JSON row. Here is a real one from a run:

```json
{
 "name": "NYSE",
 "code": "XNYS",
 "country": "United States",
 "isMarketOpen": false,
 "timeToOpen": "10:49:12",
 "timeToClose": "00:00:00",
 "timeAfterOpen": "00:00:00",
 "scrapedAt": "2026-09-28T02:40:47.636Z"
}
```

Every value above comes from a real run. A field a record does not have comes back as `null`.

### Configure the run

Drive the Actor with your Twelve Data API key and an optional exchange code, and set a max items limit so only the markets you need reach your dataset. The Input tab lists every parameter.

A first run with the defaults:

```json
{
 "apiKey": "demo",
 "maxItems": 10
}
```

A larger pull:

```json
{
 "apiKey": "demo",
 "maxItems": 10
}
```

### Free users

Free-plan runs return up to 10 results as a preview. [Upgrade your Apify plan](https://console.apify.com/sign-up) to collect more results per run.

### Run it

1. [Create a free Apify account](https://console.apify.com/sign-up).
2. Open the [Twelve Data Market Status Scraper](https://apify.com/acquistion-automation/twelve-data-market-status-scraper).
3. Set your inputs and any filters, then click **Start**.
4. Export the results as CSV, Excel, JSON, or XML from the **Dataset** tab.

Run it programmatically through the [Apify API](https://docs.apify.com/api/v2) (`run-sync-get-dataset-items`) or the [ApifyClient](https://docs.apify.com/api/client/js) for JavaScript and Python.

### Use with AI agents (MCP)

Give an AI agent live access to Twelve Data through the Model Context Protocol. Add the Actor to Claude, Cursor, or any MCP client:

```bash
claude mcp add --transport http apify "https://mcp.apify.com?tools=acquistion-automation/twelve-data-market-status-scraper"
```

Then prompt it in plain language to run the scraper and read back the results.

### Troubleshooting

**Why am I getting no results?**

Check that your API key is valid and that the exchange code, if set, matches a supported Twelve Data exchange. The demo key returns only a small sample, so also confirm maxItems is at least 1.

**Why am I limited to 10 items?**

Free or demo keys are limited to 10 items as a preview. Use a paid Twelve Data API key and raise maxItems to get more records.

**Why does the run fail with an API error?**

Twelve Data may reject invalid keys or rate-limit requests. Verify your key in the Twelve Data dashboard and check your plan's request limits.

**Why is the exchange filter not working?**

Exchange codes are case-sensitive. Use uppercase codes like NYSE or NASDAQ exactly as Twelve Data lists them.

**Why do I see fewer fields than expected?**

The demo key may return a reduced field set. Run with your own API key to get the full market status response.

### FAQ

| Question | Answer |
|---|---|
| Do I need a Twelve Data API key? | You can use the demo key for a quick preview with limited data. For production runs, pass your own Twelve Data API key in the apiKey field. |
| What does the demo key return? | The demo key returns a small sample of market status records so you can verify the output shape before using a paid key. |
| Can I filter by exchange? | Yes. Set the exchange field to a code like NYSE or NASDAQ to get only that market. Leave it empty to get all exchanges. |
| How many items can I get per run? | Free users are limited to 10 items as a preview. Paid users can set maxItems higher. |
| What fields come back for each market? | Each row includes the market name, code, country, whether it is open, time to open, time to close, time after open, scrapedAt, and error. |
| Can I export the results? | Yes. The Actor output can be exported to CSV, JSON, Excel, or XML from the Apify dataset. |
| Does this Actor handle pagination? | Yes. The Actor reads the Twelve Data market status endpoint and collects records up to your maxItems limit without you writing pagination logic. |
| Is this the same as the Twelve Data market status endpoint? | Yes. The Actor calls the official Twelve Data market\_state API endpoint and returns the response as flat rows. |
| Can I schedule this Actor? | Yes. You can schedule it from the Apify platform to run every few minutes or once a day, depending on how fresh you need the market state. |
| What happens if I pass an invalid exchange code? | The Twelve Data API returns an error or an empty result for unknown codes. Check the exchange code against Twelve Data's supported exchange list. |

### Related actors

Browse the full [Acquisition Automation collection](https://apify.com/acquistion-automation) for more scrapers.

🆘 **Need help?** Open an issue in the Issues tab of this Actor with your run ID, your input, and what you expected.

### Pricing

This Actor uses **pay-per-result** pricing: **$0.004 per result** collected. You are billed only for the results you receive, so a run that returns nothing costs nothing.

⚠️ **Disclaimer.** This Actor is unofficial and is not affiliated with, endorsed by, or sponsored by Twelve Data Pte. Ltd. It collects only publicly available data. You are responsible for using the collected data in compliance with the source's terms of service and applicable data-protection laws, including GDPR, CCPA, and PIPL. Do not use it to collect personal data unlawfully.

# Actor input Schema

## `apiKey` (type: `string`):

Your Twelve Data API key. Use 'demo' for testing with limited data.

## `exchange` (type: `string`):

Optional exchange code to filter results, such as NYSE or NASDAQ. Leave empty to get all exchanges.

## `maxItems` (type: `integer`):

Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000

## Actor input object example

```json
{
  "apiKey": "demo",
  "maxItems": 10
}
```

# Actor output Schema

## `results` (type: `string`):

Complete dataset of all scraped records.

# 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 = {
    "apiKey": "demo",
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("acquistion-automation/twelve-data-market-status-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 = {
    "apiKey": "demo",
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("acquistion-automation/twelve-data-market-status-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 '{
  "apiKey": "demo",
  "maxItems": 10
}' |
apify call acquistion-automation/twelve-data-market-status-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,acquistion-automation/twelve-data-market-status-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/XCp1x6QTv9F3ojc9q/builds/WhVXZtY2AznRs501O/openapi.json
