# Public Json Normalizer (`eichan/public-json-normalizer`) Actor

- **URL**: https://apify.com/eichan/public-json-normalizer.md
- **Developed by:** [Eichan Jolly](https://apify.com/eichan) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.01 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## Public JSON Endpoint Normalizer

### What it does

Download **one public JSON URL**, turn its top-level JSON object or list of objects into clean Apify Dataset rows, and flatten nested **objects** using dot-separated keys. A small `maxItems` setting prevents accidental huge datasets. No login, API key, or Apify SDK.

### Who it is for

Anyone who needs a repeatable snapshot from a public JSON API for CSV exports, dashboards, automation, or scheduled public-data tracking.

### Input example (real public test API)

```json
{
  "url": "https://jsonplaceholder.typicode.com/users",
  "maxItems": 3
}
```

The prefilled `/users` endpoint is a public JSONPlaceholder sample response containing a top-level list of 10 user objects; the example emits just 3 dataset records. `url` is required; `maxItems` defaults to 3 and accepts 1–100.

### Output example (one sample row; output contains more keys)

```json
{
  "sourceUrl": "https://jsonplaceholder.typicode.com/users",
  "recordIndex": 1,
  "checkedAt": "2026-11-01T05:05:10Z",
  "record.id": 1,
  "record.name": "Leanne Graham",
  "record.username": "Bret",
  "record.address.street": "Kulas Light",
  "record.address.city": "Gwenborough",
  "record.address.geo.lat": "-37.3159",
  "record.company.name": "Romaguera-Crona"
}
```

All leaf keys are placed at the row's top level under `record.*` (e.g. `record.address.city`). `sourceUrl`, `recordIndex` (1-based index within returned rows), and `checkedAt` (ISO 8601 UTC) are stable metadata fields. Lists nested *inside* objects remain JSON arrays; empty objects remain `{}`. When the JSON root is an object, exactly one row is produced. An empty array produces zero rows.

### Use in Apify

1. Create an Actor from this folder; `.actor/actor.json` points to the correct Dockerfile, README, and input schema.
2. Supply the direct URL of an openly accessible JSON endpoint; one working example is prefilled.
3. Choose a row cap (3 initially). Run and export the Dataset as CSV or JSON.
4. Schedule a daily snapshot of a stable public JSON endpoint. Each run produces a new snapshot; no previous-run deduplication or stored history is built in.

### Local run / tests

Requires Python 3.12 or newer. From the Actor folder:

```bash
ACTOR_INPUT_JSON='{"url":"https://jsonplaceholder.typicode.com/users","maxItems":3}' python src/main.py
python -m unittest discover -s tests -p 'test_*.py' -v
python tests/smoke_run.py
```

Local output is in `storage/datasets/default/*.json` (or `APIFY_LOCAL_STORAGE_DIR`). Apify cloud automatically supplies a runtime token and default storage IDs, used directly through Apify's REST API without installing its SDK. No external key is required.

### Limits and error behavior

- Only public HTTP(S) endpoints that respond with JSON. No authentication, HTML scraping, JavaScript rendering, or multi-page API pagination.
- GET request timeout: 15 seconds. Response cap: 1 MB. Up to 100 rows are saved; **the response is still downloaded in full within 1 MB** before applying `maxItems`.
- The top-level value must be an object or an array of objects. A top-level scalar or a list containing scalars within the selected rows fails with a clear error.
- Nesting in objects is limited to 20 levels. Object keys containing a period (`.`) or empty keys are rejected to avoid ambiguous flattened columns; nested arrays remain arrays.
- Unauthenticated endpoints can still rate-limit, change schemas, or block requests. Only use sources that permit automated access.
- URLs with credentials, private/loopback IP destinations, nonstandard ports, or redirects to such destinations are refused (except an explicit **local-only test fixture**; never allowed in cloud). DNS rebinding during a request is not fully preventable by application-level validation alone; deploy only with a restricted egress policy for stronger network isolation.
- Malformed HTTP responses, invalid JSON, and HTML pages returned instead of JSON produce plain-language errors without tracebacks.
- External DNS was blocked in the verification environment, so smoke evidence uses a local fixture, not a live public request. Apify cloud build/run remains unverified.

### Store placement and suggested pricing

**Store categories:** `AUTOMATION`, `DEVELOPER_TOOLS`. **Suggested price:** US $0.005 per run (advisory; no billing configured). See `store_metadata.json`.

# Actor input Schema

## `url` (type: `string`):

One publicly accessible endpoint that returns JSON. The prefilled example is a public sample API.

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

Limit the number of dataset rows produced. One top-level object always produces one row.

## Actor input object example

```json
{
  "url": "https://jsonplaceholder.typicode.com/users",
  "maxItems": 3
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing the Actor's result items

# 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 = {
    "url": "https://jsonplaceholder.typicode.com/users"
};

// Run the Actor and wait for it to finish
const run = await client.actor("eichan/public-json-normalizer").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 = { "url": "https://jsonplaceholder.typicode.com/users" }

# Run the Actor and wait for it to finish
run = client.actor("eichan/public-json-normalizer").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 '{
  "url": "https://jsonplaceholder.typicode.com/users"
}' |
apify call eichan/public-json-normalizer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eichan/public-json-normalizer"
        }
    }
}
```

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/XyvtsDG12gVsBoNt5/builds/IcKEsX2wg6ATgJaC7/openapi.json
