VBA Excel integration with RapidAPI for domain lookup service

I’m having trouble connecting VBA Excel with RapidAPI to fetch domain registration details. I’ve searched through several forum posts but haven’t found a working solution yet.

My goal is to read domain names from column A in my spreadsheet and populate column B with the registration information using an API service. The code runs without errors but doesn’t return the expected data.

Function FetchDomainInfo(siteName As String)
    Dim response, apiUrl, requestData As String
    Dim httpRequest, resultData, parsedJson As Object
    
    Set httpRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
    apiUrl = "https://jsonwhois.p.rapidapi.com/api/v1/whois/"
    
    httpRequest.Open "GET", apiUrl, False
    httpRequest.setRequestHeader "authorization", "Token token=your_token_here"
    httpRequest.setRequestHeader "x-rapidapi-host", "jsonwhois.p.rapidapi.com"
    httpRequest.setRequestHeader "x-rapidapi-key", "your_api_key_here"
    
    requestData = "domain=" + siteName
    httpRequest.Send (requestData)
    
    response = httpRequest.responseText
    Set parsedJson = JsonConverter.ParseJson(response)
    FetchDomainInfo = parsedJson
End Function

Sub ProcessDomains()
    Dim cellValue As String
    For Each cellValue In Range("A2:A50")
        If Not IsEmpty(cellValue.Value) Then
            Range("B" & Rows.Count).End(xlUp).Offset(1, 0) = FetchDomainInfo(cellValue.Value)
        End If
    Next cellValue
End Sub

Any suggestions on what might be going wrong with my API request setup?

Your main issue is how you’re sending the domain parameter. For GET requests with query parameters, append them to the URL instead of the request body. Change your apiUrl line to: apiUrl = “https://jsonwhois.p.rapidapi.com/api/v1/whois?domain=” + siteName. Remove the requestData variable completely and just use: httpRequest.Send. There’s another problem with your Range reference in ProcessDomains. You’re using Range(“B” & Rows.Count).End(xlUp).Offset(1, 0) which dumps all results in column B starting from the last used row, not matching them with the corresponding domain in column A. Use cellValue.Offset(0, 1) instead to place each result next to its domain. I’ve dealt with similar API integrations before - these changes should fix your data retrieval problems.

you’re missing the domain parameter in your url. build the full endpoint first - try apiUrl = \"https://jsonwhois.p.rapidapi.com/api/v1/whois/\" + siteName instead of sending it separately. also double-check your auth header - most rapidapi services only need the x-rapidapi-key header.

Had this exact issue last month. Your authorization header’s wrong - ditch the “Token token=” part entirely. RapidAPI just needs the x-rapidapi-key header. Also, make sure you’ve got JsonConverter imported since VBA doesn’t have that built-in. Add some error handling around httpRequest.Send and throw in Debug.Print httpRequest.Status after sending to see what’s actually happening. Btw, these domain APIs often hit you with 429 errors if you’re hammering them too fast in a loop. Try adding a small delay between requests.