OpenAny
Get API keyAPI Key
APIDataDeveloper

leetcode logo
LeetCode Solution Post API

Get LeetCode Solution Post data via REST or OpenAny MCP—with pay-per-use pricing and no subscription. Powered by Apish, pass parameters such as id, output, raw, and retrieve structured data including post identifier, post title, published post content, author metadata, and associated problem reference to inspect selected explanations, and connect problem context.

Selected price
$0.002 / billing creditPublished pricing
Sellers / APIs
1 / 1
Requests · 30d
0Selected implementation · last 30 days
Success rate · 30d
—No requests in this period
USE THIS API

LeetCode Solution Post API

Prepare your request, then continue with your agent.

Pricing

$0.002 / billing credit

Calculated from input parameters and actual returned quantities. Estimate the maximum cost before calling.

Provider
API
Pricing
Connect your agent
On this page

Overview

Overview
LeetCode Solution Post API

LeetCode Solution Post API

id identifies a solution post, not a problem. problem provides the associated problem context; official is a per-post source flag.

Quick Facts

Fact Value
Access OpenAny REST
Authentication OpenAny API key in the Authorization header
Core inputs Required inputs: id. JSON only; fresh=1 bypasses cache and raw=0 trims raw source blocks.
Selected implementation apish · LeetCode solution post API
Billing See the pricing area for the selected implementation and request options

What You Can Build

  • Inspect selected explanations: Keep author and source URL with content.
  • Connect problem context: Retain problem separately from post identity.

Returned Data

Field Meaning
topic_id Post identifier
title Post title
content Published post content
author Author metadata
problem Associated problem reference
official Source official-post flag
comments Published comment metadata

Quick Start

  1. Set OPENANY_API_KEY to your OpenAny API key.
  2. Review the selected implementation and pricing, then adapt the request below to your target.
  3. Check the HTTP response and business result before reading optional fields.
bash
curl --request GET --get \
  https://api.openany.si/v1/agent-apis/apish/leetcode/v1/discuss/post \
  -H "Authorization: Bearer ${OPENANY_API_KEY}" \
  --data-urlencode id=127810 \
  --data-urlencode output=json \
  --data-urlencode raw=0

Request and Response Examples

The response example is a documentation reference and may be abbreviated. The documented request is a calling template; use the published contract and returned response for the selected implementation.

Published LeetCode Solution Post API implementation contract.

Pricing and Billing

The pricing area reflects the selected API implementation. Review its billing unit and any request-dependent rules before calling; a source service's public availability does not determine OpenAny billing.

Frequently Asked Questions

View FAQ

Related APIs

Playground

Run sends a real API request. Charges follow the published API contract.

Request parameters
Post id, or a leetcode.com/problems/<slug>/solutions/<id>/ link.
Optional parameters (5)
0 leaves out the bulky `raw` source blocks (often 10-30x smaller).
Comma-separated fields to return, e.g. `posts.id,posts.title`. Call metadata is always included.
1 skips the 24-hour cache and fetches live.
JSON only for this OpenAny product. Omit output or use json; CSV and NDJSON are not supported.
With output=csv|ndjson: the top-level list to turn into rows (e.g. `reviews`), or `.` for the whole object as one row.

Sample response

Run a request to see the actual response. Published samples are in Examples.

Response result

Sellers

SellerPricingRequests · 30dPerformanceAccess
apishCurrent
LeetCode solution post API · GET · View API reference
$0.002 / billing credit0
—successP50—
Selected implementation traffic · 11/3/2026 – 12/3/2026 (UTC)
Selected pricing · apishUSD / billing credit
Pricing
$0.002

Calculated from input parameters and actual returned quantities. Estimate the maximum cost before calling.

Statistics use persisted gateway logs from the last 30 days up to now, including today.
Success rate = successful requests / all requests;
P50 = median latency of successful requests.
Prices reflect the published API contract. Contract revision: 3. Price update time: not supplied.

API

Method
GET
Endpoint
https://api.openany.si/v1/agent-apis/apish/leetcode/v1/discuss/post
Content type
application/json
Authentication
Authorization: Bearer $OPENANY_API_KEY
View request and response examples

Input parameters

Fields in this listing; additional options and input encoding can vary by provider.

ParameterLocationTypeRequiredDescription
idURL query parametersquerystringYes

Post id, or a leetcode.com/problems/<slug>/solutions/<id>/ link.

rawURL query parametersquerystringNo

0 leaves out the bulky `raw` source blocks (often 10-30x smaller).

enum: "0", "1"

fieldsURL query parametersquerystringNo

Comma-separated fields to return, e.g. `posts.id,posts.title`. Call metadata is always included.

freshURL query parametersquerystringNo

1 skips the 24-hour cache and fetches live.

enum: "1"

outputURL query parametersquerystringNo

JSON only for this OpenAny product. Omit output or use json; CSV and NDJSON are not supported.

enum: "json"

recordsURL query parametersquerystringNo

With output=csv|ndjson: the top-level list to turn into rows (e.g. `reviews`), or `.` for the whole object as one row.

Required markers inside a nested object or variant apply when that object or variant is used.

Response structure

Inferred from examples
  • authorobject
    • avatarstring
    • namestring
    • usernamestring
  • cachedboolean
  • commentsinteger
  • contentstring
  • created_atstring
  • credits_usedinteger
  • downvotesinteger
  • fetched_atstring
  • has_videoboolean
  • nextobject
    • slugstring
    • titlestring
    • topic_idinteger
  • officialboolean
  • previousnull
  • problemobject
    • slugstring
    • titlestring
    • urlstring
  • reactionsobject
    • thumbs_downinteger
    • upvoteinteger
  • slugstring
  • summarystring
  • tagsunknown[]
  • titlestring
  • top_level_commentsinteger
  • topic_idinteger
  • updated_atstring
  • upvotesinteger
  • urlstring
  • viewsinteger

Composite rule pricing

Calculated from input parameters and actual returned quantities. Estimate the maximum cost before calling.

Base fee: $0.000000. One matching variant replaces the base fee. Matching add-ons and quantity charges are added.

Fee itemPriceMetering sourceWhenQuantity limit
Actual API.SH credits consumed$0.002000 / billing creditResponse · /credits_used · Numeric valueAlways1 billing credit · Decimal places: 0

Each quantity charge is rounded before summing: ceil. Requests exceeding this cost limit are rejected; it is not a price cap: $0.002000.

Response quantities settle after the response. Before execution, the maximum quantity determines the reservation; unused reservation is released. Missing or invalid quantities are not treated as zero.

Pricing parameters and defaults
[]

Agent integration

Copy the resource contract without sharing an API key.

Download MDView API Markdown

Error handling

StatusNext step
400Check the offering and request fields.
401 / 403Verify your credentials and access permissions.
402Inspect the selected access mode and returned payment requirements.
429Respect the returned rate limit and retry guidance.
5xxInspect the error and usage record before retrying a paid operation.

Examples

Official example · Live API.SH response · Minimal request

Example from the provider's documentation. Field values in your results will differ.

  1. Prepare your environment

    Use a terminal with cURL installed.

    Use an OpenAny API key with shared-balance access. Confirm availability and price before running; a call may charge your balance.

    Set the key in your terminal using the hidden prompt below. Keep its value out of source files and logs.

    Terminal · macOS / Linux
    printf 'OpenAny API key: '
    read -r -s OPENANY_API_KEY
    export OPENANY_API_KEY
    printf '\n'
  2. Run the request

    Paste the complete command below into your terminal.

    Values to replace before running 6

    Review these request fields before running. Keep the published provider and request method unchanged.

    id
    Post id, or a leetcode.com/problems/<slug>/solutions/<id>/ link.
    raw
    0 leaves out the bulky `raw` source blocks (often 10-30x smaller).
    fields
    Comma-separated fields to return, e.g. `posts.id,posts.title`. Call metadata is always included.
    fresh
    1 skips the 24-hour cache and fetches live.
    output
    JSON only for this OpenAny product. Omit output or use json; CSV and NDJSON are not supported.
    records
    With output=csv|ndjson: the top-level list to turn into rows (e.g. `reviews`), or `.` for the whole object as one row.
    Terminal · cURL
    curl \
      'https://api.openany.si/v1/agent-apis/apish/leetcode/v1/discuss/post?id=127810&output=json&raw=0' \
      -X GET \
      -H "Authorization: Bearer $OPENANY_API_KEY" \
      -H 'Content-Type: application/json'
  3. Check the response

    Sample response · Documented HTTP 200

    Sample response
    {
      "author": {
        "avatar": "https://assets.leetcode.com/users/leetcode/avatar_1568224780.png",
        "name": "LeetCode",
        "username": "leetcode"
      },
      "cached": false,
      "comments": 3973,
      "content": "[TOC]\n\n## Video Solution\n\n---\n\n<lcvideo>\n    <div class=\"video-container\">\n        <iframe src=\"https://player.vimeo.com/video/567281997\" width=\"640\" height=\"360\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen></iframe>\n    </div>\n</lcvideo>\n\n<div>&nbsp;\n</div>\n\n## Solution Article\n\n---\n\n### Approach 1: Brute Force\n\n**Algorithm**\n\nThe brute force approach is simple. Loop through each element $$x$$ and find if there is another value that equals to $$target - x$$.\n\n**Implementation**\n\n<iframe src=\"https://leetcode.com/playground/WTVGRyeD/shared\" frameBorder=\"0\" width=\"100%\" height=\"327\" name=\"WTVGRyeD\"></iframe>\n\n**Complexity Analysis**\n\n* Time complexity: $$O(n^2)$$.\nFor each element, we try to find its complement by looping through the rest of the array which takes $$O(n)$$ time. Therefore, the time complexity is $$O(n^2)$$.\n\n* Space complexity: $$O(1)$$.\nThe space required does not depend on the size of the input array, so only constant space is used.\n\n---\n### Approach 2: Two-pass Hash Table\n\n**Intuition**\n\nTo improve our runtime complexity, we need a more efficient way to check if the complement exists in the array. If the complement exists, we need to get its index. What is the best way to maintain a mapping of each element in the array to its index? A hash table.\n\nWe can reduce the lookup time from $$O(n)$$ to $$O(1)$$ by trading space for speed. A hash table is well suited for this purpose because it supports fast lookup in *near* constant time. I say \"near\" because if a collision occurred, a lookup could degenerate to $$O(n)$$ time. However, lookup in a hash table should be amortized $$O(1)$$ time as long as the hash function was chosen carefully.\n\n**Algorithm**\n\nA simple implementation uses two iterations. In the first iteration, we add each element's value as a key and its index as a value to the hash table. Then, in the second iteration, we check if each element's complement ($$target - nums[i]$$) exists in the hash table. If it does exist, we return current element's index and its complement's index. Beware that the complement must not be $$nums[i]$$ itself!\n\n**Implementation**\n\n<iframe src=\"https://leetcode.com/playground/bbEpXJcf/shared\" frameBorder=\"0\" width=\"100%\" height=\"500\" name=\"bbEpXJcf\"></iframe>  \n\n**Complexity Analysis**\n\n* Time complexity: $$O(n)$$.\nWe traverse the list containing $$n$$ elements exactly twice. Since the hash table reduces the lookup time to $$O(1)$$, the overall time complexity is $$O(n)$$.\n\n* Space complexity: $$O(n)$$.\nThe extra space required depends on the number of items stored in the hash table, which stores exactly $$n$$ elements.\n\n---\n### Approach 3: One-pass Hash Table\n\n**Algorithm**\n    \nIt turns out we can do it in one-pass. While we are iterating and inserting elements into the hash table, we also look back to check if current element's complement already exists in the hash table. If it exists, we have found a solution and return the indices immediately.\n\n**Implementation**    \n    \n<iframe src=\"https://leetcode.com/playground/4KK3DMtw/shared\" frameBorder=\"0\" width=\"100%\" height=\"500\" name=\"4KK3DMtw\"></iframe>\n\n**Complexity Analysis**\n\n* Time complexity: $$O(n)$$.\nWe traverse the list containing $$n$$ elements only once. Each lookup in the table costs only $$O(1)$$ time.\n\n* Space complexity: $$O(n)$$.\nThe extra space required depends on the number of items stored in the hash table, which stores at most $$n$$ elements.",
      "created_at": "2021-06-25T02:47:00+00:00",
      "credits_used": 1,
      "downvotes": 361,
      "fetched_at": "2026-11-19T12:29:39.866Z",
      "has_video": true,
      "next": {
        "slug": "video-step-by-step-easy-solution-by-niit-ydj9",
        "title": "【Video】Step by Step Easy Solution",
        "topic_id": 8586852
      },
      "official": true,
      "previous": null,
      "problem": {
        "slug": "two-sum",
        "title": "Two Sum",
        "url": "https://leetcode.com/problems/two-sum/"
      },
      "reactions": {
        "thumbs_down": 361,
        "upvote": 5141
      },
      "slug": "two-sum-by-leetcode-kwuq",
      "summary": "Video Solution   Solution Article Approach 1: Brute Force Algorithm The brute force approach is simple. Loop through each element x and find if there is another",
      "tags": [],
      "title": "Two Sum",
      "top_level_comments": 2831,
      "topic_id": 127810,
      "updated_at": "2021-06-25T02:47:00+00:00",
      "upvotes": 5141,
      "url": "https://leetcode.com/problems/two-sum/solutions/127810/two-sum-by-leetcode-kwuq",
      "views": 14531684
    }

Common questions

Do I supply a problem ID?

No. Use a solution post ID or supported solution URL.

Where can I find post IDs?

Use topic_id from Solution Search results.

Does this execute the included code?

No. It reads published content.

Are previous and next pagination tokens?

They are returned post references; this request exposes only id.

Is every post an official solution?

No. Read official for the returned post.

Can I request CSV or NDJSON?

This OpenAny implementation serves JSON only. Omit output or use output=json.

Use LeetCode Solution Post API with your agent

Inspect endpoint contracts and confirm availability and pricing before a paid call.