openapi: 3.0.0
info:
  title: Google Rank Tracking API
  description: |
    The Google Rank Tracking API provides programmatic access to track ranking positions on Google Search for specific keywords. This API returns up to 100 organic search results, allowing you to monitor your website's ranking positions over time.

    **Key Features:**
    - Returns up to 100 organic results (configurable with `num` parameter)
    - Supports desktop and mobile devices
    - Supports location-based searches
    - Works across all Google domains and languages

    **Cross-linking**: This API is optimized for rank tracking and returns only organic results. For comprehensive search results including featured snippets, knowledge graph, ads, etc., use the regular Google Search API.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Google Rank Tracking Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine to use
          schema:
            type: string
            enum: ["google_rank_tracking"]
        - name: q
          in: query
          required: true
          description: Search query
          schema:
            type: string
        - name: device
          in: query
          required: false
          description: Device to simulate for the search
          schema:
            type: string
            enum: ["desktop", "mobile", "tablet"]
            default: "desktop"
        - name: location
          in: query
          required: false
          description: Geographic location for the search. When location is used, the uule parameter is automatically generated
          schema:
            type: string
        - name: uule
          in: query
          required: false
          description: Google's encoded location parameter. This is automatically set when using the location parameter
          schema:
            type: string
        - name: gl
          in: query
          required: false
          description: Country code for Google search (ISO 3166-1 alpha-2)
          schema:
            type: string
            enum: ["af", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "au", "at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm", "bt", "bo", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc", "co", "km", "cg", "cd", "ck", "cr", "ci", "hr", "cu", "cy", "cz", "dk", "dj", "dm", "do", "ec", "eg", "sv", "gq", "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in", "id", "ir", "iq", "ie", "il", "it", "jm", "jp", "jo", "kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "me", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "bl", "sh", "kn", "lc", "mf", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sx", "sk", "si", "sb", "so", "za", "gs", "ss", "es", "lk", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tl", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv", "ug", "ua", "ae", "uk", "us", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw"]
            default: "us"
        - name: hl
          in: query
          required: false
          description: Language for the Google search interface
          schema:
            type: string
            enum: ["af", "ak", "sq", "am", "ar", "hy", "az", "eu", "be", "bem", "bn", "bh", "xx-bork", "bs", "br", "bg", "km", "ca", "chr", "ny", "zh-cn", "zh-tw", "co", "hr", "cs", "da", "nl", "xx-elmer", "en", "eo", "et", "ee", "fo", "tl", "fi", "fr", "fy", "gaa", "gl", "ka", "de", "el", "kl", "gn", "gu", "xx-hacker", "ht", "ha", "haw", "iw", "hi", "hmn", "hu", "is", "ig", "id", "ia", "ga", "it", "ja", "jv", "kn", "kk", "rw", "rn", "xx-klingon", "kg", "ko", "kri", "ku", "ky", "lo", "la", "lv", "ln", "lt", "loz", "lg", "ach", "mk", "mg", "ms", "ml", "mt", "mi", "mr", "mfe", "mo", "mn", "sr-me", "my", "ne", "pcm", "nso", "no", "nn", "oc", "or", "om", "ps", "fa", "xx-pirate", "pl", "pt-br", "pt-pt", "pa", "qu", "ro", "rm", "nyn", "ru", "gd", "sr", "sh", "st", "tn", "crs", "sn", "sd", "si", "sk", "sl", "so", "es", "es-419", "su", "sw", "sv", "tg", "ta", "tt", "te", "th", "ti", "to", "lua", "tum", "tr", "tk", "tw", "ug", "uk", "ur", "uz", "vi", "cy", "fy", "wo", "xh", "yi", "yo", "zu"]
            default: "en"
        - name: lr
          in: query
          required: false
          description: Restricts search results to documents written in a particular language
          schema:
            type: string
            enum: ["lang_ar", "lang_hy", "lang_bg", "lang_ca", "lang_cs", "lang_da", "lang_de", "lang_el", "lang_en", "lang_es", "lang_et", "lang_tl", "lang_fi", "lang_fr", "lang_hr", "lang_hi", "lang_hu", "lang_id", "lang_is", "lang_it", "lang_iw", "lang_ja", "lang_ko", "lang_lt", "lang_lv", "lang_nl", "lang_no", "lang_fa", "lang_pl", "lang_pt", "lang_ro", "lang_ru", "lang_sk", "lang_sl", "lang_sr", "lang_sv", "lang_th", "lang_tr", "lang_uk", "lang_vi", "lang_zh-cn", "lang_zh-tw"]
        - name: safe
          in: query
          required: false
          description: SafeSearch filtering level
          schema:
            type: string
            enum: ["active", "blur", "off"]
            default: "blur"
        - name: page
          in: query
          required: false
          description: Page number for pagination (1-10). Each page contains 10 results. For example, page=2 fetches positions 11-20, and page=3 fetches positions 21-30. Note that results are capped at position 100. If page=10 and num=100, only positions 91-100 are returned.
          schema:
            type: integer
            minimum: 1
            maximum: 10
            default: 1
        - name: num
          in: query
          required: false
          description: Number of results to return (1-100)
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 100
      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: Timeout. We could not retrieve results in 90 seconds.
          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'
        error:
          type: string
          description: Error message if the search failed
        organic_results:
          type: array
          description: Array of organic search results
          items:
            $ref: '#/components/schemas/OrganicResult'
    SearchMetadata:
      type: object
      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: Google URL for this search
        html_url:
          type: string
          description: URL to view raw HTML results
        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: Search query
        device:
          type: string
          description: Device type used for the search
        hl:
          type: string
          description: Language of the search interface
        gl:
          type: string
          description: Country code used for the search
        page:
          type: integer
          description: Page number used for pagination
        num:
          type: integer
          description: Number of results requested
        uule:
          type: string
          description: Encoded location parameter
        location:
          type: string
          description: Geographic location used for the search
        location_used:
          type: string
          description: Canonical location name that was used
        lr:
          type: string
          description: Language restriction parameter
        safe:
          type: string
          description: SafeSearch setting
    OrganicResult:
      type: object
      properties:
        position:
          type: integer
          description: Position of the result (1-100)
        title:
          type: string
          description: Title of the search result
        link:
          type: string
          description: URL of the search result
        source:
          type: string
          description: Source website name
        domain:
          type: string
          description: Domain of the result
        displayed_link:
          type: string
          description: Display URL shown in the result
        snippet:
          type: string
          description: Text snippet from the result
        snippet_highlighted_words:
          type: array
          description: Highlighted words in the snippet
          items:
            type: string
        sitelinks:
          $ref: '#/components/schemas/Sitelinks'
        favicon:
          type: string
          description: URL of the site's favicon
        thumbnail:
          type: string
          description: Thumbnail image URL
        date:
          type: string
          description: Publication date if available
        rich_snippet:
          $ref: '#/components/schemas/RichSnippet'
    Sitelinks:
      type: object
      properties:
        inline:
          type: array
          description: Inline sitelinks
          items:
            type: object
            properties:
              title:
                type: string
                description: Sitelink title
              link:
                type: string
                description: Sitelink URL
    RichSnippet:
      type: object
      properties:
        detected_extensions:
          type: object
          description: Automatically detected structured data
          properties:
            rating:
              type: number
              description: Rating value
            reviews:
              type: integer
              description: Number of reviews
        extensions:
          type: array
          description: Raw extension strings
          items:
            type: string
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
