How was this site built and where do they get the gold prices from?
Asked by
!CheckTheSpelling
I'm curious about the construction of this site: [goldpricecanada.ca](https://www.goldpricecanada.ca/). I'm interested in creating something similar and would like to know how they are getting the gold prices. Are they using an API? It's not clear if this site was built using WordPress, custom code, or another method. Any insights would be appreciated!
Answers
So, they're using a WebSocket that pushes updated prices every 5 seconds from the server. The server probably fetches that data from an unseen API. Even though theyโre using socket.io for their updates, I wouldn't advise using websockets if you're starting freshโit can be less efficient. If the data wonโt be huge, polling might be a better option instead. Also, thereโs been this websocket bug in Chrome that's worth knowing about if you go this route.
Reply to this answer
It seems like they have their own API and possibly leverage an external paid API for getting gold prices. The styling looks like it's done with Tailwind CSS. My two cents? This website appears to be custom-coded because if it were built on WordPress, the design would probably look better.
Reply to this answer
This site looks fully custom. If you check the network tab in your browser, you'll see WebSocket connections to a subdomain, which explains how they can update the prices in real-time without needing to refresh the page. Most likely, itโs built with Node.js and Socket.io for handling those live updates. They probably fetch gold price data from a real-time API service. By the way, what kind of site are you planning to create? Are you also going for real-time financial data?
Reply to this answer
Add your answer
Answers are reviewed before publication.
oven-mitt: Whatโs this websocket bug you mentioned? Iโve been dabbling with websockets too. Would love to hear more!