반응형
API Reference
HTTP Method | API URL |
GET | https://api.upbit.com/v1/deposits/coin_addresses |
HEADERS
헤더명 | 필수 여부 | 설명 | 타입 |
Authorization | Y | Authorization token (JWT) | String |
Response
필드명 | 설명 | 타입 |
currency | 화폐를 의미하는 영문 대문자 코드 | String |
deposit_address | 입금 주소 | String |
secondary_address | 2차 입금 주소 | String |
VBA Code
Sub Upbit_Deposits_CoinAddresses()
Const ACCESS_KEY As String = "UPBIT_OPEN_API_ACCESS_KEY"
Const SECRET_KEY As String = "UPBIT_OPEN_API_SECRET_KEY"
Dim WinHttp As New WinHttp.WinHttpRequest
Dim url As String, nonce As String, queryStr As String
Dim header As String, payload As String, signature As String, jwt As String
url = "https://api.upbit.com/v1/deposits/coin_addresses"
nonce = DateDiff("s", "1/1/1970", Now) & Right(Timer() * 100, 3)
header = Base64Encode(StrConv("{""alg"":""HS256"",""typ"":""JWT""}", vbFromUnicode))
payload = "{""access_key"":""" & ACCESS_KEY & """,""nonce"":""" & nonce & """,""query"":""" & queryStr & """}"
payload = Base64Encode(StrConv(payload, vbFromUnicode))
signature = Base64Encode(SHA256Encrypt(header & "." & payload, SECRET_KEY))
jwt = header & "." & payload & "." & signature
With WinHttp
.Open "GET", url
.SetRequestHeader "Authorization", "Bearer " & jwt
.Send
.WaitForResponse
Debug.Print .ResponseText
End With
Set WinHttp = Nothing
End Sub
SHA-256 Encrypt
더보기
Function SHA256Encrypt(text As String, Optional secretKey As String = vbNullString) As Byte()
Dim asc As Object, enc As Object
Dim bText() As Byte, bKey() As Byte, bytes() As Byte
Set asc = CreateObject("System.Text.UTF8Encoding")
If secretKey <> vbNullString Then
Set enc = CreateObject("System.Security.Cryptography.HMACSHA256")
bText = asc.Getbytes_4(text)
bKey = asc.Getbytes_4(secretKey)
enc.Key = bKey
bytes = enc.ComputeHash_2(bText)
Else
Set enc = CreateObject("System.Security.Cryptography.SHA256Managed")
bText = asc.Getbytes_4(text)
bytes = enc.ComputeHash_2((bText))
End If
SHA256Encrypt = bytes
Set asc = Nothing
Set enc = Nothing
End Function
Base64 Encode
더보기
Function Base64Encode(ByRef arrData() As Byte) As String
Dim objXML As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMElement
Set objXML = New MSXML2.DOMDocument
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData
Base64Encode = Replace(objNode.text, Chr(10), vbNullString)
Set objNode = Nothing
Set objXML = Nothing
End Function
업비트 OPEN API
Upbit Open API v1.0.6
반응형
'VBA > Code' 카테고리의 다른 글
[VBA] ColorSum (0) | 2019.12.16 |
---|---|
[VBA] 업비트 Open API>입금>개별 입금 주소 조회 (0) | 2019.10.05 |
[VBA] 업비트 Open API>입금>입금 주소 생성 요청 (0) | 2019.10.05 |
[VBA] 업비트 Open API>입금>개별 입금 조회 (0) | 2019.10.05 |
[VBA] 업비트 Open API>입금>입금 리스트 조회 (0) | 2019.10.05 |