crawlbaseDocs
Log in
The daily challenge is returned as an extra row

LeetCode pins the daily challenge above the paginated table, so a full page returns one entry more than the page size - the pinned problem first, then the table rows. It is the only entry with isDailyQuestion set to true, which makes it straightforward to drop if you only want the table.

API usage

Add &scraper=leetcode-serp 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://leetcode.com/problemset/' \
  --data-urlencode 'scraper=leetcode-serp' -G
from crawlbase import CrawlingAPI

api = CrawlingAPI({'token': 'YOUR_TOKEN'})
res = api.get(
    'https://leetcode.com/problemset/',
    {'scraper': 'leetcode-serp'}
)

import json
data = json.loads(res['body'])
const { CrawlingAPI } = require('crawlbase');
const api = new CrawlingAPI({ token: 'YOUR_TOKEN' });

const res = await api.get(
  'https://leetcode.com/problemset/',
  { scraper: 'leetcode-serp' }
);
const data = JSON.parse(res.body);
require 'crawlbase'
api = Crawlbase::API.new(token: 'YOUR_TOKEN')

res = api.get('https://leetcode.com/problemset/', scraper: 'leetcode-serp')
data = JSON.parse(res.body)

Example input URL

Any LeetCode problem set listing works in the url parameter - the unfiltered set at /problemset/ or a filtered view. For example:

https://leetcode.com/problemset/
https://leetcode.com/problemset/?difficulty=EASY
https://leetcode.com/problemset/?topicSlugs=dynamic-programming

Response shape

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

url
string
URL of the problem set listing that was scraped.
totalProblems
integer | null
Total number of problems LeetCode reports for the current filter, across every page.
problemCount
integer
Number of entries returned in problems for this page.
problems
array
Problem rows found on the page, in the order they are listed.
problems[].id
string | null
Problem number as shown in the listing, returned as a string.
problems[].title
string | null
Problem display title.
problems[].titleSlug
string | null
URL slug of the problem, usable to build any other LeetCode problem URL.
problems[].url
string | null
Absolute URL of the problem page.
problems[].difficulty
string | null
Difficulty label - Easy, Medium, or Hard.
problems[].acceptanceRate
string | null
Acceptance rate as displayed, including the percent sign.
problems[].isPremium
boolean
Whether the problem is locked behind a LeetCode subscription.
problems[].isDailyQuestion
boolean
Whether this row is the pinned daily challenge.

Sample response

{
  "url": "https://leetcode.com/problemset/",
  "totalProblems": 4013,
  "problemCount": 101,
  "problems": [
    {
      "id": "3626",
      "title": "Smallest Divisible Digit Product I",
      "titleSlug": "smallest-divisible-digit-product-i",
      "url": "https://leetcode.com/problems/smallest-divisible-digit-product-i",
      "difficulty": "Easy",
      "acceptanceRate": "71.0%",
      "isPremium": false,
      "isDailyQuestion": true
    },
    {
      "id": "1",
      "title": "Two Sum",
      "titleSlug": "two-sum",
      "url": "https://leetcode.com/problems/two-sum",
      "difficulty": "Easy",
      "acceptanceRate": "57.9%",
      "isPremium": false,
      "isDailyQuestion": false
    },
    {
      "id": "2",
      "title": "Add Two Numbers",
      "titleSlug": "add-two-numbers",
      "url": "https://leetcode.com/problems/add-two-numbers",
      "difficulty": "Medium",
      "acceptanceRate": "49.1%",
      "isPremium": false,
      "isDailyQuestion": false
    }
  ]
}