Integrating RapidAPI with VBA Excel - Need Help Getting JSON Data

I’m trying to fetch live sports data from RapidAPI using Excel VBA but I’m running into some issues. The API service doesn’t have direct VBA examples in their documentation which makes it tricky for me.

My goal is to get real-time cricket match data and display it in my Excel spreadsheet. I’ve been looking at their REST API documentation and found this sample code structure:

const apiSettings = {
  method: 'GET',
  endpoint: SERVICE_ENDPOINT,
  headers: {
    'Authorization': 'Bearer ' + TOKEN_KEY,
    'Accept': 'application/json',
    'User-Agent': 'MyApp/1.0'
  },
  params: {
    league: 'cricket-live',
    format: 'json'
  }
};

fetch(apiSettings.endpoint, {
  method: apiSettings.method,
  headers: apiSettings.headers
})
.then(response => response.json())
.then(data => {
  console.log('Match data:', data);
})
.catch(err => {
  console.error('API Error:', err);
});

I’m wondering if there’s a way to make direct HTTP requests from VBA to get this JSON data, or maybe view the API response directly in a web browser first to understand the data structure better. Has anyone successfully connected RapidAPI services with Excel VBA before?

for sure, benmoore! xmlhttp is super useful in vba for this stuff. just remember to throw in the x-rapidapi-key and x-rapidapi-host in your headers! parsing json ain’t too hard either. you’ll get it sorted, good luck!

Yeah, you can do this with VBA’s XMLHTTP object. I’ve done similar API integrations before - always test the endpoint in Postman first to see what the response looks like. For the VBA part: create an XMLHTTP request, set it to GET, and add the headers (X-RapidAPI-Key and X-RapidAPI-Host - RapidAPI needs both). After you get the response, you can parse it manually with string functions or use the Microsoft Scripting Runtime library for JSON parsing. Make sure you handle errors properly since APIs fail for all sorts of reasons - rate limits, connection issues, whatever. Start with a basic test call to confirm your auth works, then build out the data extraction from there.