AutoIt Requires Chilkat v11.7.0+
AutoIt
Stripe: Export a period of account activity
See more Stripe Examples
Export account activity for a UTC date range to CSV, including transaction references, fees, net amounts, and currencies.
Stripe documentation and cURL example
Chilkat AutoIt Downloads
Local $bSuccess = False
; Requires an unlocked Chilkat bundle. See Global Unlock Sample.
; Supply a restricted sandbox key from merchant-controlled configuration.
Local $sApiKey = "YOUR_STRIPE_TEST_KEY"
$oCurl = ObjCreate("Chilkat.HttpCurl")
$oCmd = ObjCreate("Chilkat.StringBuilder")
$oJson = ObjCreate("Chilkat.JsonObject")
Local $iReplaced
; Example UTC interval: 1 October 2026 inclusive through 1 November exclusive.
Local $sFromTime = "1790812800"
Local $sUntilTime = "1793491200"
$oLedger = ObjCreate("Chilkat.Csv")
$oLedger.HasColumnNames = True
Local $iOutputRow = 0
$oLedger.SetColumnName(0,"id")
$oLedger.SetColumnName(1,"created")
$oLedger.SetColumnName(2,"source")
$oLedger.SetColumnName(3,"reporting_category")
$oLedger.SetColumnName(4,"amount")
$oLedger.SetColumnName(5,"fee")
$oLedger.SetColumnName(6,"net")
$oLedger.SetColumnName(7,"currency")
$oPageSuffix = ObjCreate("Chilkat.StringBuilder")
Local $bMore = True
Local $sCursor = ""
While ($bMore = True)
; curl -X GET "https://api.stripe.com/v1/balance_transactions?created%5Bgte%5D={fromTime}&created%5Blt%5D={untilTime}&limit=100" \
; -u "$STRIPE_API_KEY:" \
; -H "Stripe-Version: 2026-10-28.endive"
$oCmd.SetString("curl -X GET ""https://api.stripe.com/v1/balance_transactions?created%5Bgte%5D=@FROM@&created%5Blt%5D=@UNTIL@&limit=100@CURSOR@""")
$oCmd.Append(" -u ""@KEY@:""")
$oCmd.Append(" -H ""Stripe-Version: 2026-10-28.endive""")
$iReplaced = $oCmd.Replace("@CURSOR@",$oPageSuffix.GetAsString())
$iReplaced = $oCmd.Replace("@FROM@",$sFromTime)
$iReplaced = $oCmd.Replace("@UNTIL@",$sUntilTime)
$iReplaced = $oCmd.Replace("@KEY@",$sApiKey)
$bSuccess = $oCurl.DoYourThing($oCmd.GetAsString())
If ($bSuccess <> True) Then
ConsoleWrite("No HTTP response. Chilkat failure code: " & $oCurl.FailReason & @CRLF)
Exit
EndIf
$bSuccess = $oCurl.GetResponseJson($oJson)
If (($oCurl.StatusCode <> 200) Or ($bSuccess <> True)) Then
ConsoleWrite("Stripe HTTP " & $oCurl.StatusCode & " Request-Id: " & $oCurl.GetResponseHeaderField("Request-Id") & @CRLF)
If ($bSuccess = True) Then
ConsoleWrite($oJson.StringOf("error.message") & @CRLF)
EndIf
Exit
EndIf
Local $i = 0
Local $iCount = $oJson.SizeOfArray("data")
While ($i < $iCount)
$oJson.I = $i
$oLedger.SetCell($iOutputRow,0,$oJson.StringOf("data[i].id"))
$oLedger.SetCell($iOutputRow,1,$oJson.StringOf("data[i].created"))
$oLedger.SetCell($iOutputRow,2,$oJson.StringOf("data[i].source"))
$oLedger.SetCell($iOutputRow,3,$oJson.StringOf("data[i].reporting_category"))
$oLedger.SetCell($iOutputRow,4,$oJson.StringOf("data[i].amount"))
$oLedger.SetCell($iOutputRow,5,$oJson.StringOf("data[i].fee"))
$oLedger.SetCell($iOutputRow,6,$oJson.StringOf("data[i].net"))
$oLedger.SetCell($iOutputRow,7,$oJson.StringOf("data[i].currency"))
$iOutputRow = $iOutputRow + 1
$i = $i + 1
Wend
$bMore = $oJson.BoolOf("has_more")
If ($bMore = True) Then
Local $sNext = $oJson.StringOf("data[i].id")
If (($iCount < 1) Or ($sNext = "") Or ($sNext = $sCursor)) Then
ConsoleWrite("Invalid pagination cursor." & @CRLF)
Exit
EndIf
$sCursor = $sNext
$oPageSuffix.SetString("&starting_after=")
$oPageSuffix.Append($sCursor)
EndIf
Wend
$bSuccess = $oLedger.SaveFile("stripe-balance-transactions.csv")
If ($bSuccess = False) Then
ConsoleWrite($oLedger.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Exported rows: " & $iOutputRow & @CRLF)