fetch-json
Extract specific data from JSON APIs using JSONPath patterns to reduce token usage by fetching only required content from URLs with support for HTTP methods and request customization.
Instructions
Extract JSON content from a URL using JSONPath with extended features. Supports extensions like len, keys, filtering, arithmetic operations, and more. If 'pattern' is omitted or empty, the entire JSON document is returned. Supports different HTTP methods (default: GET).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL to get raw JSON from | |
| data | No | Request body data for POST/PUT/PATCH requests. Can be a JSON object or string. | |
| method | No | HTTP method to use (GET, POST, PUT, DELETE, PATCH, etc.). Default is GET. | GET |
| headers | No | Additional HTTP headers to include in the request | |
| pattern | No | Extended JSONPath pattern supporting: Basic: 'foo[*].baz', 'bar.items[*]'; Extensions: '$.data.`len`', '$.users.`keys`', '$.field.`str()`'; Filtering: '$.items[?(@.price > 10)]', '$.users[?name = "John"]'; Arithmetic: '$.a + $.b', '$.items[*].price * 1.2'; Text ops: '$.text.`sub(/old/, new)`', '$.csv.`split(",")' |