# Jsonplaceholder Api (`aluminum_jam/jsonplaceholder-api`) Actor

The JSONPlaceholder API data extraction actor automates the retrieval and structuring of sample data from the popular JSONPlaceholder REST API service, widely used for testing and development purposes.

- **URL**: https://apify.com/aluminum_jam/jsonplaceholder-api.md
- **Developed by:** [anuj upadhyay](https://apify.com/aluminum_jam) (community)
- **Categories:** Developer tools, Automation, Integrations
- **Features:** Limited permissions
- **Stats:** 7 total users, 0 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.01 / 1,000 results

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

## JSONPlaceholder API Data Extractor

Extract structured sample data from JSONPlaceholder REST API automatically. Perfect for developers, testers, and educators.

### What it does

Retrieves and structures sample data from all [JSONPlaceholder](https://jsonplaceholder.typicode.com/) endpoints:

- **Automated data extraction** from 6 endpoints (posts, comments, albums, photos, todos, users)
- **Data validation and cleaning** for consistent output
- **Flexible filtering** by user ID or endpoint
- **Multiple export formats** (JSON, CSV, Excel)

### How to use

1. **Input**: Select which endpoints to extract and configure options
2. **Run**: Execute the Actor
3. **Output**: Download data from Dataset in your preferred format

### Quick example

Input configuration:

```json
{
  "endpoints": ["posts", "users"],
  "maxItemsPerEndpoint": 10,
  "includeDataValidation": true
}
```

**Output**: 20 structured records (10 posts + 10 users) in the Dataset, ready to download as JSON, CSV, or Excel.

**Output**: 20 structured records (10 posts + 10 users) in the Dataset, ready to download as JSON, CSV, or Excel.

### Available endpoints

| Endpoint | Items | Description |
|----------|-------|-------------|
| `posts` | 100 | Blog posts with titles and body content |
| `comments` | 500 | User comments on posts |
| `albums` | 100 | Photo albums |
| `photos` | 5,000 | Individual photos with URLs and thumbnails |
| `todos` | 200 | Task items with completion status |
| `users` | 10 | Complete user profiles with contact information |

### Required fields

- `endpoints` - Array of endpoints to extract (e.g., `["posts", "users"]`)

### Optional fields

- `filterByUserId` - Filter data for specific user (1-10)
- `maxItemsPerEndpoint` - Limit items per endpoint (0 = unlimited, default)
- `includeDataValidation` - Clean and validate data (default: `true`)
- `includeMetadata` - Add extraction timestamps (default: `false`)
- `combineResults` - Merge all data with type field (default: `false`)

### Use cases

#### Frontend testing

```json
{
  "endpoints": ["users", "posts"],
  "maxItemsPerEndpoint": 5
}
```

#### Single user data

```json
{
  "endpoints": ["posts", "comments", "todos"],
  "filterByUserId": 1,
  "combineResults": true
}
```

#### Educational datasets

```json
{
  "endpoints": ["posts", "comments"],
  "maxItemsPerEndpoint": 10,
  "includeMetadata": true
}
```

### Output format

**Posts example**:

```json
{
  "userId": 1,
  "id": 1,
  "title": "sunt aut facere repellat provident",
  "body": "quia et suscipit..."
}
```

**Users example**:

```json
{
  "id": 1,
  "name": "Leanne Graham",
  "username": "Bret",
  "email": "Sincere@april.biz",
  "phone": "1-770-736-8031 x56442",
  "website": "hildegard.org"
}
```

**With metadata** (when enabled):

```json
{
  "id": 1,
  "title": "Sample Post",
  "body": "Post content...",
  "_metadata": {
    "extractedAt": "2025-12-28T10:30:00.000Z",
    "dataType": "posts",
    "source": "jsonplaceholder.typicode.com"
  }
}
```

### Features

- ✅ **Fast execution** - Completes in seconds
- ✅ **Data validation** - Automatic cleaning and normalization
- ✅ **Retry logic** - Handles temporary API failures
- ✅ **Multiple formats** - Export as JSON, CSV, or Excel
- ✅ **No authentication** - No API keys required
- ✅ **Educational** - Perfect for learning API integration

### Local development

```bash
## Install dependencies
npm install

## Run the Actor
apify run
```

Edit `storage/key_value_stores/default/INPUT.json` to test different configurations.

### Resources

- [JSONPlaceholder API](https://jsonplaceholder.typicode.com/)
- [Apify Documentation](https://docs.apify.com/)
- [Actor SDK Reference](https://docs.apify.com/sdk/js)

***

Built for the **Apify 1 Million Challenge** | Made with ❤️ for developers

# Actor input Schema

## `endpoints` (type: `array`):

Select which JSONPlaceholder endpoints to extract data from. Each endpoint provides different types of sample data:

- **Posts** - Blog posts with titles and body content (100 items)
- **Comments** - User comments on posts (500 items)
- **Albums** - Photo albums (100 items)
- **Photos** - Individual photos with URLs (5000 items)
- **Todos** - Task items with completion status (200 items)
- **Users** - Complete user profiles (10 items)

## `filterByUserId` (type: `integer`):

Filter data for a specific user ID (1-10). When set, only data belonging to this user will be extracted. Leave empty to get all users' data.

**Example**: Set to `1` to get all posts, comments, and todos created by user 1.

## `maxItemsPerEndpoint` (type: `integer`):

Maximum number of items to retrieve per endpoint. Set to `0` for unlimited items.

**Recommended values**:

- **Testing**: 5-10 items
- **Development**: 20-50 items
- **Full dataset**: 0 (unlimited)

## `includeDataValidation` (type: `boolean`):

Validate and clean extracted data for consistency. This includes:

- Trimming whitespace from strings
- Validating email formats in comments
- Normalizing data types (numbers, booleans)
- Ensuring required fields exist

**Recommended**: Keep enabled for production use.

## `includeMetadata` (type: `boolean`):

Add metadata to each extracted item including:

- `extractedAt` - ISO timestamp of extraction
- `dataType` - Type of endpoint (posts, comments, etc.)
- `source` - Source API domain

**Use case**: Useful for tracking when data was extracted and from which endpoint.

## `combineResults` (type: `boolean`):

Combine all endpoint results into a single dataset with a `type` field indicating the data source.

- **Enabled**: All data in one dataset with `type` field (posts, comments, etc.)
- **Disabled**: Separate datasets/records per endpoint

**Use case**: Enable for unified data analysis, disable for organized separate files.

## Actor input object example

```json
{
  "endpoints": [
    "posts",
    "users"
  ],
  "filterByUserId": 1,
  "maxItemsPerEndpoint": 10,
  "includeDataValidation": true,
  "includeMetadata": false,
  "combineResults": false
}
```

# Actor output Schema

## `extractedData` (type: `string`):

Complete dataset of extracted items from selected endpoints

## `csvExport` (type: `string`):

Export extracted data in CSV format for use in spreadsheets

## `excelExport` (type: `string`):

Export extracted data in Excel format (.xlsx)

## `stats` (type: `string`):

View detailed statistics about the extraction run

# 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 = {
    "endpoints": [
        "posts",
        "users"
    ],
    "maxItemsPerEndpoint": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("aluminum_jam/jsonplaceholder-api").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 = {
    "endpoints": [
        "posts",
        "users",
    ],
    "maxItemsPerEndpoint": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("aluminum_jam/jsonplaceholder-api").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 '{
  "endpoints": [
    "posts",
    "users"
  ],
  "maxItemsPerEndpoint": 10
}' |
apify call aluminum_jam/jsonplaceholder-api --silent --output-dataset

```

## MCP server setup

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

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/ZJUkUlKEhJ16QfB36/builds/nLVIgx8JTcgWmcFag/openapi.json
