Market Leader
Market Leader

Reputation: 1

What is correct URL? {'quandl_error': {'code': 'QECx01', 'could not recognize URL: /api/v3/databases/WIKI/search. Please check URL and try again.'}

attempting to write a stock symbol search function with Quandl Python API. I registered with Nasdaq Data Link and configured quandl api key in my python file.

Here is code:

@app.route("/fetch_stock_symbols", methods=['GET', 'POST'])
def fetch_stock_symbols(query):
    url = f"https://www.quandl.com/api/v3/databases/WIKI/search.json?api_key={QUANDL_API_KEY}"

and Error: data: {'quandl_error': {'code': 'QECx01', 'message': 'We could not recognize the URL you requested: /api/v3/databases/WIKI/search. Please check your URL and try again.'}}

I was expecting Quandl to return query results as user enters keys. Here is javascript code:

  <script>
      const searchInput = document.getElementById("searchInput");
      const searchResultsDiv = document.getElementById("searchResults");

      async function searchSymbols() {
         const query = searchInput.value;
         const response = await fetch(`/search?query=${query}`);
         const data = await response.json();
         displaySearchResults(data.symbols);
      }

      function displaySearchResults(results) {
          searchResultsDiv.innerHTML = "";
          results.forEach(result => {
              const symbol = result.symbol;
              console.log(symbol);
              const name = result.name;
              const resultElement = document.createElement("div");
              const button = document.createElement("button");
              button.textContent = `Analyze ${symbol}`;
              button.addEventListener("click", () => securitiesAnalysis(symbol));
              resultElement.innerHTML = `<strong>${symbol}</strong>: ${name}`;
              resultElement.appendChild(button);
              searchResultsDiv.appendChild(resultElement);
          });
       }
       searchInput.addEventListener("input", searchSymbols);
    </script>

Upvotes: 0

Views: 32

Answers (0)

Related Questions