← All guides
JSONPathextraction

How to Use JSONPath Extraction

Query JSON API responses and embedded JSON data using JSONPath expressions - the JSON equivalent of XPath.

Verid Guides·4 min read

What is it?

JSONPath extraction parses the raw page content as JSON and applies JSONPath expressions to pull out specific values. It's the cleanest method when your monitor URL points directly to a JSON API endpoint or when the page embeds a JSON data blob.

If the URL returns Content-Type: application/json, JSONPath is almost always the right choice - it's faster and more precise than CSS or regex on JSON data.

When to use it

  • The URL is a JSON API endpoint (GitHub releases, NPM registry, weather APIs, etc.)
  • The page source contains an embedded <script type="application/json"> block that the page uses to populate content
  • You want to track deeply nested values - JSONPath handles any nesting depth cleanly

How to configure it

Pick JSONPath as your extraction method, then map field names to JSONPath expressions:

{
  "method": "json_path",
  "fields": {
    "version": "$.tag_name",
    "published": "$.published_at"
  }
}
  • $ - root of the JSON document
  • .key - access an object property
  • [0] - access an array index (0-based)
  • [*] - wildcard: match all items in an array
  • Returns null if the path doesn't exist

Example 1 - Track the latest GitHub release

Goal: Get notified whenever a GitHub repo publishes a new release.

URL: https://api.github.com/repos/facebook/react/releases/latest

JSON response (simplified):

{
  "tag_name": "v19.1.0",
  "name": "React 19.1",
  "published_at": "2026-04-10T14:23:00Z",
  "prerelease": false,
  "html_url": "https://github.com/facebook/react/releases/tag/v19.1.0"
}

Configuration:

{
  "method": "json_path",
  "fields": {
    "version": "$.tag_name",
    "name": "$.name",
    "published": "$.published_at",
    "prerelease": "$.prerelease",
    "url": "$.html_url"
  }
}

Output:

{
  "version": "v19.1.0",
  "name": "React 19.1",
  "published": "2026-04-10T14:23:00Z",
  "prerelease": false,
  "url": "https://github.com/facebook/react/releases/tag/v19.1.0"
}

Example 2 - Track an NPM package version

Goal: Know when a package publishes a new version to NPM.

URL: https://registry.npmjs.org/next/latest

JSON response (simplified):

{
  "name": "next",
  "version": "15.3.1",
  "description": "The React Framework",
  "dist": {
    "tarball": "https://registry.npmjs.org/next/-/next-15.3.1.tgz"
  }
}

Configuration:

{
  "method": "json_path",
  "fields": {
    "version": "$.version",
    "tarball": "$.dist.tarball"
  }
}

Output:

{
  "version": "15.3.1",
  "tarball": "https://registry.npmjs.org/next/-/next-15.3.1.tgz"
}

Example 3 - Track crypto or stock prices

Goal: Monitor ETH price from a public price API.

URL: https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd

JSON response:

{
  "ethereum": {
    "usd": 3421.58
  }
}

Configuration:

{
  "method": "json_path",
  "fields": {
    "eth_usd": "$.ethereum.usd"
  }
}

Output:

{
  "eth_usd": 3421.58
}

Example 4 - Extract from a nested array

Goal: Track the first open issue on a project's issue tracker API.

URL: https://api.github.com/repos/vercel/next.js/issues?state=open&per_page=1

JSON response:

[
  {
    "number": 78234,
    "title": "App Router: cache invalidation race condition",
    "state": "open",
    "user": {
      "login": "devuser42"
    },
    "created_at": "2026-05-10T09:11:00Z"
  }
]

Configuration:

{
  "method": "json_path",
  "fields": {
    "issue_number": "$[0].number",
    "issue_title": "$[0].title",
    "author": "$[0].user.login"
  }
}

Output:

{
  "issue_number": 78234,
  "issue_title": "App Router: cache invalidation race condition",
  "author": "devuser42"
}

Example 5 - Count array items

Goal: Track how many items are in a list returned by an API.

JSON response:

{
  "results": [
    { "id": 1, "name": "Item A" },
    { "id": 2, "name": "Item B" },
    { "id": 3, "name": "Item C" }
  ]
}

Configuration:

{
  "method": "json_path",
  "fields": {
    "result_count": "$.results.length"
  }
}

Output:

{
  "result_count": 3
}

JSONPath quick reference

Expression What it selects
$ Root of the document
$.name Property name on the root object
$.user.email Nested property
$[0] First item in a root array
$[0].title Property of the first array item
$.items[2].price Third item's price in the items array
$.items[*].name All name values across every item
$.items.length Count of items in the array

Tips

  • Test the URL in your browser first. If you visit the API URL and see raw JSON, JSONPath will work perfectly.
  • Use [0] for the first item. JSONPath arrays are 0-indexed, unlike XPath which is 1-indexed.
  • The page doesn't have to be pure JSON. If the site embeds JSON in a <script> tag (e.g., Next.js __NEXT_DATA__), the extractor will still find and parse it.
  • Missing paths return null. A path that doesn't exist won't cause an error - it just won't appear in the output. This is useful for optional fields.

Try Verid for free

5 monitors, no credit card required.

Get started free