Having trouble integrating PancakeSwap token price feed into my website

Hey everyone, I’ve been working on a restaurant-themed website (focused on Texas Roadhouse deals, coupons, and reviews), and I recently decided to experiment by adding a small crypto-related feature for visitors. The idea was to display live token prices (like CAKE, BNB, etc.) directly on the site using PancakeSwap’s public data or API. However, I’m running into several issues when trying to connect to the PancakeSwap API endpoints — the requests either time out or return CORS policy errors in the browser console.

At first, I thought it was a temporary issue with my hosting or DNS setup, but after testing locally, I realized the problem seems to be related to how my frontend is making API calls. I’m using a simple JavaScript fetch request to pull token price data from https://api.pancakeswap.info/api/v2/tokens/``<token_address>. It works fine for a few minutes, but then it suddenly starts returning 429 Too Many Requests or sometimes just Failed to Fetch. I tried adding a proxy server in between, but even then, the data doesn’t always load reliably.

Another issue I’m facing is that when the API actually works, the price data sometimes freezes or doesn’t refresh even after setting an interval timer. My goal is to have the live CAKE token price auto-update every 30 seconds, but instead, it either duplicates data or stops after the first refresh. I’ve tested it in Chrome, Firefox, and Edge — same behavior across all browsers. It feels like there’s some caching or throttling happening on the PancakeSwap side that I’m not handling properly.

I also considered pulling the data via a Web3 connection using a BSC node instead of the PancakeSwap REST API, but I’ve never implemented that before. I’m using basic HTML and JS right now, but if it requires Web3.js or Ethers.js, I can definitely set that up. I just want to make sure I’m fetching accurate token prices directly from the blockchain (or a reliable PancakeSwap endpoint) without getting blocked or rate-limited.

To add to the confusion, when I checked my website logs, I saw random errors like Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'price'). It seems like the JSON response sometimes changes format, or maybe the endpoint structure has been updated recently? I couldn’t find much documentation on how often PancakeSwap updates their API or if there’s a best practice for web integrations.

Has anyone here successfully integrated PancakeSwap’s live token prices or liquidity data into a website? If so, what’s the best approach — should I rely on the public API, or is there a better method using BSCScan or Web3 calls? Any tips on avoiding request throttling or CORS blocks would be super helpful. I’d love to get this working smoothly since my audience is increasingly interested in crypto-friendly restaurant deals and CAKE token holders are a growing part of my community. Sorry for the long post!

Is there anyone who can help me? I would love your guidance!