# JSONPath Extractor (`automation-lab/jsonpath-extractor`) Actor

Extract data from JSON using JSONPath expressions. Supports filters, wildcards, recursive descent, multi-expression batches, and flat or grouped output. Pure utility — no proxy, no scraping.

- **URL**: https://apify.com/automation-lab/jsonpath-extractor.md
- **Developed by:** [Stas Persiianenko](https://apify.com/automation-lab) (community)
- **Categories:** Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## JSONPath Extractor

Run **JSONPath expressions** against any JSON document and extract matching values with their full paths. Supports complex queries, filter expressions, recursive descent (`..`), wildcards, multi-expression batches, and both flat and grouped output. Built on the battle-tested [`jsonpath-plus`](https://github.com/JSONPath-Plus/JSONPath) library.

🔗 [Try it on Apify Store](https://apify.com/automation-lab/jsonpath-extractor) | 📖 [JSONPath specification](https://goessner.net/articles/JsonPath/)

---

### What does JSONPath Extractor do?

JSONPath Extractor evaluates one or more JSONPath expressions against a JSON string and returns every matched value with its path and type. Feed it any valid JSON — objects, arrays, nested structures — and it produces a clean, structured dataset you can download as JSON, CSV, or Excel.

**No browser, no proxy, no scraping.** This is a pure utility — you provide the JSON, you provide the expressions, you get back the matched data. Runs in milliseconds, costs fractions of a cent.

Key capabilities:
- 🔍 **Wildcard selectors** — `$.store.book[*].author` matches all authors
- 🔽 **Recursive descent** — `$..price` finds all `price` fields at any depth
- 🧮 **Filter expressions** — `$.book[?(@.price < 10)]` selects books under $10
- 📋 **Array slicing** — `$.items[0:3]` extracts the first three items
- 🔢 **Multi-expression batches** — evaluate dozens of expressions in one run
- 📍 **Path tracking** — every result includes its full JSONPath location

### Who is JSONPath Extractor for?

**Backend developers and API integrators** working with REST API responses, GraphQL payloads, or database exports. Use JSONPath to quickly extract the exact fields you need without writing a custom parser. Replace manual `response.data.items[0].id` chains with a declarative expression.

**Data engineers and ETL pipeline builders** transforming large JSON datasets. Run multiple expressions in a single pass — extract IDs, timestamps, nested arrays, and flags all at once. The flat output mode writes one dataset row per matched value, ready for downstream joins.

**QA engineers and test automation specialists** validating API contracts. JSONPath Extractor lets you describe what you expect from an API response in a human-readable expression and extract values to assert against — no extra parsing code needed.

**Analytics teams and data analysts** receiving JSON exports from SaaS tools (Stripe, Salesforce, HubSpot, etc.). Instead of writing Python or JavaScript to navigate the structure, paste the export and describe what you want.

**No-code automation builders** using Zapier, Make, or n8n who need to pull a specific nested field out of a JSON payload for use in downstream steps. Run this actor via the API or as a webhook handler.

### Why use JSONPath Extractor?

- ✅ **Zero setup** — no credentials, no login, no proxy needed
- ✅ **Handles any JSON shape** — arrays as root, deeply nested objects, mixed types
- ✅ **Full JSONPath-Plus feature set** — filters, scripts, recursive descent, custom functions
- ✅ **Path tracking** — see exactly where in the document each result came from
- ✅ **Batch queries** — run 20 expressions against the same JSON in a single actor run
- ✅ **Export-ready** — download results as JSON, CSV, or Excel from the Apify dataset
- ✅ **API-accessible** — integrate into pipelines via the Apify API, webhooks, or MCP
- ✅ **Deterministic** — pure computation, no network requests, always reproducible results
- ✅ **Fast** — typical run completes in under 2 seconds

### What data can you extract?

JSONPath Extractor returns structured rows for every match:

| Field | Type | Description |
|-------|------|-------------|
| `expression` | string | The JSONPath expression that produced this match |
| `resultPath` | string | Full JSONPath location of the matched value (e.g. `$['store']['book'][0]['price']`) |
| `matchIndex` | number | Zero-based index of this match within the expression's result set |
| `matchCount` | number | Total number of matches for this expression |
| `value` | any | The matched value — string, number, boolean, null, or JSON string for objects/arrays |
| `valueType` | string | JavaScript typeof: `string`, `number`, `boolean`, `object`, `null` |

When a matched value is an object, its top-level fields are also spread into the row for easier table viewing.

### How much does it cost to run JSONPath queries?

This actor uses **pay-per-event pricing** — you pay only per JSONPath expression evaluated.
No monthly subscription. All platform costs are included.

| | Free | Starter ($29/mo) | Scale ($199/mo) | Business ($999/mo) |
|---|---|---|---|---|
| **Per query** | $0.00115 | $0.001 | $0.00078 | $0.0006 |
| **Start event** | $0.005 | $0.005 | $0.005 | $0.005 |
| **10 expressions** | ~$0.017 | ~$0.015 | ~$0.013 | ~$0.011 |

Higher-tier plans (PLATINUM, DIAMOND) get deeper volume discounts.

**Real-world cost examples:**

| Use case | Expressions | Duration | Cost (Free tier) |
|---|---|---|---|
| Extract 3 fields from API response | 3 | ~1s | ~$0.008 |
| Batch transform (20 expressions) | 20 | ~2s | ~$0.028 |
| Daily ETL pipeline (100 expressions/day) | 100 | ~5s | ~$0.12/day |

With $5 of free Apify credits, you can run roughly **300 expressions** on the free tier.

### How to run JSONPath expressions against your JSON

1. Go to [JSONPath Extractor on Apify Store](https://apify.com/automation-lab/jsonpath-extractor)
2. Click **Try for free**
3. In the **JSON input** field, paste your JSON string
4. In the **JSONPath expressions** field, add your expressions (one per line)
5. Configure options: path tracking, flatten vs grouped output
6. Click **Start** and wait (typically under 5 seconds)
7. View results in the **Dataset** tab, or download as JSON/CSV/Excel

**Input examples:**

Query all authors from a bookstore API response:
```json
{
    "jsonInput": "{\"store\":{\"book\":[{\"author\":\"Nigel Rees\",\"price\":8.95},{\"author\":\"Herman Melville\",\"price\":8.99}]}}",
    "expressions": ["$.store.book[*].author"],
    "includeResultPath": true,
    "flattenResults": true
}
````

Filter objects matching a condition:

```json
{
    "jsonInput": "[{\"name\":\"Alice\",\"score\":95},{\"name\":\"Bob\",\"score\":72},{\"name\":\"Carol\",\"score\":88}]",
    "expressions": ["$[?(@.score >= 85)].name"],
    "includeResultPath": true,
    "flattenResults": true
}
```

Batch extraction (multiple fields in one run):

```json
{
    "jsonInput": "{\"order\":{\"id\":\"ORD-123\",\"customer\":{\"email\":\"user@example.com\"},\"items\":[{\"sku\":\"A1\",\"qty\":2}]}}",
    "expressions": ["$.order.id", "$.order.customer.email", "$.order.items[*].sku"],
    "includeResultPath": true,
    "flattenResults": true
}
```

### Input parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `jsonInput` | string | required | The JSON string to query. Must be valid JSON. |
| `expressions` | string\[] | required | One or more JSONPath expressions to evaluate. Each is run independently. |
| `includeResultPath` | boolean | `true` | Include the full JSONPath location of each matched value in the output. |
| `flattenResults` | boolean | `true` | When `true`, each matched value is a separate dataset row. When `false`, all matches per expression are grouped into one row. |
| `wrapSingleValue` | boolean | `true` | Kept for schema compatibility. Primitive values are output directly in the `value` field. |

### Output examples

**Flat mode (`flattenResults: true`)** — each match is its own row:

```json
[
    {
        "expression": "$.store.book[*].author",
        "matchIndex": 0,
        "matchCount": 3,
        "valueType": "string",
        "resultPath": "$['store']['book'][0]['author']",
        "value": "Nigel Rees"
    },
    {
        "expression": "$.store.book[*].author",
        "matchIndex": 1,
        "matchCount": 3,
        "valueType": "string",
        "resultPath": "$['store']['book'][1]['author']",
        "value": "Evelyn Waugh"
    }
]
```

**Grouped mode (`flattenResults: false`)** — all matches per expression in one row:

```json
[
    {
        "expression": "$.store.book[*].author",
        "matchCount": 3,
        "values": ["Nigel Rees", "Evelyn Waugh", "Herman Melville"],
        "valueTypes": ["string", "string", "string"],
        "paths": ["$['store']['book'][0]['author']", "$['store']['book'][1]['author']", "$['store']['book'][2]['author']"]
    }
]
```

**Object match (flattened into row columns):**

```json
{
    "expression": "$.store.book[?(@.price < 10)]",
    "matchIndex": 0,
    "matchCount": 2,
    "valueType": "object",
    "resultPath": "$['store']['book'][0]",
    "category": "reference",
    "author": "Nigel Rees",
    "title": "Sayings of the Century",
    "price": 8.95,
    "value": "{\"category\":\"reference\",\"author\":\"Nigel Rees\",...}"
}
```

### JSONPath syntax reference

| Expression | Description | Example |
|-----------|-------------|---------|
| `$` | Root element | `$` returns the entire document |
| `.key` | Child accessor | `$.store.name` |
| `['key']` | Bracket notation | `$['store']['name']` |
| `[*]` | Wildcard — all elements | `$.items[*]` |
| `..key` | Recursive descent | `$..price` finds all `price` fields |
| `[n]` | Array index | `$.items[0]` |
| `[start:end]` | Array slice | `$.items[0:3]` |
| `[?(expr)]` | Filter expression | `$.items[?(@.active==true)]` |
| `@` | Current node in filter | `$[?(@.price < 10)]` |
| `,` | Union | `$['price','author']` |
| `length` | Array length | `$.items.length` |

**Comparison operators in filters:** `==`, `!=`, `<`, `<=`, `>`, `>=`

**Logical operators:** `&&` (AND), `||` (OR)

### Tips for best results

- 🧪 **Test expressions incrementally** — start with `$..key` to find all matching keys, then narrow to `$.path.to.key`
- 📦 **Group related queries** — run all the expressions you need in one actor call instead of separate runs
- 🔧 **Use `flattenResults: false`** when you want to process all matches as an array in a single downstream step
- 📍 **Enable `includeResultPath`** when debugging — the path column tells you exactly where each value lives in the document
- 🔁 **Combine with webhooks** — trigger this actor automatically when your API returns a payload and you need a specific field
- ⚡ **For API integrations**, use the Apify API with `waitForFinish=60` to get results synchronously in one request
- 🧮 **Non-matching expressions produce a row with `matchCount: 0`** — useful for asserting that a field does NOT exist

### Integrations

**JSONPath Extractor → Google Sheets** — extract fields from daily API exports and append them to a tracking spreadsheet. Use Apify's Google Sheets integration or pipe the JSON dataset output via Make.

**JSONPath Extractor → Slack** — validate an API contract after deployment. Trigger via webhook, extract the expected field, and post a Slack alert if `matchCount` is 0 (missing field).

**JSONPath Extractor → Make / Zapier** — after receiving a JSON webhook payload, run JSONPath Extractor to pull nested fields before passing them to downstream actions. Eliminates the need for JavaScript modules in your automation.

**JSONPath Extractor → n8n** — use as an HTTP node to evaluate JSONPath in your n8n workflow. Connect to any dataset output for structured table results.

**Scheduled extraction pipeline** — combine with a scraper that produces JSON datasets, then run JSONPath Extractor on a schedule to extract specific fields from daily dumps.

**CI/CD API contract testing** — call JSONPath Extractor from your CI pipeline via cURL to assert that your API response contains the expected fields and values before merging.

### Using the Apify API

Run JSONPath Extractor programmatically from any language.

#### Node.js

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

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });

const run = await client.actor('automation-lab/jsonpath-extractor').call({
    jsonInput: '{"users":[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]}',
    expressions: ['$[*].id', '$[*].name'],
    includeResultPath: true,
    flattenResults: true,
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

#### Python

```python
from apify_client import ApifyClient

client = ApifyClient('YOUR_APIFY_TOKEN')

run = client.actor('automation-lab/jsonpath-extractor').call(run_input={
    'jsonInput': '{"users":[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]}',
    'expressions': ['$[*].id', '$[*].name'],
    'includeResultPath': True,
    'flattenResults': True,
})

items = client.dataset(run['defaultDatasetId']).list_items().items
print(items)
```

#### cURL

```bash
curl -X POST "https://api.apify.com/v2/acts/automation-lab~jsonpath-extractor/runs?token=YOUR_APIFY_TOKEN&waitForFinish=60" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonInput": "{\"users\":[{\"id\":1,\"name\":\"Alice\"},{\"id\":2,\"name\":\"Bob\"}]}",
    "expressions": ["$[*].id", "$[*].name"],
    "includeResultPath": true,
    "flattenResults": true
  }'
```

Response includes `defaultDatasetId` — fetch results at:

```
GET https://api.apify.com/v2/datasets/{defaultDatasetId}/items?token=YOUR_APIFY_TOKEN
```

### Use with AI agents via MCP

JSONPath Extractor is available as a tool for AI assistants that support the [Model Context Protocol (MCP)](https://docs.apify.com/platform/integrations/mcp).

Add the Apify MCP server to your AI client — this gives you access to all Apify actors, including this one:

#### Setup for Claude Code

```bash
claude mcp add --transport http apify "https://mcp.apify.com?tools=automation-lab/jsonpath-extractor"
```

#### Setup for Claude Desktop, Cursor, or VS Code

Add this to your MCP config file:

```json
{
    "mcpServers": {
        "apify": {
            "url": "https://mcp.apify.com?tools=automation-lab/jsonpath-extractor"
        }
    }
}
```

Your AI assistant will use OAuth to authenticate with your Apify account on first use.

#### Example prompts

Once connected, try asking your AI assistant:

- "Use automation-lab/jsonpath-extractor to extract all email addresses from this JSON: \[paste JSON]"
- "Run the expression `$..price` against my product catalog JSON and show me a table of all prices with their paths"
- "Filter this API response with JSONPath to find all active users where status equals 'active'"

Learn more in the [Apify MCP documentation](https://docs.apify.com/platform/integrations/mcp).

### Is it legal to use JSONPath Extractor?

Yes. JSONPath Extractor processes **data you provide** — it does not scrape any website, make any outbound HTTP requests, or access any third-party service. You supply the JSON, the actor runs JSONPath computations locally, and returns the results.

This tool is a pure computational utility. It is equivalent to running `jsonpath-plus` in your own Node.js environment. No terms of service, robots.txt, or rate limits apply.

As with all data processing, ensure you have the right to process any personally identifiable information (PII) included in your JSON input in accordance with GDPR, CCPA, or applicable privacy regulations.

### FAQ

**Can JSONPath Extractor handle large JSON documents?**
Yes. The actor runs in a 128–256 MB container and can process multi-megabyte JSON documents without issue. For very large documents (10+ MB), consider splitting them into chunks or increasing the memory setting.

**How much does it cost to run 1,000 queries per day?**
At the BRONZE ($29/mo Starter plan) rate of $0.001 per query plus $0.005 per run start, 1,000 queries across 10 runs costs approximately $1.05/day. At the free tier rate it's approximately $1.20/day against your $5 monthly credit.

**What is the difference between JSONPath and JMESPath or XPath?**
JSONPath (`$..book[*]`) is the de facto standard for querying JSON, modeled after XPath for XML. JMESPath is an alternative standard used in AWS CLI. XPath is for XML only. JSONPath-Plus (used here) extends the original Goessner spec with additional functions like `length`, `keys`, and extended filter support.

**Why do some expressions return 0 matches?**
The most common causes: (1) the path uses dot notation for a key that contains special characters — use bracket notation instead (`$['my-key']`); (2) array indexing is off by one — JSONPath arrays are 0-indexed; (3) filter comparison uses `=` instead of `==` — use `==` for equality. Check the `resultPath` column on a successful match to understand the actual path structure.

**Can I use recursive descent to search all levels?**
Yes. `$..key` finds all occurrences of `key` at any depth. For example, `$..price` returns every `price` field in the entire document regardless of nesting level.

**Why is my filter expression not working?**
Ensure you're using `@` to reference the current node: `$[?(@.age > 18)]`. String comparisons require quotes: `$[?(@.status == "active")]`. The `==` operator is required (not `=`).

**Can I extract nested objects, not just primitives?**
Yes. If a JSONPath expression matches an object or array, the entire object is returned. In flat mode, top-level fields of the matched object are spread into the row columns for easy table display.

### Other JSON and data tools

Looking for related JSON utilities or data extraction tools? Check out these other actors from the same publisher:

- 🔧 [JSON Schema Generator](https://apify.com/automation-lab/json-schema-generator) — Auto-generate JSON Schema (draft-07) from sample JSON objects
- ✅ [JSON Validator](https://apify.com/automation-lab/json-validator) — Validate JSON strings and files against schemas
- 🔀 [JSON CSV Converter](https://apify.com/automation-lab/json-csv-converter) — Convert between JSON and CSV formats
- 📋 [JSONld Validator](https://apify.com/automation-lab/jsonld-validator) — Validate JSON-LD structured data markup
- 🌐 [Base64 Converter](https://apify.com/automation-lab/base64-converter) — Encode and decode Base64 strings
- 🔗 [Canonical URL Checker](https://apify.com/automation-lab/canonical-url-checker) — Bulk check canonical tags across URLs
- 🔍 [Broken Link Checker](https://apify.com/automation-lab/broken-link-checker) — Find broken links and 404 errors on any site

# Actor input Schema

## `jsonInput` (type: `string`):

Paste the JSON string to query. Must be valid JSON — objects, arrays, or primitives are all supported.

## `expressions` (type: `array`):

One or more JSONPath expressions to evaluate. Each produces a separate result set. Examples: $.store.book\[\*].author, $..price, $.store.book\[?(@.price < 10)]

## `includeResultPath` (type: `boolean`):

Return the JSONPath location of each matched value in addition to the value itself. Useful for understanding where in the document each result came from.

## `flattenResults` (type: `boolean`):

When enabled, each matched value is a separate dataset row. When disabled, all matches for each expression are grouped into a single row.

## `wrapSingleValue` (type: `boolean`):

When a matched value is a primitive (string, number, boolean), wrap it in a {value: ...} object for consistent dataset output.

## Actor input object example

```json
{
  "jsonInput": "{\"store\":{\"book\":[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99},{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99}],\"bicycle\":{\"color\":\"red\",\"price\":19.95}}}",
  "expressions": [
    "$.store.book[*].author",
    "$..price",
    "$.store.book[?(@.price < 10)].title"
  ],
  "includeResultPath": true,
  "flattenResults": true,
  "wrapSingleValue": true
}
```

# 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 = {
    "jsonInput": "{\"store\":{\"book\":[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99},{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99}],\"bicycle\":{\"color\":\"red\",\"price\":19.95}}}",
    "expressions": [
        "$.store.book[*].author",
        "$..price",
        "$.store.book[?(@.price < 10)].title"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("automation-lab/jsonpath-extractor").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 = {
    "jsonInput": "{\"store\":{\"book\":[{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"price\":8.95},{\"category\":\"fiction\",\"author\":\"Evelyn Waugh\",\"title\":\"Sword of Honour\",\"price\":12.99},{\"category\":\"fiction\",\"author\":\"Herman Melville\",\"title\":\"Moby Dick\",\"isbn\":\"0-553-21311-3\",\"price\":8.99}],\"bicycle\":{\"color\":\"red\",\"price\":19.95}}}",
    "expressions": [
        "$.store.book[*].author",
        "$..price",
        "$.store.book[?(@.price < 10)].title",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("automation-lab/jsonpath-extractor").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "jsonInput": "{\\"store\\":{\\"book\\":[{\\"category\\":\\"reference\\",\\"author\\":\\"Nigel Rees\\",\\"title\\":\\"Sayings of the Century\\",\\"price\\":8.95},{\\"category\\":\\"fiction\\",\\"author\\":\\"Evelyn Waugh\\",\\"title\\":\\"Sword of Honour\\",\\"price\\":12.99},{\\"category\\":\\"fiction\\",\\"author\\":\\"Herman Melville\\",\\"title\\":\\"Moby Dick\\",\\"isbn\\":\\"0-553-21311-3\\",\\"price\\":8.99}],\\"bicycle\\":{\\"color\\":\\"red\\",\\"price\\":19.95}}}",
  "expressions": [
    "$.store.book[*].author",
    "$..price",
    "$.store.book[?(@.price < 10)].title"
  ]
}' |
apify call automation-lab/jsonpath-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=automation-lab/jsonpath-extractor",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "JSONPath Extractor",
        "description": "Extract data from JSON using JSONPath expressions. Supports filters, wildcards, recursive descent, multi-expression batches, and flat or grouped output. Pure utility — no proxy, no scraping.",
        "version": "0.1",
        "x-build-id": "GYNVUajJfyKb2mhlW"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/automation-lab~jsonpath-extractor/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-automation-lab-jsonpath-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/automation-lab~jsonpath-extractor/runs": {
            "post": {
                "operationId": "runs-sync-automation-lab-jsonpath-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/automation-lab~jsonpath-extractor/run-sync": {
            "post": {
                "operationId": "run-sync-automation-lab-jsonpath-extractor",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "jsonInput",
                    "expressions"
                ],
                "properties": {
                    "jsonInput": {
                        "title": "JSON input",
                        "type": "string",
                        "description": "Paste the JSON string to query. Must be valid JSON — objects, arrays, or primitives are all supported."
                    },
                    "expressions": {
                        "title": "JSONPath expressions",
                        "type": "array",
                        "description": "One or more JSONPath expressions to evaluate. Each produces a separate result set. Examples: $.store.book[*].author, $..price, $.store.book[?(@.price < 10)]",
                        "items": {
                            "type": "string"
                        }
                    },
                    "includeResultPath": {
                        "title": "Include result paths",
                        "type": "boolean",
                        "description": "Return the JSONPath location of each matched value in addition to the value itself. Useful for understanding where in the document each result came from.",
                        "default": true
                    },
                    "flattenResults": {
                        "title": "Flatten results",
                        "type": "boolean",
                        "description": "When enabled, each matched value is a separate dataset row. When disabled, all matches for each expression are grouped into a single row.",
                        "default": true
                    },
                    "wrapSingleValue": {
                        "title": "Wrap primitive values as objects",
                        "type": "boolean",
                        "description": "When a matched value is a primitive (string, number, boolean), wrap it in a {value: ...} object for consistent dataset output.",
                        "default": true
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
