> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stophy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Google scholar API

> Search Google Scholar for papers, books and case law, with citations. Call the Google scholar API for JSON. 1 credit per call.

Searches Google Scholar for papers, books and case law, with citations.

## Request

At least one of `query` or `citesId` is required. Set `citesId` to list the works that cite a result.

<CodeGroup>
  ```typescript TypeScript icon="https://mintlify.s3.us-west-1.amazonaws.com/sirathic/images/icons/typescript.svg" theme={null} theme={null}
  import { Stophy } from "stophy";

  const stophy = new Stophy({ apiKey: process.env.STOPHY_API_KEY });
  const result = await stophy.google.scholar({ query: "malaria vaccine efficacy" });
  console.log(result.data.results);
  ```

  ```python Python icon="python" theme={null} theme={null}
  from stophy import Stophy

  stophy = Stophy()  # reads STOPHY_API_KEY
  result = stophy.google.scholar(query="malaria vaccine efficacy")
  print(result["data"]["results"])
  ```

  ```bash cURL icon="terminal" theme={null} theme={null}
  curl -X POST https://api.stophy.dev/v1/google/scholar \
    -H "Authorization: Bearer $STOPHY_API_KEY" \
    -H "content-type: application/json" \
    -d '{"query":"malaria vaccine efficacy"}'
  ```

  ```bash CLI icon="square-terminal" theme={null} theme={null}
  stophy google scholar "malaria vaccine efficacy"
  ```
</CodeGroup>

## Response

If successful, the response body contains the standard envelope. `data.results[]` contains the papers, books and cases, each with its authors, year and the number of works that cite it.

The following example is a real response, truncated: each list shows one item and long strings are cut.

```json theme={null}
{
  "success": true,
  "data": {
    "results": [
      {
        "title": "Seven-year efficacy of RTS, S/AS01 malaria vaccine among young African children",
        "url": "https://www.nejm.org/doi/abs/10.1056/NEJMoa1515257",
        "format": "pdf",
        "authors": ["A Olotu", "G Fegan"],
        "publication": "England Journal of …",
        "year": 2016,
        "publisher": "Mass Medical Soc",
        "snippet": "… In an analysis that was not prespecified, the malaria exposure of each child was estimated … of malaria among…",
        "citations": 618,
        "citesId": "15871362944033457094",
        "versions": 14,
        "pdfUrl": "https://www.nejm.org/doi/pdf/10.1056/NEJMoa1515257",
        "position": 1
      }
    ],
    "page": 1
  },
  "creditsUsed": 1,
  "requestId": "2fe9dbad-fc48-4890-9751-0b24b596035b"
}
```

| Field | Type | Description |
| - | - | - |
| `citesId` | string | Pass it as `citesId` to list the works that cite this one. |
| `citations` | integer | The number of works cite this one. |
| `format` | string | Scholar's tag, such as \[PDF] or \[BOOK]. |
| `publication` | string | Journal or venue; the case citation for case law. |
| `page` | integer | The page number of this response. |
| `position` | integer | The 1-based position of the result in the list. |

For every field, see the response schema on this page.

## Optional parameters

| Parameter | Type | Description |
| - | - | - |
| `query` | string | Words to search for. |
| `citesId` | string | A result's `citesId`. Lists the works that cite it. |
| `yearFrom` | integer | Restricts results to works from this year on. Must be between 1700 and 2027. |
| `yearTo` | integer | Restricts results to works up to this year. Must be between 1700 and 2027. |
| `sort` | string | Specifies the order of the results. `newest` lists recent additions first. Acceptable values are `relevance` and `newest`. If unset, defaults to `relevance`. |
| `type` | string | Any type, review articles or case law. Acceptable values are `any`, `reviewArticles` and `caseLaw`. If unset, defaults to `any`. |
| `includePatents` | boolean | Include patents in the results. If unset, defaults to `false`. |
| `includeCitations` | boolean | Include works that Scholar knows only from citations. If unset, defaults to `true`. |
| `page` | integer | The page to return. Pages are numbered from 1. Must be between 1 and 20. If unset, defaults to `1`. |

## Billing

Each successful request consumes 1 credit, regardless of the number of items returned. Requests that fail, or that return no items, are not billed.

## Pagination

Results are paginated. To retrieve the next page, increment `page`. An empty `data.results` indicates the last page. The maximum value of `page` is 20.

## Related methods

* [Google Scholar](/api-reference/endpoint/google-scholar): Accepts a result's `citesId` as `citesId`. Searches Google Scholar for papers, books and case law, with citations.


## OpenAPI

````yaml api-reference/openapi.json POST /v1/google/scholar
openapi: 3.1.0
info:
  title: Stophy API
  version: '1'
  description: >-
    Every endpoint is a POST that takes its input as a JSON object body. Unknown
    fields are rejected with 400.


    Responses leave out empty values: null, empty strings, empty objects and
    empty nested lists are not sent.


    x-credits is what one call costs. Every call costs the same, whatever it
    returns, unless an operation's description says it costs per 10 results, or
    per second of audio. Then x-credits is the lowest price and x-credits-max
    the most one call can cost. Where an operation takes limit, send it to
    return fewer results and pay for fewer.


    When a response has a cursor, send it back unchanged with the same input to
    get the next page. When it has a page, send the next page number.
servers:
  - url: https://api.stophy.dev
security:
  - apiKey: []
paths:
  /v1/google/scholar:
    post:
      summary: Search Google Scholar for papers, books and case law, with citations
      description: Costs 1 credit per call. Pages with page.
      operationId: googleScholar
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  minLength: 1
                  maxLength: 256
                citesId:
                  description: >-
                    A result's citesId: lists the works that cite it, like
                    Scholar's Cited by.
                  type: string
                  pattern: ^\d{5,25}$
                yearFrom:
                  description: 'Scholar''s own Custom range: from this year.'
                  type: integer
                  minimum: 1700
                  maximum: 2027
                yearTo:
                  description: 'Scholar''s own Custom range: up to this year.'
                  type: integer
                  minimum: 1700
                  maximum: 2027
                sort:
                  default: relevance
                  description: Scholar's own sort. Newest lists recent additions first.
                  type: string
                  enum:
                    - relevance
                    - newest
                type:
                  default: any
                  description: Scholar's own Any type, Review articles, or Case law.
                  type: string
                  enum:
                    - any
                    - reviewArticles
                    - caseLaw
                includePatents:
                  default: false
                  type: boolean
                includeCitations:
                  default: true
                  description: >-
                    Scholar's own include citations: works known only from
                    citations.
                  type: boolean
                page:
                  default: 1
                  description: Page number, starting at 1.
                  type: integer
                  minimum: 1
                  maximum: 20
              additionalProperties: false
            example:
              query: malaria vaccine efficacy
      responses:
        '200':
          description: The data, and the credits this call used.
          headers:
            X-Request-ID:
              $ref: '#/components/headers/RequestId'
            x-credits-used:
              $ref: '#/components/headers/CreditsUsed'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
            x-cache:
              $ref: '#/components/headers/Cache'
            x-cache-age:
              $ref: '#/components/headers/CacheAge'
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                  - creditsUsed
                  - requestId
                properties:
                  success:
                    const: true
                  data:
                    type: object
                    additionalProperties: false
                    properties:
                      results:
                        type: array
                        items:
                          type: object
                          additionalProperties: false
                          properties:
                            title:
                              type: string
                              minLength: 1
                            url:
                              type: string
                              format: uri
                            format:
                              description: Scholar's tag, like [PDF] or [BOOK].
                              type: string
                              enum:
                                - pdf
                                - html
                                - book
                                - citation
                                - doc
                            authors:
                              type: array
                              items:
                                type: string
                                minLength: 1
                              description: As Scholar lists them; long lists end early.
                            publication:
                              description: >-
                                Journal or venue; the case citation for case
                                law.
                              type: string
                            year:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                            publisher:
                              description: >-
                                Publisher or site Scholar names; the court for
                                case law.
                              type: string
                            snippet:
                              type: string
                            citations:
                              description: Scholar's Cited by count.
                              type: integer
                              minimum: 0
                              maximum: 9007199254740991
                            citesId:
                              description: >-
                                Send as citesId to list the works that cite this
                                one.
                              type: string
                            versions:
                              type: integer
                              minimum: 0
                              maximum: 9007199254740991
                            pdfUrl:
                              type: string
                              format: uri
                            position:
                              type: integer
                              exclusiveMinimum: 0
                              maximum: 9007199254740991
                          required:
                            - title
                            - position
                      page:
                        type: integer
                        minimum: 1
                        maximum: 9007199254740991
                    required:
                      - results
                      - page
                  creditsUsed:
                    type: integer
                  requestId:
                    type: string
        4XX:
          $ref: '#/components/responses/Error'
        5XX:
          $ref: '#/components/responses/Error'
components:
  headers:
    RequestId:
      description: The request id. Quote it when you report a problem.
      schema:
        type: string
    CreditsUsed:
      description: Credits this call used.
      schema:
        type: integer
    RateLimitLimit:
      description: Requests allowed in the current window.
      schema:
        type: integer
    RateLimitRemaining:
      description: Requests left in the current window.
      schema:
        type: integer
    RateLimitReset:
      description: Unix time in seconds when the current window resets.
      schema:
        type: integer
    Cache:
      description: hit if this result came from the cache, miss if it was fetched live.
      schema:
        type: string
    CacheAge:
      description: Seconds since the returned result was written to the cache.
      schema:
        type: integer
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
  responses:
    Error:
      description: The request failed. retryable says whether trying again can help.
      headers:
        X-Request-ID:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - success
        - error
      properties:
        success:
          const: false
        error:
          type: object
          required:
            - code
            - message
            - retryable
            - requestId
          properties:
            code:
              type: string
              enum:
                - cliSessionCompleted
                - cliSessionExists
                - cliSessionNotFound
                - forbidden
                - insufficientCredits
                - internalError
                - inviteClaimed
                - inviteDisabled
                - inviteExpired
                - inviteUsedUp
                - invalidCliSession
                - invalidCliVerifier
                - invalidRequest
                - notFound
                - rateLimited
                - sourceChanged
                - sourceRefused
                - sourceTimeout
                - sourceUnavailable
                - tooManyInFlight
                - unauthorized
                - unsupportedMediaType
            message:
              type: string
            retryable:
              type: boolean
            retryAfterSeconds:
              type: integer
            requestId:
              type: string
            requiredCredits:
              type: number
            availableCredits:
              type: number
            billingUrl:
              type: string
              const: https://stophy.dev/billing
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.