---
title: "Stack Overflow API: question search as JSON | Perceptlayer"
description: "Stack Overflow API for question search, question details, answers and comments as JSON, with scores, tags and view counts. 1 credit per successful call."
url: https://perceptlayer.com/apis/stackoverflow
---

[APIs](https://perceptlayer.com/apis) / [Apps and media](https://perceptlayer.com/verticals/apps) / Stack Overflow

1 credit per call 4 endpoints 15 datapoints 

# Stack Overflow API

Stack Overflow API for question search, question details, answers and comments as JSON, with scores, tags and view counts. 1 credit per successful call.

[Get a free API key](https://perceptlayer.com/signup) Run it below

Stack Overflow

GET /v1/stackoverflow/search?q=laravel+queue&tagged=php&sort=votes 

```
{
  "success": true,
  "data": {
    "search_parameters": {
      "q": "laravel queue",
      "tagged": "php",
      "sort": "votes",
      "order": "desc"
    },
    "questions": [
      {
        "question_id": 25877752,
        "title": "Laravel queue process timeout error",
        "link": "https://stackoverflow.com/questions/25877752/laravel-queue-process-timeout-error",
        "tags": [
          "php",
          "symfony",
          "laravel"
        ],
        "score": 82,
        "view_count": 112277,
        "answer_count": 4,
        "comment_count": 5,
        "is_answered": true,
        "accepted_answer_id": 26238686,
        "created_at": "2014-09-16T20:21:27Z",
        "last_activity_at": "2022-12-24T01:39:22Z",
        "owner": {
          "user_id": 1512641,
          "display_name": "Will Durney",
          "reputation": 1258,
          "user_type": "registered",
          "accept_rate": 86,
          "link": "https://stackoverflow.com/users/1512641/will-durney",
          "profile_image": "https://www.gravatar.com/avatar/76b63456d16d4c9877f9c590487fc755?s=256&d=identicon&r=PG"
        },
        "body": "<p>I'm on Laravel using <code>php artisan queue:listen</code> to run queued jobs. One of these jobs is fairly involved and takes a long time, and so I'm getting the following error:</p>\n\n<pre><code>[Symfony\\Component\\Process\\Exception\\Proce…",
        "body_text": "I'm on Laravel using php artisan queue:listen to run queued jobs. One of these jobs is fairly involved and takes a long time, and so I'm getting the following error:\n\n[Symfony\\Component\\Process\\Exception\\ProcessTimedOutException] \nThe proce…"
      },
      {
        "question_id": 33457639,
        "title": "How to inject dependencies to a laravel job",
        "link": "https://stackoverflow.com/questions/33457639/how-to-inject-dependencies-to-a-laravel-job",
        "tags": [
          "php",
          "laravel",
          "laravel-5"
        ],
        "score": 43,
        "view_count": 27151,
        "answer_count": 4,
        "comment_count": 0,
        "is_answered": true,
        "accepted_answer_id": 33458379,
        "created_at": "2015-10-31T23:17:31Z",
        "last_activity_at": "2024-09-04T10:04:47Z",
        "owner": {
          "user_id": 2561122,
          "display_name": "Acho Arnold",
          "reputation": 1263,
          "user_type": "registered",
          "accept_rate": 50,
          "link": "https://stackoverflow.com/users/2561122/acho-arnold",
          "profile_image": "https://www.gravatar.com/avatar/2e59fc57acb64eed70c958f4e1ad5e60?s=256&d=identicon&r=PG"
        },
        "body": "<p>I'm adding a laravel job to my queue from my controller as such</p>\n\n<pre><code>$this-&gt;dispatchFromArray(\n    'ExportCustomersSearchJob',\n    [\n        'userId' =&gt; $id,\n        'clientId' =&gt; $clientId\n    ]\n);\n</code></pre>\n\n<p>…",
        "body_text": "I'm adding a laravel job to my queue from my controller as such\n\n$this->dispatchFromArray(\n 'ExportCustomersSearchJob',\n [\n 'userId' => $id,\n 'clientId' => $clientId\n ]\n);\n\nI would like to inject the userRepository as a dependency when impl…"
      },
      {
        "question_id": 35412779,
        "title": "How to get all pending jobs in laravel queue on redis?",
        "link": "https://stackoverflow.com/questions/35412779/how-to-get-all-pending-jobs-in-laravel-queue-on-redis",
        "tags": [
          "php",
          "laravel",
          "redis"
        ],
        "score": 41,
        "view_count": 89443,
        "answer_count": 7,
        "comment_count": 0,
        "is_answered": true,
        "accepted_answer_id": 42182586,
        "created_at": "2016-02-15T15:11:26Z",
        "last_activity_at": "2022-01-06T18:47:07Z",
        "last_edited_at": "2022-01-06T18:44:02Z",
        "owner": {
          "user_id": 978690,
          "display_name": "rap-2-h",
          "reputation": 32408,
          "user_type": "registered",
          "accept_rate": 94,
          "link": "https://stackoverflow.com/users/978690/rap-2-h",
          "profile_image": "https://i.sstatic.net/lNUl6.png?s=256"
        },
        "body": "<p>The <code>queue:listen</code> was not run on a server, so some jobs were pushed (using Redis driver) but never run.</p>\n<p>How could I count (or get all) these jobs? I did not find any artisan command to get this information.</p>\n",
        "body_text": "The queue:listen was not run on a server, so some jobs were pushed (using Redis driver) but never run.\n\nHow could I count (or get all) these jobs? I did not find any artisan command to get this information."
      }
    ],
    "page": 1,
    "pagesize": 30,
    "has_more": true
  },
  "meta": {
    "endpoint_family": "search",
    "request_id": "req_b24552b89e2e488a83c3127fdc0cfd19",
    "credits_charged": 1,
    "credits_remaining": 1778
  }
}
```

200 OK JSON X-Credits-Used: 1

Recorded from our API and shortened.

Sample data

## What one call returns

A recorded run of `search`: the fields and shapes you will get, shortened to 3 items.

| # | question\_id integer | title string | link url | tags string\[\] | score integer | view\_count integer | answer\_count integer | comment\_count integer | is\_answered boolean | accepted\_answer\_id integer | created\_at string | last\_activity\_at string | owner object | body string | body\_text string |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| 1 | 25877752 | Laravel queue process timeout error | https://stackoverflow.com/questions/25877752/laravel-queue-process-timeout-error | \[3 items\] | 82 | 112277 | 4 | 5 | true | 26238686 | 2014-09-16T20:21:27Z | 2022-12-24T01:39:22Z | {7 fields} | <p>I'm on Laravel using <code>php artisan queue:listen</code> to run queued jobs. One of these jobs is fairly involved and takes a long time, and so I'm getting the following error:</p> <pre><code>\[Symfony\\Component\\Process\\Exception\\Proce… | I'm on Laravel using php artisan queue:listen to run queued jobs. One of these jobs is fairly involved and takes a long time, and so I'm getting the following error: \[Symfony\\Component\\Process\\Exception\\ProcessTimedOutException\] The proce… |
| 2 | 33457639 | How to inject dependencies to a laravel job | https://stackoverflow.com/questions/33457639/how-to-inject-dependencies-to-a-laravel-job | \[3 items\] | 43 | 27151 | 4 | 0 | true | 33458379 | 2015-10-31T23:17:31Z | 2024-09-04T10:04:47Z | {7 fields} | <p>I'm adding a laravel job to my queue from my controller as such</p> <pre><code>$this-&gt;dispatchFromArray( 'ExportCustomersSearchJob', \[ 'userId' =&gt; $id, 'clientId' =&gt; $clientId \] ); </code></pre> <p>… | I'm adding a laravel job to my queue from my controller as such $this->dispatchFromArray( 'ExportCustomersSearchJob', \[ 'userId' => $id, 'clientId' => $clientId \] ); I would like to inject the userRepository as a dependency when impl… |
| 3 | 35412779 | How to get all pending jobs in laravel queue on redis? | https://stackoverflow.com/questions/35412779/how-to-get-all-pending-jobs-in-laravel-queue-on-redis | \[3 items\] | 41 | 89443 | 7 | 0 | true | 42182586 | 2016-02-15T15:11:26Z | 2022-01-06T18:47:07Z | {7 fields} | <p>The <code>queue:listen</code> was not run on a server, so some jobs were pushed (using Redis driver) but never run.</p> <p>How could I count (or get all) these jobs? I did not find any artisan command to get this information.</p> | The queue:listen was not run on a server, so some jobs were pushed (using Redis driver) but never run. How could I count (or get all) these jobs? I did not find any artisan command to get this information. |

Recorded from our API · 3 items shown · 15 datapoints per item GET /v1/stackoverflow/search?q=laravel+queue&tagged=php&sort=votes

15 datapoints

### Identity

-   question\_id integer
-   title string
-   accepted\_answer\_id integer

### Contact

-   link url
-   owner object

### Reputation

-   score integer

### Other

-   tags string\[\]
-   view\_count integer
-   answer\_count integer
-   comment\_count integer
-   is\_answered boolean
-   created\_at string
-   last\_activity\_at string
-   body string
-   body\_text string

Playground

## Run this API

cURL shell 

```
curl "https://api.perceptlayer.com/v1/stackoverflow/search?q=laravel+queue&tagged=php&sort=votes" \
  -H "X-API-Key: $API_KEY"
```

Stack Overflow · 4 endpoints

## Endpoints

Every endpoint takes the same key. Open one for its parameters, the fields it returns and an example request.

| Endpoint | Required parameters | Returns | Cost |
| --- | --- | --- | --- |
| [GET `/v1/stackoverflow/answers`](https://perceptlayer.com/apis/stackoverflow/answers) | `question_id` +4 optional | JSON | 1 credit |
| [GET `/v1/stackoverflow/comments`](https://perceptlayer.com/apis/stackoverflow/comments) | `question_id` +4 optional | JSON | 1 credit |
| [GET `/v1/stackoverflow/question`](https://perceptlayer.com/apis/stackoverflow/question) | `question_id` | JSON | 1 credit |
| [GET `/v1/stackoverflow/search`](https://perceptlayer.com/apis/stackoverflow/search) | none +6 optional | `search_parameters` `questions` `pagesize` | 1 credit |

Overview

## About the Stack Overflow API

## What you can get

The Stack Overflow API returns Stack Overflow questions, answers and comments as JSON through 4 endpoints.

-   **Search:** `search` takes a `q` and `tagged`, with `sort` (activity, votes, creation or relevance), `order` (asc or desc), `page` and `pagesize`.
-   **Questions:** `question` takes a `question_id`.
-   **Answers:** `answers` takes a `question_id`, with `sort` (votes, activity or creation), `order`, `page` and `pagesize`.
-   **Comments:** `comments` takes a `question_id`, with `sort` (creation or votes), `order`, `page` and `pagesize`.

The recorded search for "laravel queue" tagged php, sorted by votes, returns `questions`, each with `question_id`, `title`, `link`, `tags`, `score`, `view_count`, `answer_count`, `comment_count`, `is_answered`, `accepted_answer_id`, `created_at`, `last_activity_at`, `owner`, `body` and `body_text`. It also returns `search_parameters`, `page`, `pagesize` and `has_more`.

## How a call works

Search, then read the thread: `GET /v1/stackoverflow/search?q=laravel queue&tagged=php&sort=votes`, with your key in the `X-API-Key` header, returns each question's `question_id`. Pass that to `question`, `answers` or `comments`, for example `GET /v1/stackoverflow/answers?question_id=11227809&sort=votes`. Check `has_more` before asking for the next `page`. Every successful call costs 1 credit; failed calls cost nothing.

Apps and media JSON REST MCP

### More apps and media APIs

[Apple App Store](https://perceptlayer.com/apis/apple-app-store) [Apple Podcasts](https://perceptlayer.com/apis/apple-podcasts) [arXiv](https://perceptlayer.com/apis/arxiv) [Audible](https://perceptlayer.com/apis/audible) [Bandcamp](https://perceptlayer.com/apis/bandcamp) [Chrome Web Store](https://perceptlayer.com/apis/chrome-web-store) [CISA KEV](https://perceptlayer.com/apis/cisa-kev) [ClinicalTrials.gov](https://perceptlayer.com/apis/clinicaltrials) [Coursera](https://perceptlayer.com/apis/coursera) [crates.io](https://perceptlayer.com/apis/crates-io) [Crossref](https://perceptlayer.com/apis/crossref) [Discogs](https://perceptlayer.com/apis/discogs)

Use cases

### Find the most-voted questions for a tag and keyword

`Use the Stack Overflow API to find the most-voted questions for a tag and keyword` 

### Pull a question with its answers and comments into a support knowledge base

`Use the Stack Overflow API to pull a question with its answers and comments into a support knowledge base` 

### Track new and recently active questions about your library or product

`Use the Stack Overflow API to track new and recently active questions about your library or product` 

### Spot unanswered questions with \`is\_answered\` and \`answer\_count\`

`` Use the Stack Overflow API to spot unanswered questions with `is_answered` and `answer_count` `` 

FAQ

## Questions

**How much does the Stack Overflow API cost?**

Each successful call costs one credit, and each search page is one call. New accounts get free credits to start, and credit packs bring the price down as you scale.

**Do I need a Stack Overflow account?**

No. You call this Stack Overflow API with your Perceptlayer key in the \`X-API-Key\` header, with no Stack Overflow login.

**Can I get the question text without HTML?**

Yes. Search results carry both \`body\`, with the HTML markup, and \`body\_text\`, as plain text.

**What format are responses in?**

Every endpoint returns JSON, with no HTML parsing on your side.

**Is this the official Stack Overflow API?**

No. Perceptlayer is an independent service and is not affiliated with Stack Overflow. It returns Stack Overflow data as JSON with a Perceptlayer key, so there is no Stack Overflow developer account, app review or partner approval to get first. It only reads data: if Stack Overflow has an official API and you need to act on your own Stack Overflow account, such as posting, managing orders or reading private data, use that one.

**Should I build a Stack Overflow scraper instead?**

You can, but a Stack Overflow scraper is code you maintain: page changes break it, requests get blocked, and Stack Overflow's terms govern how you collect data. The Stack Overflow API gives you 4 endpoints of named JSON fields for 1 credit per successful call, and failed calls cost nothing. A scraper makes sense only for data these endpoints don't return, so check the response in the playground on this page first.

## Try the Stack Overflow API with 100 free credits

No credit card. Failed calls are never billed.

[Get a free API key](https://perceptlayer.com/signup) [Read the docs](https://docs.perceptlayer.com)
