Sub api()
Dim url As String
Dim cle As String
Dim parametre As String
Dim request As WinHttpRequest
Set request = New WinHttpRequest
url = "https://alpha-vantage.p.rapidapi.com/"
parametre = "query?function=TIME_SERIES_DAILY&symbol=MSFT&outputsize=compact&datatype=csv"
cle = "ac4460a83emshcb214093cc18a63p1f0a09jsnc26cc5a29252"
request.Open "GET", url & parametre
request.SetRequestHeader "X-RapidAPI-Host", "alpha-vantage.p.rapidapi.com"
request.SetRequestHeader "X-RapidAPI-Key", cle
request.Send
If request.Status = 200 Then
Dim Buffer As Variant, R As Long, V As Variant, Nv As Integer
Cells.ClearContents
Buffer = Trim(request.ResponseText)
For Each Line In Split(Buffer, vbCrLf)
R = R + 1
V = Split(Line, ","): If Nv = 0 Then Nv = UBound(V)
Range("A" & R).Resize(, Nv).Value = V
Next
Range(Cells(1, 1), Cells(R, Nv)) = Range(Cells(1, 1), Cells(R, Nv)).Value
Else
MsgBox request.Status & " " & request.StatusText & vbLf & request.ResponseText
End If
End Sub