openapi: 3.0.0
info:
  title: TradingView Symbol Search API
  description: |
    Search TradingView's catalog of instruments by ticker, company or asset name, ISIN or CUSIP: stocks, funds, futures, forex, crypto, indexes, bonds, economic series and options, on every market TradingView covers.

    Each result is one listing with its TradingView id in the `EXCHANGE:SYMBOL` form (`NASDAQ:AAPL`, `FX_IDC:EURUSD`, `BINANCE:BTCUSDT`), its type, currency, country and identifiers when TradingView has them, and a link to its TradingView page. A futures root lists its contracts, each with its own id (`CME_MINI:NQ1!` for the continuous contract).

    Results come 50 to a page, and TradingView returns at most 10,000 results per search, so the last page is 200.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: TradingView Symbol Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Search engine. Must be set to: `tradingview_symbol_search`'
          schema:
            type: string
            enum: ["tradingview_symbol_search"]
        - name: q
          in: query
          required: true
          description: A ticker, company or asset name, ISIN or CUSIP, up to 200 bytes of text (about 66 Chinese, Japanese or Korean characters). An `EXCHANGE:SYMBOL` id such as `NASDAQ:AAPL` searches that exchange for the symbol.
          schema:
            type: string
        - name: type
          in: query
          required: false
          description: Instrument type to return. Leave it out to search every type. `stocks` includes depositary receipts and `crypto` includes crypto indexes and futures.
          schema:
            type: string
            enum: ["stocks", "funds", "futures", "forex", "crypto", "index", "bond", "economic", "options"]
        - name: exchange
          in: query
          required: false
          description: TradingView exchange code to search, such as `NASDAQ`, `NSE` or `BINANCE`.
          schema:
            type: string
            pattern: '^[A-Za-z0-9_]{1,32}$'
        - name: country
          in: query
          required: false
          description: Country of the listings to return (ISO 3166-1 alpha-2). `EU` returns European futures, and `UK` is read as `GB`.
          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", "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", "SH", "KN", "LC", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "GS", "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", "GB", "US", "UM", "UY", "UZ", "VU", "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW", "GG", "JE", "IM", "ME", "EU"]
        - name: gl
          in: query
          required: false
          description: Country whose listings TradingView ranks first (ISO 3166-1 alpha-2). It changes the order of results, not which ones match.
          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", "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", "sh", "kn", "lc", "pm", "vc", "ws", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sk", "si", "sb", "so", "za", "gs", "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", "gb", "us", "um", "uy", "uz", "vu", "ve", "vn", "vg", "vi", "wf", "eh", "ye", "zm", "zw", "gg", "je", "im", "me"]
            default: "us"
        - name: hl
          in: query
          required: false
          description: Language of the instrument names, for the names TradingView translates.
          schema:
            type: string
            enum: ["en", "ar", "de", "es", "fr", "he", "id", "it", "ja", "ko", "ms", "pl", "pt", "ru", "th", "tr", "vi", "zh-cn", "zh-tw"]
            default: "en"
        - name: page
          in: query
          required: false
          description: Page of results, 50 per page.
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 1
      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'
        search_information:
          $ref: '#/components/schemas/SearchInformation'
        symbols:
          type: array
          description: Instruments TradingView lists for the search, in TradingView's order.
          items:
            $ref: '#/components/schemas/Symbol'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Message returned when TradingView has no result for the search or the page, or refuses to answer it.
    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
          nullable: true
          description: "Always null for this engine"
        html_url:
          type: string
          description: "URL to view 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: The text searched for
        type:
          type: string
          description: Instrument type searched
        exchange:
          type: string
          description: Exchange code searched
        country:
          type: string
          description: Country of the listings searched
        gl:
          type: string
          description: Country ranked first
        hl:
          type: string
          description: Language of the instrument names
        page:
          type: integer
          description: Page of results
    SearchInformation:
      type: object
      required: [total_results]
      properties:
        total_results:
          type: integer
          description: Number of instruments TradingView matches for the search, up to 10,000.
    Symbol:
      type: object
      required: [position, symbol, ticker, exchange, link]
      properties:
        position:
          type: integer
          description: Position of the instrument in the results, counted across pages.
        symbol:
          type: string
          description: TradingView id of the instrument in the EXCHANGE:SYMBOL form.
        ticker:
          type: string
          description: Ticker of the instrument on its exchange.
        name:
          type: string
          description: Name of the instrument in the language asked for.
        thumbnail:
          type: string
          description: Link to the logo TradingView shows for the instrument.
        type:
          type: string
          description: Instrument type, such as stock, dr, fund, futures, forex, spot, index, bond, economic or option.
        subtypes:
          type: array
          description: TradingView's finer classification of the instrument, such as common, etf, corporate or crypto.
          items:
            type: string
        exchange:
          type: string
          description: Exchange code in the instrument's TradingView id.
        exchange_name:
          type: string
          description: Name of the exchange, or of the publisher for an economic series.
        currency:
          type: string
          description: Currency the instrument is quoted in.
        country:
          type: string
          description: Country of the instrument's market (ISO 3166-1 alpha-2), or EU for European futures.
        isin:
          type: string
          description: ISIN of the instrument.
        cusip:
          type: string
          description: CUSIP of the instrument.
        cik:
          type: string
          description: SEC Central Index Key of the issuer.
        is_primary_listing:
          type: boolean
          description: Whether this listing is the instrument's primary listing.
        contracts:
          type: array
          description: Contracts of a futures root.
          items:
            $ref: '#/components/schemas/Contract'
        link:
          type: string
          description: Link to the instrument's page on TradingView.
    Contract:
      type: object
      required: [symbol]
      properties:
        symbol:
          type: string
          description: TradingView id of the contract in the EXCHANGE:SYMBOL form.
        name:
          type: string
          description: Expiry month of the contract.
        subtypes:
          type: array
          description: TradingView's classification of the contract, such as continuous or mini.
          items:
            type: string
    Pagination:
      type: object
      required: [current]
      properties:
        current:
          type: integer
          description: Current page number.
        next_page:
          type: integer
          description: Number of the next page.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
