Kaggle Notebook
Parse a single Kaggle notebook page into structured JSON with its author, language, runtime, version history, engagement counts, and attached inputs. Pricing, use cases and the other Kaggle scrapers are on the Kaggle Scraper page.
Kaggle renders the executed notebook - cells, output, and charts - inside an iframe rather than in the page itself, so it is not part of this response. contentUrl returns the address of that frame; fetch it as a second request when you need the rendered notebook. The URL carries a short-lived signed token, so request it soon after scraping rather than storing it.
API usage
Add &scraper=kaggle-notebook to a Crawling API request. URL-encode the target URL in the url parameter.
curl 'https://api.crawlbase.com/?token=YOUR_TOKEN' \
--data-urlencode 'url=https://www.kaggle.com/code/alexisbcook/titanic-tutorial' \
--data-urlencode 'scraper=kaggle-notebook' -Gfrom crawlbase import CrawlingAPI
api = CrawlingAPI({'token': 'YOUR_TOKEN'})
res = api.get(
'https://www.kaggle.com/code/alexisbcook/titanic-tutorial',
{'scraper': 'kaggle-notebook'}
)
import json
data = json.loads(res['body'])const { CrawlingAPI } = require('crawlbase');
const api = new CrawlingAPI({ token: 'YOUR_TOKEN' });
const res = await api.get(
'https://www.kaggle.com/code/alexisbcook/titanic-tutorial',
{ scraper: 'kaggle-notebook' }
);
const data = JSON.parse(res.body);require 'crawlbase'
api = Crawlbase::API.new(token: 'YOUR_TOKEN')
res = api.get('https://www.kaggle.com/code/alexisbcook/titanic-tutorial', scraper: 'kaggle-notebook')
data = JSON.parse(res.body)Example input URL
Any Kaggle notebook page works in the url parameter - the page at /code/<author>/<notebook>. For example:
https://www.kaggle.com/code/alexisbcook/titanic-tutorial
https://www.kaggle.com/code/startupsci/titanic-data-science-solutions
https://www.kaggle.com/code/ldfreeman3/a-data-science-framework-to-achieve-99-accuracyResponse shape
JSON response body. Field types may be null when the source page omits the value.
author/notebook, read from the URL path.Python or R).16s).gold), or null when it carries none.Apache 2.0).COMPETITIONS).Sample response
{
"url": "https://www.kaggle.com/code/alexisbcook/titanic-tutorial",
"slug": "alexisbcook/titanic-tutorial",
"title": "Titanic Tutorial",
"author": {
"username": "alexisbcook",
"name": "Alexis Cook",
"url": "https://www.kaggle.com/alexisbcook"
},
"publishedAt": "2022-06-24T00:25:16.1066667Z",
"lastUpdated": "2022-06-24T00:25:16.1066667Z",
"thumbnail": "https://storage.googleapis.com/kaggle-avatars/thumbnails/2603295-kg.jpg",
"language": "Python",
"runtime": "16s",
"version": 22,
"versionCount": 22,
"views": 3265744,
"votes": 60135,
"copies": 51320,
"commentCount": 30626,
"medal": "gold",
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
},
"inputs": [
{
"category": "COMPETITIONS",
"title": "Titanic - Machine Learning from Disaster"
}
],
"contentUrl": "https://www.kaggleusercontent.com/kf/99170538//__results__.html"
}