crawlbaseDocs
Log in
The notebook body is served in an iframe

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' -G
from 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-accuracy

Response shape

JSON response body. Field types may be null when the source page omits the value.

url
string
URL of the notebook page that was scraped.
slug
string | null
Notebook identifier as author/notebook, read from the URL path.
title
string | null
Notebook display title.
author
object
Account that owns the notebook.
author.username
string | null
Owner handle.
author.name
string | null
Owner display name.
author.url
string | null
Absolute URL of the owner profile.
publishedAt
string | null
ISO 8601 timestamp of first publication.
lastUpdated
string | null
ISO 8601 timestamp of the most recent version.
thumbnail
string | null
Notebook card image URL.
language
string | null
Notebook language (for example Python or R).
runtime
string | null
Execution time of the last run as displayed, units included (for example 16s).
version
integer | null
Version number currently on display.
versionCount
integer | null
Total number of published versions.
views
integer | null
Total page view count.
votes
integer | null
Upvote count.
copies
integer | null
Number of times the notebook has been copied or forked.
commentCount
integer | null
Number of comments on the notebook.
medal
string | null
Kaggle medal on the notebook (for example gold), or null when it carries none.
license
object
License the notebook is published under.
license.name
string | null
License display name (for example Apache 2.0).
license.url
string | null
Canonical URL of the license text.
inputs
array
Competitions, datasets, and other notebooks attached as inputs.
inputs[].category
string | null
Input group heading as Kaggle labels it (for example COMPETITIONS).
inputs[].title
string | null
Display name of the attached input.
contentUrl
string | null
Address of the iframe that holds the rendered notebook body. Carries a short-lived signed token.

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"
}