Dashboard de Tenis en Tiempo Real con WebSocket y JavaScript

Imagen
¿Por qué utilizar WebSocket en lugar de una API REST? El caso de Tennis API Cuando trabajamos con APIs, normalmente pensamos en solicitudes HTTP tradicionales donde una aplicación consulta información cada cierto tiempo. Sin embargo, para aplicaciones que requieren datos en tiempo real, existe una alternativa mucho más eficiente: WebSocket. Mientras exploraba las capacidades de Tennis API encontré su integración mediante Socket.IO, una tecnología que permite recibir actualizaciones en tiempo real sin necesidad de realizar consultas constantes al servidor. ¿Cómo funciona una API REST tradicional? Con una API REST, la aplicación debe preguntar periódicamente si existen nuevos datos. Por ejemplo: setInterval(async () => { const response = await fetch("/live-scores"); const data = await response.json(); console.log(data); }, 5000); En este caso la aplicación realiza una consulta cada 5 segundos. El problema es que muchas veces no existe información nue...

How to Get Exchange Rates in Excel Automatically Using a Free API (VBA Step-by-Step)

How to Get Exchange Rates in Excel Automatically Using a Free API (VBA Step-by-Step)

Automate exchange rates in Excel in minutes. In this guide, you’ll learn how to retrieve currency data from multiple countries (including African currencies) using a free API and VBA.

This example is perfect if you work with financial reports, currency analysis, or need updated data without manual input.


🚀 What will you learn?

  • How to get real-time exchange rates in Excel
  • How to use a free API (no API key required)
  • How to automate Excel with VBA
  • How to retrieve multiple currencies (USD, MXN, EUR, ZAR, NGN, etc.)

🌍 Free Exchange Rate API

For this example, we will use the following free API:

👉 https://open.er-api.com/v6/latest/USD

Advantages:

  • No API key required
  • 150+ currencies available
  • Includes African currencies
  • Daily updated data (not historical)

💻 VBA Macro to Get Exchange Rates in Excel

Copy and paste this code into a VBA module:


Sub GetExchangeRates()

    Dim http As Object
    Dim json As Object
    Dim url As String
    
    url = "https://open.er-api.com/v6/latest/USD"
    
    Set http = CreateObject("MSXML2.XMLHTTP")
    http.Open "GET", url, False
    http.Send
    
    If http.Status = 200 Then
    
        Set json = JsonConverter.ParseJson(http.responseText)
        
        Range("A1").Value = "Currency"
        Range("B1").Value = "Exchange Rate vs USD"
        
        Range("A2").Value = "MXN"
        Range("B2").Value = json("rates")("MXN")
        
        Range("A3").Value = "EUR"
        Range("B3").Value = json("rates")("EUR")
        
        Range("A4").Value = "ZAR"
        Range("B4").Value = json("rates")("ZAR")
        
        Range("A5").Value = "NGN"
        Range("B5").Value = json("rates")("NGN")
        
    Else
        MsgBox "API request failed"
    End If

End Sub

⚠️ Requirement: JSON Parser for VBA

To make this work, you need to import the JsonConverter.bas library.

Download it here:

👉 https://github.com/VBA-tools/VBA-JSON

Then:

  • Open VBA (Alt + F11)
  • Go to File → Import File
  • Select JsonConverter.bas

🔹 Enable Reference

In VBA, go to:

Tools > References

And enable:

Microsoft Scripting Runtime


📊 Excel Output

After running the macro, you’ll get a table with updated exchange rates:

  • MXN → Mexican Peso
  • EUR → Euro
  • ZAR → South African Rand
  • NGN → Nigerian Naira



💡 What can you use this for?

  • Automated financial reports
  • Currency conversion in Excel
  • International market analysis
  • API integrations in Excel

📥 Download Ready-to-Use Excel Template

Want to save time? Get the ready-to-use Excel file:

  • ✔ One-click update
  • ✔ 150+ currencies
  • ✔ VBA code included

👉 Download here


🔗 Related: Banxico API (Mexico)

If you need official exchange rates in Mexico, check this guide:

👉 How to use Banxico API step by step


❓ FAQ

Can Excel get exchange rates automatically?
Yes, by using an API and VBA you can update exchange rates instantly.

Do I need Power Query?
No, this solution works using VBA only.


🎯 Conclusion

With this macro, you can fully automate exchange rate retrieval in Excel using a free API.

This type of solution is widely used in professional environments where up-to-date data is required without manual work.

TIP: You can expand this to build dashboards or automate financial reports 😉

Comentarios

🚀 Mantener este blog funcionando requiere tiempo y café. ¡Puedes contribuir con uno aquí!

Entradas más populares de este blog

Guía Práctica: Ejemplo Completo de ASPX para Desarrolladores Web

👉 Cómo obtener el tipo de cambio en Excel con API de Banxico (paso a paso)

Macro en Word para automatizar documentos: genera diplomas en segundos (con código VBA)