# LeetCode problem solutions and discussion posts API

Search LeetCode Solution via REST or OpenAny MCP—with pay-per-use pricing and no subscription. Powered by Apish, pass parameters such as limit, output, raw, and retrieve structured data including solution post identifier, post title, post summary, published author metadata, and source official-post flag to compare published approaches, and load selected explanations.

Documentation: https://openany.si/leetcode/leetcode-problem-solutions-and-discussion-posts-api/bb3e1f16-445a-4c34-957f-1060ae964787/
API ID: bb3e1f16-445a-4c34-957f-1060ae964787
Provider: apish
Contract revision: 3
Method: GET
Endpoint: https://api.openany.si/v1/agent-apis/apish/leetcode/v1/discuss
Page update time: 2026-12-03T02:44:09.716Z
Access: OpenAny REST
OpenAny MCP: availability is not supplied by this REST contract. Check get_api on the configured OpenAny MCP server before execution.
Request content type: none
Execution mode: sync
Authentication: Authorization: Bearer $OPENANY_API_KEY

## Billing
Price: $0.002 / billing credit
API-key calls use your shared balance. Review the published billing rules before making a paid request.
Price source: OpenAny public API contract.
Contract update time: 2026-12-03T02:44:06.471Z. This is not a price-change timestamp.
```json
{
  "currency": "USD",
  "mode": "rules",
  "parameters": [],
  "policy_version": 2,
  "sale": {
    "addons": [],
    "base_price_micro_usd": "0",
    "max_cost_micro_usd": "2000",
    "quantities": [
      {
        "id": "upstream_credits",
        "label": "Actual API.SH credits consumed",
        "max_quantity": "1",
        "measure": "value",
        "pointer": "/credits_used",
        "price_micro_usd": "2000",
        "quantity_scale": 0,
        "source": "response",
        "unit": "credit",
        "unit_quantity": "1"
      }
    ],
    "rounding": "ceil",
    "variants": []
  }
}
```

## Usage and limits
## LeetCode Solution Search API

order accepts hot (default), most\_votes or most\_recent. limit is capped at 50; next\_page continues results and topic\_id identifies a detail post.

## What You Can Build

- **Compare published approaches**: Keep tags and authors with summaries.
- **Load selected explanations**: Pass topic\_id to Solution Post.

## Returned Data

| Field | Meaning |
| --- | --- |
| `items[].topic_id` | Solution post identifier |
| `items[].title` | Post title |
| `items[].summary` | Post summary |
| `items[].author` | Published author metadata |
| `items[].official` | Source official-post flag |
| `next_page` | Continuation page |

## Request parameters
```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "LeetCode problem solutions and discussion posts API request inputs",
  "$comment": "Declared input types grouped by HTTP location. Path, query and header values describe decoded inputs and are serialized as text on the wire; body is the payload. This is not an exhaustive provider contract or a schema for the raw HTTP request.",
  "type": "object",
  "properties": {
    "path": {
      "type": "object",
      "properties": {}
    },
    "query": {
      "type": "object",
      "properties": {
        "slug": {
          "type": "string",
          "description": "Problem slug, title or leetcode.com/problems/<slug>/ link."
        },
        "order": {
          "type": "string",
          "description": "hot (default), most_votes or most_recent.",
          "enum": [
            "hot",
            "most_votes",
            "most_recent"
          ]
        },
        "tags": {
          "type": "string",
          "description": "Comma-separated language or topic tag slugs (python3, java, cpp, hash-table...)."
        },
        "q": {
          "type": "string",
          "description": "Only posts matching these words."
        },
        "limit": {
          "type": "integer",
          "description": "Posts per page (max 50)."
        },
        "page": {
          "type": "integer",
          "description": "Page number."
        },
        "raw": {
          "type": "string",
          "description": "0 leaves out the bulky `raw` source blocks (often 10-30x smaller).",
          "enum": [
            "0",
            "1"
          ]
        },
        "fields": {
          "type": "string",
          "description": "Comma-separated fields to return, e.g. `posts.id,posts.title`. Call metadata is always included."
        },
        "fresh": {
          "type": "string",
          "description": "1 skips the 24-hour cache and fetches live.",
          "enum": [
            "1"
          ]
        },
        "output": {
          "type": "string",
          "description": "JSON only for this OpenAny product. Omit output or use json; CSV and NDJSON are not supported.",
          "enum": [
            "json"
          ]
        },
        "records": {
          "type": "string",
          "description": "With output=csv|ndjson: the top-level list to turn into rows (e.g. `reviews`), or `.` for the whole object as one row."
        }
      },
      "required": [
        "slug"
      ]
    },
    "headers": {
      "type": "object",
      "properties": {}
    }
  },
  "required": [
    "path",
    "query",
    "headers"
  ]
}
```

## Response fields
Source: Inferred from examples; not an exhaustive provider schema.
```json
{
  "type": "object",
  "properties": {
    "cached": {
      "type": "boolean"
    },
    "count": {
      "type": "integer"
    },
    "credits_used": {
      "type": "integer"
    },
    "fetched_at": {
      "type": "string"
    },
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "author": {
            "type": "object",
            "properties": {
              "avatar": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "username": {
                "type": "string"
              }
            }
          },
          "comments": {
            "type": "integer"
          },
          "created_at": {
            "type": "string"
          },
          "downvotes": {
            "type": "integer"
          },
          "has_video": {
            "type": "boolean"
          },
          "official": {
            "type": "boolean"
          },
          "reactions": {
            "type": "object",
            "properties": {
              "thumbs_down": {
                "type": "integer"
              },
              "upvote": {
                "type": "integer"
              }
            }
          },
          "slug": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {}
          },
          "title": {
            "type": "string"
          },
          "top_level_comments": {
            "type": "integer"
          },
          "topic_id": {
            "type": "integer"
          },
          "updated_at": {
            "type": "string"
          },
          "upvotes": {
            "type": "integer"
          },
          "url": {
            "type": "string"
          },
          "views": {
            "type": "integer"
          }
        }
      }
    },
    "next_page": {
      "type": "integer"
    },
    "order": {
      "type": "string"
    },
    "page": {
      "type": "integer"
    },
    "q": {
      "type": "null"
    },
    "slug": {
      "type": "string"
    },
    "tags": {
      "type": "array",
      "items": {}
    },
    "total": {
      "type": "integer"
    }
  }
}
```

## Request example
Scenario: Official example · Live API.SH response · Minimal request
```bash
curl \
  'https://api.openany.si/v1/agent-apis/apish/leetcode/v1/discuss?limit=1&output=json&raw=0&slug=two-sum' \
  -X GET \
  -H "Authorization: Bearer $OPENANY_API_KEY" \
  -H 'Content-Type: application/json'
```

## Response example
Example from the provider's documentation. Field values in your results will differ.
Sample response · Documented HTTP 200
```json
{
  "cached": false,
  "count": 1,
  "credits_used": 1,
  "fetched_at": "2026-11-19T12:29:39.594Z",
  "items": [
    {
      "author": {
        "avatar": "https://assets.leetcode.com/users/leetcode/avatar_1568224780.png",
        "name": "LeetCode",
        "username": "leetcode"
      },
      "comments": 3973,
      "created_at": "2021-06-25T02:47:00+00:00",
      "downvotes": 361,
      "has_video": true,
      "official": true,
      "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
    }
  ],
  "next_page": 2,
  "order": "hot",
  "page": 1,
  "q": null,
  "slug": "two-sum",
  "tags": [],
  "total": 3000
}
```

## Error handling
400: Check the request fields.
401 / 403: Verify credentials and access permissions.
402: Inspect payment requirements and balance.
429: Respect returned retry guidance.
5xx: Inspect the error and usage record before retrying a paid operation.

## Common questions
### What sorting is supported?
hot, most_votes and most_recent.

### What does tags accept?
Comma-separated language or topic slugs such as python3 or hash-table.

### What is the maximum limit?
50 posts per page.

### How do I continue?
Pass next_page as page with the same filters.

### Does an official flag mean every returned post is official?
No. Read official on each returned item.

### Can I request CSV or NDJSON?
This OpenAny implementation serves JSON only. Omit output or use output=json.

## Available implementations
- apish: https://openany.si/leetcode/leetcode-problem-solutions-and-discussion-posts-api/bb3e1f16-445a-4c34-957f-1060ae964787/

Integration guide: https://openany.si/docs/
Agent setup: https://openany.si/SKILL.md
