Skip to content

Instantly share code, notes, and snippets.

@ljskatt
Last active June 23, 2020 22:19
Show Gist options
  • Save ljskatt/fb0aa042aff960808dc3a7327df4a7c8 to your computer and use it in GitHub Desktop.
Save ljskatt/fb0aa042aff960808dc3a7327df4a7c8 to your computer and use it in GitHub Desktop.
Get coinbase wallet information by using API keys to your coinbase account, needs permission: "wallet:accounts:read"
$cb_key = ""
$cb_secret = ""
$timestamp = (Invoke-RestMethod -Uri "https://api.coinbase.com/v2/time").data.epoch
$cb_message = "$timestamp" + "GET/v2/accounts"
$hmacsha = New-Object System.Security.Cryptography.HMACSHA256
$hmacsha.key = [Text.Encoding]::UTF8.GetBytes($cb_secret)
$signature = ([System.BitConverter]::ToString($hmacsha.ComputeHash([Text.Encoding]::UTF8.GetBytes($cb_message))) -replace "-").ToLower()
$headers = @{"CB-ACCESS-KEY" = "$cb_key"; "CB-ACCESS-SIGN" = "$signature"; "CB-ACCESS-TIMESTAMP" = "$timestamp"}
$cb_wallets = (Invoke-RestMethod -Uri "https://api.coinbase.com/v2/accounts" -Method "GET" -Headers $headers).data
#$cb_wallets - Coinbase Wallet information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment