# NYT Cooking Scraper (`harvest/nyt-cooking-scraper`) Actor

Scrapes recipe data from a New York Times Cooking recipe page. It extracts key details such as the recipe name, ingredients, instructions, cooking time, servings, and nutrition facts.

- **URL**: https://apify.com/harvest/nyt-cooking-scraper.md
- **Developed by:** [Harvest Data](https://apify.com/harvest) (community)
- **Categories:** Social media, Automation
- **Stats:** 51 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

## NYT Cooking Recipe Scraper

### Overview

Scrapes recipe data from a New York Times Cooking recipe page. It extracts key details such as the recipe name, ingredients, instructions, cooking time, servings, and nutrition facts.

### Features

- Extracts recipe title, author, and description
- Scrapes ingredient list and preparation steps
- Captures cooking time, servings, and difficulty level
- Retrieves nutrition facts if available
- Outputs structured JSON data

### Usage

#### Input

The Actor accepts a JSON input with the following structure:

```json
{
  "url": "https://cooking.nytimes.com/recipes/1025701-crispy-gnocchi-with-spinach-and-feta"
}
```

#### Output

The output is structured JSON data containing the scraped recipe details:

```json
	"contentAttribution": {
		"cardByline": "Hetty Lui McKinnon",
		"topnoteSigner": "",
		"primaryByline": {
			"prefix": "By",
			"authors": [
				{
					"name": "Hetty Lui McKinnon",
					"link": "/search?q=Hetty+Lui+McKinnon"
				}
			]
		},
		"secondaryByline": {
			"prefix": "",
			"authors": []
		}
	},
	"id": 1025701,
	"image": {
		"caption": "",
		"credit": "Julia Gartland for The New York Times. Food Stylist: Samantha Seneviratne.",
		"src": {
			"card": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-mediumThreeByTwo440.jpg",
			"article": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-jumbo.jpg",
			"seoImage": ""
		},
		"crops": {
			"collection": {},
			"recipe": {
				"XS": {
					"height": 241,
					"name": "tmagSF",
					"url": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-tmagSF.jpg",
					"width": 362
				},
				"S": {
					"height": 320,
					"name": "blog480",
					"url": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-blog480.jpg",
					"width": 480
				},
				"M": {
					"height": 512,
					"name": "master768",
					"url": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-master768.jpg",
					"width": 768
				},
				"L": {
					"height": 683,
					"name": "jumbo",
					"url": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-jumbo.jpg",
					"width": 1024
				},
				"XL": {
					"height": 1000,
					"name": "threeByTwoMediumAt2X",
					"url": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-threeByTwoMediumAt2X.jpg",
					"width": 1500
				}
			},
			"card": {
				"XS": {
					"height": 293,
					"name": "mediumThreeByTwo440",
					"url": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-mediumThreeByTwo440.jpg",
					"width": 440
				}
			},
			"rotd": {
				"XS": {
					"height": 293,
					"name": "mediumThreeByTwo440",
					"url": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-mediumThreeByTwo440.jpg",
					"width": 440
				},
				"S": {
					"height": 293,
					"name": "mediumThreeByTwo440",
					"url": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-mediumThreeByTwo440.jpg",
					"width": 440
				},
				"M": {
					"height": 293,
					"name": "mediumThreeByTwo440",
					"url": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-mediumThreeByTwo440.jpg",
					"width": 440
				},
				"L": {
					"height": 293,
					"name": "mediumThreeByTwo440",
					"url": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-mediumThreeByTwo440.jpg",
					"width": 440
				},
				"XL": {
					"height": 1000,
					"name": "threeByTwoMediumAt2X",
					"url": "https://static01.nyt.com/images/2024/08/20/multimedia/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp/hm-crispy-gnocchi-with-spinach-and-fetarex-wjzp-threeByTwoMediumAt2X.jpg",
					"width": 1500
				}
			}
		}
	},
	"ingredients": [
		{
			"name": "",
			"ingredients": [
				{
					"text": "ounces baby spinach",
					"quantity": "5"
				},
				{
					"text": "ounces Greek feta, crumbled (about 1 cup)",
					"quantity": "6"
				},
				{
					"text": "lemon, halved",
					"quantity": "1"
				},
				{
					"text": "tablespoons extra-virgin olive oil",
					"quantity": "5"
				},
				{
					"text": "Salt and pepper",
					"quantity": ""
				},
				{
					"text": "(16- to 17-ounce) package potato gnocchi (shelf-stable, fresh or frozen)",
					"quantity": "1"
				},
				{
					"text": "teaspoon crushed red pepper",
					"quantity": "1/4 to 1/2"
				},
				{
					"text": "scallions, thinly sliced",
					"quantity": "2"
				},
				{
					"text": "Big handful of chopped dill",
					"quantity": ""
				},
				{
					"text": "Big handful of chopped mint",
					"quantity": ""
				}
			]
		}
	],
	"nutritionalInformation": [
		{
			"header": "Nutritional analysis per serving (4 servings)",
			"description": "442 calories; 26 grams fat; 8 grams saturated fat; 0 grams trans fat; 14 grams monounsaturated fat; 2 grams polyunsaturated fat; 42 grams carbohydrates; 5 grams dietary fiber; 2 grams sugars; 12 grams protein; 684 milligrams sodium",
			"source": "edamam"
		}
	],
	"publishedAt": 1724112000,
	"modifiedAt": 1724112000,
	"ratings": {
		"avgRating": 5,
		"numRatings": 3130
	},
	"recipeYield": "4 servings",
	"steps": [
		{
			"name": "",
			"steps": [
				{
					"number": 1,
					"description": "Place the spinach into a large bowl. Add half of the feta, juice of 1/2 lemon, 1 tablespoon of olive oil and a big pinch of salt; rub the ingredients vigorously into the spinach to tenderize it. Leave to sit and soften further while you cook the gnocchi.",
					"media": null
				},
				{
					"number": 2,
					"description": "Heat a large (about 12-inch) cast-iron or nonstick skillet over medium-high; add 2 tablespoons of olive oil. Add the gnocchi to the pan, breaking up any that are stuck together. Cook for 8 to 10 minutes, tossing every 2 minutes, until golden and crispy all over. Allow to cool in the pan for 5 minutes; they will further crisp as they cool.",
					"media": null
				},
				{
					"number": 3,
					"description": "Add the gnocchi to the spinach, along with the red pepper, scallions, dill and mint. Drizzle with about 2 tablespoons of olive oil, add the remaining crumbled feta and toss to combine. Squeeze the remaining lemon juice over top and serve.",
					"media": null
				}
			]
		}
	],
	"tips": [],
	"title": "Crispy Gnocchi With Spinach and Feta",
	"topnote": "Inspired by the herbaceous and jaunty flavors of <a href=\"https://cooking.nytimes.com/recipes/1020101-spanakopita/">spanakopita</a>, the savory, ever popular Greek pie, spinach and feta headline this textural gnocchi salad. The spinach is not cooked, but is simply massaged, which softens it while ensuring it maintains its leafy structure. Incorporating some feta to the spinach massage is a functional move — the salt in the feta helps to tenderize the leaves — but it also adds a hint of quiet luxury to this dish, as the leaves become coated with the creamy, briny cheese. Be heavy-handed with your herbs and lemon, as these bring boldness and freshness that play off the saltiness of the feta. Everyday shelf-stable gnocchi from your local supermarket is perfect for crisping in the pan; if you choose to use frozen variety, no defrosting is required.",
	"url": "/recipes/1025701-crispy-gnocchi-with-spinach-and-feta",
	"fullUrl": "https://cooking.nytimes.com/recipes/1025701-crispy-gnocchi-with-spinach-and-feta",
	"cookTime": "20 minutes",
	"prepTime": "5 minutes",
	"totalTime": "25 minutes"
```

### How It Works

1. The Actor receives a recipe URL as input.
2. It loads the page and extracts the relevant details using Cheerio or Puppeteer.
3. The extracted data is formatted into a structured JSON output.
4. The JSON output is stored and can be accessed via the Apify dataset.

### Setup

1. Deploy the Actor on [Apify](https://apify.com/)
2. Provide the necessary URL as input
3. Run the Actor and retrieve the structured recipe data

### Limitations

- Requires valid access to NYT Cooking (some recipes may be behind a paywall)
- May require adjustments if the NYT Cooking website structure changes

### License

MIT License

# Actor input Schema

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

The URL of the NYT cooking page you want to get the data from.

## Actor input object example

```json
{
  "url": "https://cooking.nytimes.com/recipes/1025701-crispy-gnocchi-with-spinach-and-feta"
}
```

# 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://cooking.nytimes.com/recipes/1025701-crispy-gnocchi-with-spinach-and-feta"
};

// Run the Actor and wait for it to finish
const run = await client.actor("harvest/nyt-cooking-scraper").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://cooking.nytimes.com/recipes/1025701-crispy-gnocchi-with-spinach-and-feta" }

# Run the Actor and wait for it to finish
run = client.actor("harvest/nyt-cooking-scraper").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://cooking.nytimes.com/recipes/1025701-crispy-gnocchi-with-spinach-and-feta"
}' |
apify call harvest/nyt-cooking-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,harvest/nyt-cooking-scraper"
        }
    }
}

```

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/7P6X2ASqSSDdoBoCi/builds/YWbOZg0Bf3F8mDtFh/openapi.json
