# github.search_issues

**stable** **Advanced**

Search GitHub issues and pull requests.

`GET /v1/github/search_issues`

## What you get

A list of GitHub results in Onekey's unified shape, in `data` (an array). An empty array is a normal, successful answer and is charged like any other; a source that reports "nothing found" as an error returns a free `404 not_found` instead.

**Pagination:** 10 results per page. The response carries a `pagination` block; send its `next_cursor` back as the `cursor` parameter to get the next page. Every page is one call at the price below. See [Pagination](https://onekey.dev/docs/pagination.md).

## What it costs

- **Advanced · 5 credits** for a fresh fetch, charged only when it succeeds.
- **Free when served from cache (0.2 credit for a cached response over 100 KB).**
- **Free** if the request is invalid (never charged) or the source fails or reports not found (refunded).

## Parameters

| Name | Type | Required | Default | What it is | Constraints |
| --- | --- | --- | --- | --- | --- |
| `q` | string | yes | (required) | Search query | max 200 chars; trimmed, repeated spaces collapsed |
| `cursor` | string | no | - | Opaque cursor from a previous response's `pagination.next_cursor`. Omit for the first page. | - |

## Request

```bash
curl "https://api.onekey.dev/v1/github/search_issues?q=is%3Aissue%20is%3Aopen%20react%20hooks" \
  -H "x-api-key: YOUR_API_KEY"
```

```python
import requests

res = requests.get(
    "https://api.onekey.dev/v1/github/search_issues",
    params={"q": "is:issue is:open react hooks"},
    headers={"x-api-key": "YOUR_API_KEY"},
)
body = res.json()

if body["success"]:
    print(body["data"])
else:
    print(body["error"]["code"], body["error"]["message"])
```

```javascript
const params = new URLSearchParams({ q: "is:issue is:open react hooks" });
const res = await fetch(`https://api.onekey.dev/v1/github/search_issues?${params}`, {
  headers: { "x-api-key": "YOUR_API_KEY" },
});
const body = await res.json();

if (body.success) console.log(body.data);
else console.error(body.error.code, body.error.message);
```

## Recorded response

A real GitHub response, recorded and returned in Onekey's shape. Fields the platform does not provide are `null`.

```json
{
  "success": true,
  "data": [
    {
      "content": {
        "id": "318",
        "title": "[React] Hooks are not SSR-safe",
        "text": "**Area:** `packages/react` — **Difficulty:** intermediate\n\n## Context\nThe provider and hooks assume a browser. Rendering them in Next.js or any SSR framework risks touching `window` during the server pass.\n\n## What to do\n- [ ] Audit the provider and hooks for browser-only globals at module scope\n- [ ] Guard effects so the server render is inert\n- [ ] Add a minimal Next.js example under `packages/react/example/`\n- [ ] Add a test that renders the provider with `react-dom/server`\n\n## Acceptance criteria\n- The provider renders on the server without throwing\n- Run `pnpm --filter @stellaragent/react test`\n\n## Pointers\n- `packages/react/src/StellarAgentProvider.tsx`\n\n---\nNew here? Read [CONTRIBUTING.md](../blob/main/CONTRIBUTING.md) first. Comment on this issue to claim it, and ask questions in the thread — a half-finished PR with a question beats a silent fork.",
        "url": "https://github.com/StellarAgent-AI-Agent-Payment-Rails/Stellar-agentic/issues/318",
        "createdAt": "2026-08-24T20:33:49Z",
        "updatedAt": "2026-09-28T10:27:41Z",
        "state": "open"
      },
      "author": {
        "username": "Emmy123222"
      },
      "engagement": {
        "comments": 3,
        "likes": 0
      }
    },
    {
      "content": {
        "id": "35",
        "title": "Remediate React compiler lint findings before react-hooks 7",
        "text": "Dependabot PR #19 activates 66 react-hooks compiler-rule errors, primarily refs read or written during render and synchronous state changes in effects. Fix behavior file by file with meaningful tests or interaction checks, then re-enable the eslint-plugin-react-hooks major-update policy. Do not disable the new rules merely to merge the dependency update.",
        "url": "https://github.com/stoicescueric/control-lab/issues/35",
        "createdAt": "2026-09-11T06:28:51Z",
        "updatedAt": "2026-09-11T06:28:51Z",
        "state": "open"
      },
      "author": {
        "username": "stoicescueric"
      },
      "engagement": {
        "comments": 0,
        "likes": 0
      }
    }
  ],
  "metadata": {
    "platform": "github",
    "endpoint": "search_issues",
    "cached": false,
    "stale": false,
    "age_s": 0,
    "fetched_at": "2026-01-01T12:00:00+00:00",
    "credits_charged": 5,
    "request_id": "7f3a9c2e5b1d4c8fa2e6d0b9c4f18e37"
  },
  "error": null
}
```

## Field mapping

How this endpoint's source fields become Onekey's [unified schema](https://onekey.dev/docs/schema.md). Fields the source lacks come back as `null`.

| Source path | Onekey field | Transform |
| --- | --- | --- |
| `number` | `content.id` | `toString` |
| `title` | `content.title` | - |
| `body` | `content.text` | - |
| `html_url` | `content.url` | `safeUrl` |
| `created_at` | `content.createdAt` | `toIsoDate` |
| `updated_at` | `content.updatedAt` | `toIsoDate` |
| `state` | `content.state` | - |
| `user.login` | `author.username` | - |
| `comments` | `engagement.comments` | `toNumber` |
| `reactions.total_count` | `engagement.likes` | `toNumber` |

## Caching and freshness

- Fresh for about 2 minutes. Repeat calls in that window are served from cache and are free.
- Between 2 minutes and 15 minutes the cached copy is still served instantly and marked `stale: true` while Onekey refreshes it in the background.
- If the source is down when a refresh is needed, the last copy can be served for up to 1 hour more (marked stale).
- A "not found" is remembered for 1 minute and is free.
- The cache is shared across all customers, which is what keeps repeat calls cheap.

## What can go wrong

| Status | Code | What to do |
| --- | --- | --- |
| 401 | `unauthorized` | Check the `x-api-key` header. |
| 402 | `insufficient_credits` | [Add credits](https://onekey.dev/pricing); your balance must cover the price. |
| 404 | `not_found` | Unknown endpoint path. |
| 422 | `invalid_params` | Fix the parameters using the table above. Free. |
| 429 | `rate_limited` | Wait `Retry-After` seconds, then retry. |
| 502 | `upstream_error` | The source failed. Refunded; retry with backoff. |

See [Errors](https://onekey.dev/docs/errors.md) for the full list and retry guidance.

Status: stable (verified against the live source).
