openapi: 3.0.0
info:
  title: OpenAlex Search API
  description: |
    Search OpenAlex for scholarly works: articles, books, preprints, datasets and more.

    Each work carries its OpenAlex work id, DOI, publication date, type and language, its authors with their OpenAlex and ORCID ids and institutions, the source it was published in, its open access status and link, its citation count, its primary topic and keywords, and its abstract as text.

    Filters narrow works by publication year, type, open access, citations, language, institution country, or an author, institution, source or topic id. OpenAlex serves the first 10,000 results of a search, up to 100 per page.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: OpenAlex Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Search engine. Must be set to: `openalex_search`'
          schema:
            type: string
            enum: ["openalex_search"]
        - name: q
          in: query
          required: true
          description: The terms to search for. Quoted phrases and uppercase `AND`, `OR` and `NOT` work as in OpenAlex.
          schema:
            type: string
            maxLength: 1000
        - name: search_in
          in: query
          required: false
          description: Where to look for the terms. `all` searches titles, abstracts and full text. `title` searches titles only.
          schema:
            type: string
            enum: ["all", "title"]
            default: "all"
        - name: as_ylo
          in: query
          required: false
          description: Earliest publication year, such as `2020`.
          schema:
            type: integer
            minimum: 1
            maximum: 9999
        - name: as_yhi
          in: query
          required: false
          description: Latest publication year, such as `2024`. Must not be lower than `as_ylo`.
          schema:
            type: integer
            minimum: 1
            maximum: 9999
        - name: type
          in: query
          required: false
          description: Only works of this type.
          schema:
            type: string
            enum: ["article", "book", "book-chapter", "book-review", "conference-abstract", "conference-paper", "data-paper", "dataset", "dissertation", "editorial", "erratum", "letter", "other", "paratext", "peer-review", "preprint", "reference-entry", "report", "retraction", "review", "software", "software-paper", "standard", "study-registration", "supplementary-materials"]
        - name: is_open_access
          in: query
          required: false
          description: Set to `true` for open access works only.
          schema:
            type: boolean
            enum: [true]
        - name: open_access_status
          in: query
          required: false
          description: Only works with this open access status.
          schema:
            type: string
            enum: ["gold", "green", "hybrid", "bronze", "diamond", "closed"]
        - name: min_citations
          in: query
          required: false
          description: Only works cited at least this many times.
          schema:
            type: integer
            minimum: 0
            maximum: 999999999
        - name: author_id
          in: query
          required: false
          description: Only works by this author, given as an OpenAlex author id such as `A5061886400` (`author_id` in `authors`).
          schema:
            type: string
            pattern: '^[Aa][1-9]\d{0,11}$'
        - name: institution_id
          in: query
          required: false
          description: Only works with an author at this institution, given as an OpenAlex institution id such as `I241749` (`institution_id` in `institutions`).
          schema:
            type: string
            pattern: '^[Ii][1-9]\d{0,11}$'
        - name: source_id
          in: query
          required: false
          description: Only works published in this journal, repository or other source, given as an OpenAlex source id such as `S24807848` (`source_id` in `source`).
          schema:
            type: string
            pattern: '^[Ss][1-9]\d{0,11}$'
        - name: topic_id
          in: query
          required: false
          description: Only works whose primary topic is this one, given as an OpenAlex topic id such as `T10083` (`topic_id` in `primary_topic`).
          schema:
            type: string
            pattern: '^[Tt][1-9]\d{0,11}$'
        - name: institution_country
          in: query
          required: false
          description: Only works with an author at an institution in this country, as an ISO 3166-1 alpha-2 code such as `DE`.
          schema:
            type: string
            pattern: '^[A-Za-z]{2}$'
        - name: lr
          in: query
          required: false
          description: Only works in these languages, as Google Scholar `lang_` codes such as `lang_fr`. Join several with `|`, such as `lang_fr|lang_de`.
          schema:
            type: string
        - name: has_abstract
          in: query
          required: false
          description: Set to `true` for works with an abstract, or `false` for works without one.
          schema:
            type: boolean
        - name: sort_by
          in: query
          required: false
          description: Order of the works. `relevance` puts the best matches first, `cited_by_count` the most cited, `publication_date` the newest.
          schema:
            type: string
            enum: ["relevance", "cited_by_count", "publication_date"]
            default: "relevance"
        - name: num
          in: query
          required: false
          description: Number of works per page.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 10
        - name: page
          in: query
          required: false
          description: Page of works. `page` times `num` must be at most 10,000.
          schema:
            type: integer
            minimum: 1
            maximum: 10000
            default: 1
        - name: zero_retention
          in: query
          required: false
          description: Set to true to disable logging and persistent storage for this request. Enterprise plans only.
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: Validation Error. There is an issue with query parameters, such as missing required parameters or invalid values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan or waiting for the limit to reset.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Service Unavailable. Results could not be retrieved for this search. Please try again later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchResponse:
      type: object
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        search_information:
          $ref: '#/components/schemas/SearchInformation'
        organic_results:
          type: array
          description: Works that match the search, in the requested order.
          items:
            $ref: '#/components/schemas/OrganicResult'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Why the search returned no works.
    SearchMetadata:
      type: object
      required: [status, created_at]
      properties:
        id:
          type: string
          description: Unique identifier for the search request
        status:
          type: string
          description: Status of the search request
        created_at:
          type: string
          format: date-time
          description: Timestamp when the search was created
        request_time_taken:
          type: number
          description: Time taken to make the request in seconds
        parsing_time_taken:
          type: number
          description: Time taken to parse the results in seconds
        total_time_taken:
          type: number
          description: Total time taken for the search in seconds
        request_url:
          type: string
          description: OpenAlex search page for this search
        html_url:
          type: string
          description: URL to view the stored answer
        json_url:
          type: string
          description: URL to view JSON results
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Search engine used
        q:
          type: string
          description: The terms searched for
        search_in:
          type: string
          description: Where the terms were searched for
        as_ylo:
          type: integer
          description: Earliest publication year
        as_yhi:
          type: integer
          description: Latest publication year
        type:
          type: string
          description: Work type filter
        is_open_access:
          type: boolean
          description: Open access filter
        open_access_status:
          type: string
          description: Open access status filter
        min_citations:
          type: integer
          description: Minimum citation count
        author_id:
          type: string
          description: Author id filter
        institution_id:
          type: string
          description: Institution id filter
        source_id:
          type: string
          description: Source id filter
        topic_id:
          type: string
          description: Topic id filter
        institution_country:
          type: string
          description: Institution country filter
        lr:
          type: string
          description: Language filter
        has_abstract:
          type: boolean
          description: Abstract filter
        sort_by:
          type: string
          description: Order of the works
        num:
          type: integer
          description: Number of works per page
        page:
          type: integer
          description: Page of works
        zero_retention:
          type: boolean
          description: Whether the search was run without logging or storage
    SearchInformation:
      type: object
      required: [total_results]
      properties:
        total_results:
          type: integer
          description: Number of works OpenAlex counts for the search.
    OrganicResult:
      type: object
      required: [position, work_id, openalex_link, type, open_access, cited_by_count, is_retracted]
      properties:
        position:
          type: integer
          description: Position of the work in the results, counted across pages.
        work_id:
          type: string
          description: OpenAlex work id, such as `W2136334331`.
        openalex_link:
          type: string
          description: Link to the work on OpenAlex.
        title:
          type: string
          description: Title of the work.
        link:
          type: string
          description: Link to the work's landing page at its publisher or repository.
        doi:
          type: string
          description: DOI of the work, without the `https://doi.org/` prefix.
        publication_date:
          type: string
          format: date
          description: Publication date in `YYYY-MM-DD` format.
        publication_year:
          type: integer
          description: Publication year.
        type:
          type: string
          description: Type of the work, such as `article`, `review` or `book`.
        language:
          type: string
          description: ISO 639-1 code of the work's language.
        authors:
          type: array
          description: Authors of the work, in byline order.
          items:
            $ref: '#/components/schemas/Author'
        source:
          $ref: '#/components/schemas/Source'
        biblio:
          $ref: '#/components/schemas/Biblio'
        open_access:
          $ref: '#/components/schemas/OpenAccess'
        cited_by_count:
          type: integer
          description: Number of works in OpenAlex that cite this work.
        primary_topic:
          $ref: '#/components/schemas/PrimaryTopic'
        keywords:
          type: array
          description: Keywords OpenAlex assigns to the work.
          items:
            type: string
        abstract:
          type: string
          description: Abstract of the work as text.
        is_retracted:
          type: boolean
          description: Whether the work has been retracted.
        relevance_score:
          type: number
          description: How well the work matches the search. Returned with `sort_by` `relevance`.
    Author:
      type: object
      required: [name, is_corresponding]
      properties:
        name:
          type: string
          description: Name of the author.
        author_id:
          type: string
          description: OpenAlex author id, such as `A5061886400`. Use it as `author_id` to search the author's works.
        orcid:
          type: string
          description: ORCID iD of the author.
        position:
          type: string
          enum: ["first", "middle", "last"]
          description: Place of the author in the byline.
        is_corresponding:
          type: boolean
          description: Whether the author is a corresponding author.
        institutions:
          type: array
          description: Institutions the author is affiliated with for this work.
          items:
            $ref: '#/components/schemas/Institution'
    Institution:
      type: object
      required: [name, institution_id]
      properties:
        name:
          type: string
          description: Name of the institution.
        institution_id:
          type: string
          description: OpenAlex institution id, such as `I241749`. Use it as `institution_id` to search the institution's works.
        ror:
          type: string
          description: ROR link of the institution.
        country_code:
          type: string
          description: ISO 3166-1 alpha-2 code of the institution's country.
        type:
          type: string
          description: Kind of institution, such as `education`, `company` or `healthcare`.
    Source:
      type: object
      required: [name, source_id]
      properties:
        name:
          type: string
          description: Name of the journal, repository, conference or other source.
        source_id:
          type: string
          description: OpenAlex source id, such as `S24807848`. Use it as `source_id` to search the source's works.
        issn_l:
          type: string
          description: Linking ISSN of the source.
        type:
          type: string
          description: Kind of source, such as `journal`, `repository` or `conference`.
        publisher:
          type: string
          description: Publisher or host organization of the source.
    Biblio:
      type: object
      properties:
        volume:
          type: string
          description: Volume the work appears in.
        issue:
          type: string
          description: Issue the work appears in.
        first_page:
          type: string
          description: First page of the work.
        last_page:
          type: string
          description: Last page of the work.
    OpenAccess:
      type: object
      required: [is_open_access, status]
      properties:
        is_open_access:
          type: boolean
          description: Whether the work can be read for free.
        status:
          type: string
          enum: ["gold", "green", "hybrid", "bronze", "diamond", "closed"]
          description: Open access status of the work.
        link:
          type: string
          description: Link to a free copy of the work.
    PrimaryTopic:
      type: object
      required: [name, topic_id, subfield, field, domain]
      properties:
        name:
          type: string
          description: Name of the work's main topic.
        topic_id:
          type: string
          description: OpenAlex topic id, such as `T10083`. Use it as `topic_id` to search the topic's works.
        subfield:
          type: string
          description: Subfield the topic belongs to.
        field:
          type: string
          description: Field the topic belongs to.
        domain:
          type: string
          description: Domain the topic belongs to.
    Pagination:
      type: object
      required: [current]
      properties:
        current:
          type: integer
          description: Current page number.
        next:
          type: integer
          description: Next page number.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message
