# Stack Exchange API
> Search Stack Overflow and the Stack Exchange network — questions by relevance with scores, answer counts and tags, full question details, and user profiles with reputation, badges and location. Ideal for developer tools, tech-trend monitoring, Q&A aggregation and reputation lookups.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/stackexchange-api/..."
```

## Pricing
- **Free** (Free) — 4,000 calls/Mo, 2 req/s
- **Basic** ($8/Mo) — 60,000 calls/Mo, 8 req/s
- **Pro** ($24/Mo) — 300,000 calls/Mo, 20 req/s
- **Mega** ($99/Mo) — 1,500,000 calls/Mo, 50 req/s

## Endpoints

### Stack Exchange

#### `GET /v1/question` — A question by id

**Parameters:**
- `id` (query, required, string) — Numeric question id Example: `11227809`
- `site` (query, optional, string) — Stack Exchange site slug (default stackoverflow; see /v1/sites) Example: `stackoverflow`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/stackexchange-api/v1/question?id=11227809&site=stackoverflow"
```

**Response:**
```json
{
    "data": {
        "id": 11227809,
        "link": "https://stackoverflow.com/questions/11227809/why-is-conditional-processing-of-a-sorted-array-faster-than-of-an-unsorted-array",
        "tags": [
            "java",
            "c++",
            "performance",
            "cpu-architecture",
            "branch-prediction"
        ],
        "owner": "GManNickG",
        "score": 27530,
        "title": "Why is conditional processing of a sorted array faster than of an unsorted array?",
        "created_at": "2012-06-27T13:51:36.000Z",
        "view_count": 1985304,
        "is_answered": true,
        "answer_count": 26,
        "last_activity_at": "2026-04-08T05:35:32.000Z",
        "accepted_answer_id": 11227902
    },
    "meta": {
        "timestamp": "2026-05-30T06:33:29.921Z",
        "request_id": "17f03b07-c69f-4aed-8065-159a7ff98e4d"
    },
    "status": "ok",
    "message": "Question retrieved",
    "success": true
}
```

#### `GET /v1/search` — Search questions by relevance

**Parameters:**
- `q` (query, required, string) — Search text Example: `how to reverse a list`
- `site` (query, optional, string) — Stack Exchange site slug (default stackoverflow; see /v1/sites) Example: `stackoverflow`
- `limit` (query, optional, string) — Max results (1-30) Example: `15`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/stackexchange-api/v1/search?q=how+to+reverse+a+list&site=stackoverflow&limit=15"
```

**Response:**
```json
{
    "data": {
        "site": "stackoverflow",
        "count": 15,
        "query": "async await",
        "results": [
            {
                "id": 37576685,
                "link": "https://stackoverflow.com/questions/37576685/using-async-await-with-a-foreach-loop",
                "tags": [
                    "javascript",
                    "node.js",
                    "promise",
                    "async-await",
                    "ecmascript-2017"
                ],
                "owner": "Saad",
                "score": 3351,
                "title": "Using async/await with a forEach loop",
                "created_at": "2016-06-01T18:55:58.000Z",
                "view_count": 2476066,
                "is_answered": true,
                "answer_count": 35,
                "last_activity_at": "2025-01-28T01:27:13.000Z",
                "accepted_answer_id": 37576787
            },
            {
                "id": 14455293,
                "link": "https://stackoverflow.com/questions/14455293/how-and-when-to-use-async-and-await",
                "tags": [
                    "c#",
                    ".net",
                    "asynchronous",
                    "async-await"
                ],
                "owner": "Dan Dinu",
                "score": 1429,
                "title": "How and when to use ‘async’ and ‘await’",
                "created_at": "2013-01-22T09:29:58.000Z",
                "view_count": 1314415,
                "
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/user` — A user profile by id

**Parameters:**
- `id` (query, required, string) — Numeric user id Example: `22656`
- `site` (query, optional, string) — Stack Exchange site slug (default stackoverflow; see /v1/sites) Example: `stackoverflow`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/stackexchange-api/v1/user?id=22656&site=stackoverflow"
```

**Response:**
```json
{
    "data": {
        "id": 22656,
        "link": "https://stackoverflow.com/users/22656/jon-skeet",
        "name": "Jon Skeet",
        "badges": {
            "gold": 895,
            "bronze": 9357,
            "silver": 9318
        },
        "location": "Reading, United Kingdom",
        "user_type": "registered",
        "created_at": "2008-09-26T12:05:05.000Z",
        "reputation": 1527510,
        "profile_image": "https://www.gravatar.com/avatar/6d8ebb117e8d83d74ea95fbdd0f87e13?s=256&d=identicon&r=PG",
        "last_access_at": "2026-05-29T19:26:28.000Z"
    },
    "meta": {
        "timestamp": "2026-05-30T06:33:31.171Z",
        "request_id": "71c132cc-8cd1-4db2-b206-cf8d80cff462"
    },
    "status": "ok",
    "message": "User retrieved",
    "success": true
}
```

### Questions

#### `GET /v1/answers` — Answers to a question, highest-voted first

**Parameters:**
- `id` (query, required, string) — Numeric question id Example: `11227809`
- `site` (query, optional, string) — Stack Exchange site slug (default stackoverflow; see /v1/sites) Example: `stackoverflow`
- `sort` (query, optional, string) — votes (default), activity or creation Example: `votes`
- `limit` (query, optional, string) — Max results (1-30) Example: `10`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/stackexchange-api/v1/answers?id=11227809&site=stackoverflow&sort=votes&limit=10"
```

**Response:**
```json
{
    "data": {
        "site": "stackoverflow",
        "sort": "votes",
        "count": 10,
        "results": [
            {
                "id": 11227902,
                "body": "<p><strong>You are a victim of <a href=\"https://en.wikipedia.org/wiki/Branch_predictor\" rel=\"noreferrer\">branch prediction</a> fail.</strong></p>\n<hr />\n<h2>What is Branch Prediction?</h2>\n<p>Consider a railroad junction:</p>\n<p><a href=\"https://commons.wikimedia.org/wiki/File:Entroncamento_do_Transpraia.JPG\" rel=\"noreferrer\"><img src=\"https://i.sstatic.net/muxnt.jpg\" alt=\"Image showing a railroad junction\" /></a>\n<sub><a href=\"https://commons.wikimedia.org/wiki/File:Entroncamento_do_Transpraia.JPG\" rel=\"noreferrer\">Image</a> by Mecanismo, via Wikimedia Commons. Used under the <a href=\"https://creativecommons.org/licenses/by-sa/3.0/deed.en\" rel=\"noreferrer\">CC-By-SA 3.0</a> license.</sub></p>\n<p>Now for the sake of argument, suppose this is back in the 1800s - before long-distance or radio communication.</p>\n<p>You are a blind operator of a junction and you hear a train coming. You have no idea which way it is supposed to go. You stop the train to ask the driver which direction they want. And then you set the switch appropriately.</p>\n<p><em>Trains are heavy and have a lot of inertia, so they take forever to start up and slow down.</em></p>\n<p>Is there a better way? You guess which direction the train will go!</p>\n<ul>\n<li>If you guessed right, it continues on.<
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/questions` — Typed question lists without a search term

**Parameters:**
- `site` (query, optional, string) — Stack Exchange site slug (default stackoverflow; see /v1/sites) Example: `stackoverflow`
- `sort` (query, optional, string) — hot (default), votes, activity, week, month or creation Example: `hot`
- `tag` (query, optional, string) — Filter by a single tag Example: `python`
- `limit` (query, optional, string) — Max results (1-30) Example: `20`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/stackexchange-api/v1/questions?site=stackoverflow&sort=hot&tag=python&limit=20"
```

**Response:**
```json
{
    "data": {
        "tag": "python",
        "site": "stackoverflow",
        "sort": "hot",
        "count": 20,
        "results": [
            {
                "id": 79958531,
                "link": "https://stackoverflow.com/questions/79958531/how-to-read-headers-set-by-wsgi-start-response",
                "tags": [
                    "python",
                    "wsgi",
                    "wsgiref",
                    "wsgiserver"
                ],
                "owner": "NickC",
                "score": -1,
                "title": "How to read headers set by WSGI start_response",
                "created_at": "2026-06-13T14:04:06.000Z",
                "view_count": 17,
                "is_answered": true,
                "answer_count": 1,
                "last_activity_at": "2026-06-13T14:20:47.000Z",
                "accepted_answer_id": 79958535
            },
            {
                "id": 79958517,
                "link": "https://stackoverflow.com/questions/79958517/fastapi-returns-422-unprocessable-entity-on-post-from-next-js-fetch-despite-matc",
                "tags": [
                    "python",
                    "next.js",
                    "http-post",
                    "fastapi",
                    "pydantic"
                ],
                "owner": "Debanshu Paul",
                "score": -1,
                "title": "FastAPI returns 422 Unprocessable Entity on POST from Next.js fetch despite matching Pydantic model",
  
…(truncated, see openapi.json for full schema)
```

### Tags

#### `GET /v1/tags` — A site's tags by popularity or name

**Parameters:**
- `site` (query, optional, string) — Stack Exchange site slug (default stackoverflow; see /v1/sites) Example: `stackoverflow`
- `sort` (query, optional, string) — popular (default) or name Example: `popular`
- `limit` (query, optional, string) — Max results (1-50) Example: `25`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/stackexchange-api/v1/tags?site=stackoverflow&sort=popular&limit=25"
```

**Response:**
```json
{
    "data": {
        "site": "stackoverflow",
        "sort": "popular",
        "count": 25,
        "results": [
            {
                "name": ".net",
                "count": 341642,
                "is_required": false,
                "has_synonyms": true,
                "is_moderator_only": false
            },
            {
                "name": "android",
                "count": 1418133,
                "is_required": false,
                "has_synonyms": true,
                "is_moderator_only": false
            },
            {
                "name": "arrays",
                "count": 418296,
                "is_required": false,
                "has_synonyms": true,
                "is_moderator_only": false
            },
            {
                "name": "asp.net",
                "count": 373555,
                "is_required": false,
                "has_synonyms": true,
                "is_moderator_only": false
            },
            {
                "name": "c",
                "count": 409820,
                "is_required": false,
                "has_synonyms": false,
                "is_moderator_only": false
            },
            {
                "name": "c#",
                "count": 1626252,
                "is_required": false,
                "has_synonyms": true,
                "is_moderator_only": false
            },
            {
                "name": "c++",
                "count": 818063,
                "is_
…(truncated, see openapi.json for full schema)
```

### Meta

#### `GET /v1/sites` — Directory of Stack Exchange sites

**Parameters:**
- `limit` (query, optional, string) — Page size (1-100) Example: `50`
- `page` (query, optional, string) — Page (1-20) Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/stackexchange-api/v1/sites?limit=50&page=1"
```

**Response:**
```json
{
    "data": {
        "page": 1,
        "count": 50,
        "results": [
            {
                "name": "Stack Overflow",
                "slug": "stackoverflow",
                "audience": "professional and enthusiast programmers",
                "icon_url": "https://stackoverflow.com/Content/Sites/stackoverflow/Img/apple-touch-icon.png",
                "site_url": "https://stackoverflow.com",
                "site_type": "main_site"
            },
            {
                "name": "Server Fault",
                "slug": "serverfault",
                "audience": "system and network administrators",
                "icon_url": "https://serverfault.com/Content/Sites/serverfault/Img/apple-touch-icon.png",
                "site_url": "https://serverfault.com",
                "site_type": "main_site"
            },
            {
                "name": "Super User",
                "slug": "superuser",
                "audience": "computer enthusiasts and power users",
                "icon_url": "https://superuser.com/Content/Sites/superuser/Img/apple-touch-icon.png",
                "site_url": "https://superuser.com",
                "site_type": "main_site"
            },
            {
                "name": "Meta Stack Exchange",
                "slug": "meta",
                "audience": "meta-discussion of the Stack Exchange family of Q&amp;A websites",
                "icon_url": "https://meta.stackexchange.com/Content/Sites/stackexchangemeta/Img/appl
…(truncated, see openapi.json for full schema)
```


---
Marketplace page: https://www.oanor.com/api/stackexchange-api
OpenAPI spec: https://www.oanor.com/api/stackexchange-api/openapi.json
