반응형
API Reference
HTTP Method | API URL |
POST | https://api.upbit.com/v1/deposits/generate_coin_address |
BODY PARAMS
필드명 | 필수 여부 | 설명 | 타입 |
currency | Y | Currency symbol | String |
HEADERS
헤더명 | 필수 여부 | 설명 | 타입 |
Authorization | Y | Authorization token (JWT) | String |
Request Parameters
필드명 | 설명 | 타입 |
currency | Currency 코드 | String |
Response1
필드명 | 설명 | 타입 |
success | 요청 성공 여부 | Boolean |
message | 요청 결과에 대한 메세지 | String |
Response2
필드명 | 설명 | 타입 |
currency | 화폐를 의미하는 영문 대문자 코드 | String |
deposit_address | 입금 주소 | String |
secondary_address | 2차 입금 주소 | String |
VBA Code
Sub Upbit_Deposits_GenerateCoinAddress()
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
Dim xCurrency As String
url = "https://api.upbit.com/v1/deposits/generate_coin_address"
xCurrency = "BTC"
queryStr = "currency=" & xCurrency
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 "POST", url
.SetRequestHeader "Authorization", "Bearer " & jwt
.SetRequestHeader "content-type", "application/json"
.Send ("{""" & Replace(Replace(queryStr, "=", """:"""), "&", """,""") & """}")
.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] 업비트 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 |
[VBA] 업비트 Open API>출금>원화 출금하기 (0) | 2019.10.05 |