TradingView-API icon indicating copy to clipboard operation
TradingView-API copied to clipboard

Issue with searchIndicator not returning results for some search terms.

Open BelugaWhale opened this issue 1 year ago • 1 comments

Hello when I do searchIndicator with this search term: "Squeeze Momentum Indicator [LazyBear]"

it returns nothing.

If I do searchIndicator on just "Squeeze" the first result is this:

[
  {
    id: 'PUB;175',
    version: '-1',
    name: 'Squeeze Momentum Indicator [LazyBear]',
    author: { id: 175, username: 'LazyBear' },
    image: 'nqQ1DT5a',
    access: 'open_source',
    source: '//\r\n' +
      '// @author LazyBear \r\n' +
....
    type: 'study',
    get: [Function: get]
  },
  { ....
  

any idea why I cant find this one by name?

I also tried various other search terms none worked like Squeeze Momentum Squeeze Momentum Indicator %5BLazyBear%5D Squeeze0Momentum%20Indicator%20%5BLazyBear%5D

no results for all

code i used to test:

                    const rs = await TradingView.searchIndicator(search_term);
                    console.log(rs.slice(0, 10));

Kindly assist me, thank you

BelugaWhale avatar Nov 13 '24 15:11 BelugaWhale

hey btw i have figured out a work around and know the cause of the bug too. u have a line

    const { data } = await axios.get(
      'https://www.tradingview.com/pubscripts-suggest-json',
      {
        params: {
          search: search.replace(/ /g, '%20'),
        },
        validateStatus,
      },
    );

which is coverting space characters to %20 but in ur url this becomes %2520 which is not a space character. So the search returns nothing. I have temporarily resolved it by using + in place of space as this does not get affected by ur replace string and is treated the same in the url. Thansk for this repo btw, its awesome and ur awesome. Hope this helps to resolve a bug.

BelugaWhale avatar Nov 14 '24 14:11 BelugaWhale