crawlbaseDocs
Log in
Premium problems return metadata only

A problem with isPremium set to true keeps its identity fields - id, title, difficulty, topic tags - but the statement and the engagement counters are not part of the page, so description, descriptionHtml, and the counts come back empty.

API usage

Add &scraper=leetcode-problem 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/problems/two-sum/' \
  --data-urlencode 'scraper=leetcode-problem' -G
from crawlbase import CrawlingAPI

api = CrawlingAPI({'token': 'YOUR_TOKEN'})
res = api.get(
    'https://leetcode.com/problems/two-sum/',
    {'scraper': 'leetcode-problem'}
)

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/problems/two-sum/',
  { scraper: 'leetcode-problem' }
);
const data = JSON.parse(res.body);
require 'crawlbase'
api = Crawlbase::API.new(token: 'YOUR_TOKEN')

res = api.get('https://leetcode.com/problems/two-sum/', scraper: 'leetcode-problem')
data = JSON.parse(res.body)

Example input URL

Any LeetCode problem page works in the url parameter - the page at /problems/<slug>. For example:

https://leetcode.com/problems/two-sum/
https://leetcode.com/problems/add-two-numbers/
https://leetcode.com/problems/longest-substring-without-repeating-characters/

Response shape

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

url
string
URL of the problem page that was scraped.
id
string | null
Problem number as shown on the page, returned as a string.
internalId
string | null
LeetCode's internal question identifier. Usually equal to id, but the two diverge on older problems.
title
string | null
Problem display title.
titleSlug
string | null
URL slug of the problem.
difficulty
string | null
Difficulty label - Easy, Medium, or Hard.
category
string | null
Problem category, for example Algorithms or Database.
isPremium
boolean
Whether the problem is locked behind a LeetCode subscription.
descriptionHtml
string | null
Problem statement as HTML, with the original markup preserved so examples, constraints, and inline code survive intact.
description
string | null
Problem statement flattened to plain text.
likes
integer | null
Upvote count on the problem.
dislikes
integer | null
Downvote count on the problem.
acceptedCount
integer | null
Number of accepted submissions.
submissionCount
integer | null
Total number of submissions.
acceptanceRate
string | null
Acceptance rate as displayed, including the percent sign.
commentCount
integer | null
Number of comments in the problem discussion.
topicTags
array
Algorithm and data structure tags applied to the problem.
topicTags[].name
string | null
Tag display name.
topicTags[].slug
string | null
Tag URL slug.
hints
array
Hints published with the problem, as an array of plain-text strings.
exampleTestcases
array
Default test case inputs, as an array of strings. Each string keeps the newlines that separate its arguments.
codeSnippets
array
Starter code stubs LeetCode provides for the problem.
codeSnippets[].language
string | null
Language display name, for example Python3.
codeSnippets[].languageSlug
string | null
Language slug, for example python3.
codeSnippets[].code
string | null
The stub itself, with its original indentation.
similarQuestions
array
Problems LeetCode links as related.
similarQuestions[].title
string | null
Related problem title.
similarQuestions[].titleSlug
string | null
Related problem URL slug.
similarQuestions[].url
string | null
Absolute URL of the related problem.
similarQuestions[].difficulty
string | null
Related problem difficulty label.
similarQuestions[].isPremium
boolean
Whether the related problem is subscription-locked.
officialSolution
object
State of LeetCode's own write-up for the problem.
officialSolution.available
boolean
Whether an official solution exists.
officialSolution.isFree
boolean
Whether the official solution is readable without a subscription.
officialSolution.hasVideo
boolean
Whether the official solution includes a video walkthrough.
solutionsUrl
string | null
Absolute URL of the community solutions tab for this problem.

Sample response

{
  "url": "https://leetcode.com/problems/two-sum/",
  "id": "1",
  "internalId": "1",
  "title": "Two Sum",
  "titleSlug": "two-sum",
  "difficulty": "Easy",
  "category": "Algorithms",
  "isPremium": false,
  "descriptionHtml": "

You are given an array of integers nums and an integer target, return indices of t...", "description": "You are given an array of integers nums and an integer target, return indices of the two numbers such that they add up t...", "likes": 69478, "dislikes": 2592, "acceptedCount": 22929319, "submissionCount": 39569455, "acceptanceRate": "57.9%", "commentCount": 3490, "topicTags": [ { "name": "Array", "slug": "array" }, { "name": "Hash Table", "slug": "hash-table" } ], "hints": [ "A really brute force way would be to search for all possible pairs of numbers but that would be too slow. Again, it's best to try out brute force solutions just for completeness. It is from these brute force solutions that you can come up with optimizations." ], "exampleTestcases": [ "[2,7,11,15]\n9", "[3,2,4]\n6", "[3,3]\n6" ], "codeSnippets": [ { "language": "Python3", "languageSlug": "python3", "code": "class Solution:\n def twoSum(self, nums: List[int], target: int) -> List[int]:\n " }, { "language": "JavaScript", "languageSlug": "javascript", "code": "/**\n * @param {number[]} nums\n * @param {number} target\n * @return {number[]}\n */\nvar twoSum = function(nums, target) {\n \n};" } ], "similarQuestions": [ { "title": "3Sum", "titleSlug": "3sum", "url": "https://leetcode.com/problems/3sum/", "difficulty": "Medium", "isPremium": false }, { "title": "4Sum", "titleSlug": "4sum", "url": "https://leetcode.com/problems/4sum/", "difficulty": "Medium", "isPremium": false } ], "officialSolution": { "available": true, "isFree": true, "hasVideo": true }, "solutionsUrl": "https://leetcode.com/problems/two-sum/solutions/" }