# Public JSON to CSV Feed (`convenient_yarn/public-json-to-csv-feed`) Actor

Flatten inline JSON or public HTTPS JSON into Excel-safe CSV with stable export URLs for automation workflows.

- **URL**: https://apify.com/convenient\_yarn/public-json-to-csv-feed.md
- **Developed by:** [Travis Berman](https://apify.com/convenient_yarn) (community)
- **Categories:** Business, Developer tools, Lead generation
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## 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/docs.md):

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

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.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/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

## Public JSON to CSV Feed

Turn inline JSON rows or a public HTTPS JSON endpoint into a deterministic CSV file that opens cleanly in Excel, Google Sheets, Airtable, Make, Zapier, and n8n workflows.

### Why this Actor

Automation users repeatedly ask how to flatten nested API data, choose stable columns, avoid manual CSV exports, and expose workflow output at a reusable URL. This Actor provides that narrow conversion layer without requiring Airtable credentials, browser automation, or private-system access.

### What it does

- accepts inline object rows or a permission-respecting public HTTPS JSON endpoint;
- selects a nested row array with `rowsPath`;
- flattens nested objects to dotted columns such as `customer.name`;
- serializes arrays as JSON strings instead of inventing columns;
- optionally projects and orders explicit columns;
- emits UTF-8 CSV with a BOM, CRLF rows, correct quote/newline escaping, and spreadsheet-formula neutralization;
- writes `OUTPUT.csv`, a summary dataset row, and a named-store CSV record whose URL stays stable when `exportKey` is reused;
- caps source data at 5 MB while streaming (the body is cancelled as soon as the limit is crossed), CSV output at 10 MB, and rows at 10,000.

### Inline example

```json
{
  "rows": [
    {"id": 1, "customer": {"name": "Ada", "region": "EU"}, "tags": ["priority"], "amount": 1250.5},
    {"id": 2, "customer": {"name": "Lin", "region": "US"}, "tags": [], "amount": 800}
  ],
  "columns": ["id", "customer.name", "customer.region", "tags", "amount"],
  "maxRows": 1000,
  "exportKey": "weekly-sales"
}
````

### Public endpoint example

```json
{
  "sourceUrl": "https://api.github.com/repos/apify/apify-sdk-js/commits?per_page=5",
  "rowsPath": "",
  "columns": ["sha", "commit.author.name", "commit.author.date", "html_url"],
  "maxRows": 100,
  "exportKey": "apify-sdk-commits"
}
```

Provide exactly one of `rows` or `sourceUrl`. Reusing an `exportKey` updates the same named storage record, which is useful for scheduled feeds.

### Output

The default dataset and `OUTPUT` record contain:

```json
{
  "source": "inline",
  "rowCount": 2,
  "sourceRowCount": 2,
  "columns": ["id", "customer.name", "customer.region", "tags", "amount"],
  "columnCount": 5,
  "truncated": false,
  "csvBytes": 115,
  "exportKey": "weekly-sales.csv",
  "exportUrl": null,
  "generatedAt": "ISO timestamp"
}
```

`exportUrl` is intentionally `null` in local runs because local file URLs are not portable. In Apify cloud it is populated from the named key-value store. A capped cloud probe verified that two runs using the same `exportKey` returned the same anonymously readable CSV URL.

### Safety

The Actor rejects non-HTTPS URLs, credentials in URLs, custom ports, localhost/private/link-local IP literals, and hostnames resolving to private addresses. Redirects are disabled. It does not log in, use proxies, bypass access controls, or accept arbitrary request headers. Only use endpoints and data you are allowed to access.

### Local development

```bash
npm ci
npm test
CRAWLEE_STORAGE_DIR="$PWD/storage" CRAWLEE_PURGE_ON_START=0 npm start
```

Pre-seed `storage/key_value_stores/default/INPUT.json` with an example before running. Keep `APIFY_TOKEN` and `APIFY_IS_AT_HOME` unset for deterministic local storage.

### Status and pricing

The Actor is published and anonymously visible in the Apify Store. Capped cloud probes verified deterministic CSV output and a stable named-store export URL across repeated runs. The current listing is free apart from normal Apify platform usage. A future paid `file-generated` event remains a hypothesis until payout/KYC is complete; invalid input and source failures must never be charged.

# Actor input Schema

## `sourceUrl` (type: `string`):

Public HTTPS endpoint returning JSON. Redirects, credentials, custom ports, and private/local hosts are rejected.

## `rows` (type: `array`):

Array of objects to export instead of sourceUrl.

## `rowsPath` (type: `string`):

Optional dot path to an array inside the JSON response, for example data.items.

## `columns` (type: `array`):

Optional ordered list of flattened columns. Nested keys use dots, for example customer.name.

## `maxRows` (type: `integer`):

Hard cap on exported rows.

## `exportKey` (type: `string`):

Stable name for the CSV record. Reusing it updates the same URL on later runs.

## Actor input object example

```json
{
  "maxRows": 1000,
  "exportKey": "latest"
}
```

# Actor output Schema

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

No description

## `keyValueStore` (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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("convenient_yarn/public-json-to-csv-feed").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("convenient_yarn/public-json-to-csv-feed").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 '{}' |
apify call convenient_yarn/public-json-to-csv-feed --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=convenient_yarn/public-json-to-csv-feed",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Public JSON to CSV Feed",
        "description": "Flatten inline JSON or public HTTPS JSON into Excel-safe CSV with stable export URLs for automation workflows.",
        "version": "0.1",
        "x-build-id": "Bqjl0OWy8Tk2OOV8w"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/convenient_yarn~public-json-to-csv-feed/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-convenient_yarn-public-json-to-csv-feed",
                "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/convenient_yarn~public-json-to-csv-feed/runs": {
            "post": {
                "operationId": "runs-sync-convenient_yarn-public-json-to-csv-feed",
                "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/convenient_yarn~public-json-to-csv-feed/run-sync": {
            "post": {
                "operationId": "run-sync-convenient_yarn-public-json-to-csv-feed",
                "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": [
                    "maxRows"
                ],
                "properties": {
                    "sourceUrl": {
                        "title": "Public JSON URL",
                        "type": "string",
                        "description": "Public HTTPS endpoint returning JSON. Redirects, credentials, custom ports, and private/local hosts are rejected."
                    },
                    "rows": {
                        "title": "Inline JSON rows",
                        "maxItems": 10000,
                        "type": "array",
                        "description": "Array of objects to export instead of sourceUrl."
                    },
                    "rowsPath": {
                        "title": "Rows path",
                        "type": "string",
                        "description": "Optional dot path to an array inside the JSON response, for example data.items."
                    },
                    "columns": {
                        "title": "Columns",
                        "maxItems": 200,
                        "type": "array",
                        "description": "Optional ordered list of flattened columns. Nested keys use dots, for example customer.name.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxRows": {
                        "title": "Maximum rows",
                        "minimum": 1,
                        "maximum": 10000,
                        "type": "integer",
                        "description": "Hard cap on exported rows.",
                        "default": 1000
                    },
                    "exportKey": {
                        "title": "Stable export name",
                        "maxLength": 120,
                        "type": "string",
                        "description": "Stable name for the CSV record. Reusing it updates the same URL on later runs.",
                        "default": "latest"
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
