Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions examples/Visual Basic.net/example.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2020
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "example", "example\example.vbproj", "{03F65997-9226-4781-A478-EE76977DCD5E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{03F65997-9226-4781-A478-EE76977DCD5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03F65997-9226-4781-A478-EE76977DCD5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03F65997-9226-4781-A478-EE76977DCD5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03F65997-9226-4781-A478-EE76977DCD5E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {87A0AA32-91BC-41DB-9070-0D40C8C7CB9E}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions examples/Visual Basic.net/example/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
152 changes: 152 additions & 0 deletions examples/Visual Basic.net/example/Bl3p_PrivateApi.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
' Coded by [email protected]
' it has been released under AGPL v3.0
' it requires "Flurl https://tmenier.github.io/Flurl/"

Imports System.Security.Cryptography
Imports Flurl
Imports Flurl.Http

Friend Class Bl3p_PrivateApi
'base Url to bl3p
Dim host As String = "https://api.bl3p.eu/1/"
Public publickey As String
Public privatekey As String

'Fetch complete orderbook
Public Function fullDepth(ByVal currency As String) As String
'call bl3p api and return its json
Dim json As String = ApiCall(currency.ToUpper & "EUR/money/depth/full")
Return json
End Function

'Get balance for all wallets
Public Function wallets() As String
'call bl3p api and return its json
Dim json As String = ApiCall("GENMKT/money/info")
Return json
End Function

'create new deposit address.
Public Function getNewDepositAddress(ByVal currency As String) As String
'call bl3p api and return its json
Dim json As String = ApiCall(currency.ToUpper & "EUR/money/new_deposit_address")
Return json
End Function

'Add order to your account.
Public Function addOrder(ByVal currency As String, ByVal type As String, ByVal amount_int As Int32, ByVal price_int As Int32, ByVal fee_currency As String) As String
Dim parameters = New List(Of KeyValuePair(Of String, String))()
parameters.Add(New KeyValuePair(Of String, String)("type", type))
parameters.Add(New KeyValuePair(Of String, String)("amount_int", amount_int * 100000000.0))
parameters.Add(New KeyValuePair(Of String, String)("price_int", price_int * 100000.0))
parameters.Add(New KeyValuePair(Of String, String)("fee_currency", fee_currency.ToUpper))
'call bl3p api and return its json
Dim json As String = ApiCall(currency.ToUpper & "EUR/money/order/add", parameters)
Return json
End Function

'Fetch complete orderbook
Public Function orderInfo(ByVal currency As String, ByVal orderid As String) As String
Dim parameters = New List(Of KeyValuePair(Of String, String))()
parameters.Add(New KeyValuePair(Of String, String)("order_id", orderid))
'call bl3p api and return its json
Dim json As String = ApiCall(currency.ToUpper & "EUR/money/order/result", parameters)
Return json
End Function

'cancel order
Public Function cancelOrder(ByVal currency As String, ByVal orderid As String) As String
Dim parameters = New List(Of KeyValuePair(Of String, String))()
parameters.Add(New KeyValuePair(Of String, String)("order_id", orderid))
'call bl3p api and return its json
Dim json As String = ApiCall(currency.ToUpper & "EUR/money/order/cancel", parameters)
Return json
End Function

'Get all open orders.
Public Function getAllActiveOrders(ByVal currency As String) As String
'call bl3p api and return its json
Dim json As String = ApiCall(currency.ToUpper & "EUR/money/orders")
Return json
End Function

'Get the most recent generated deposit address
Public Function getLastDepositAddress(ByVal currency As String) As String
'call bl3p api and return its json
Dim json As String = ApiCall(currency.ToUpper & "EUR/money/deposit_address")
Return json
End Function

'Get the transaction history
Public Function walletHistory(ByVal currency As String, ByVal type As String, ByVal pages As Integer) As String
'create the POST parameters list needed for the wallet history [currency] [recs_per_page]
Dim parameters = New List(Of KeyValuePair(Of String, String))()
'create new parameter and add to list
parameters.Add(New KeyValuePair(Of String, String)("currency", currency.ToUpper))
parameters.Add(New KeyValuePair(Of String, String)("recs_per_page", pages))
parameters.Add(New KeyValuePair(Of String, String)("type", type)) ' filter (Can be: ‘trade’, ‘fee’, ‘deposit’, ‘withdraw’)
'call bl3p api and return its json
Dim json As String = ApiCall("GENMKT/money/wallet/history", parameters)
Return json

End Function

Private Function ApiCall(ByVal path As String, Optional parameters As List(Of KeyValuePair(Of String, String)) = Nothing) As String
Try

'make timestamp in milisecs
Dim timestamp = Math.Round((Date.Now.ToUniversalTime() - New Date(1970, 1, 1)).Ticks)

'check if there are any parameters passed to the api
If parameters Is Nothing Then
' if no parameters pass create list
parameters = New List(Of KeyValuePair(Of String, String))()
End If
' add nonce to all calls
parameters.Add(New KeyValuePair(Of String, String)("nonce", timestamp))

'build POST parameters
Dim parameterURl As String = ""
For Each key In parameters
'for each key add to url
parameterURl += key.Key & "=" & key.Value & "&"
Next
'trim last & from parameter URL
parameterURl = parameterURl.TrimEnd("&")

'make a message to send
Dim message = path & vbNullChar & parameterURl
'create the Rest signature
Dim signature = CreateSignature(message, privatekey)
'call the api and get response
Dim coinbasewalletinfo = host.AppendPathSegments(path).WithHeader("Content-Type", "application/json").WithHeader("Rest-Key", publickey).WithHeader("Rest-Sign", signature).PostUrlEncodedAsync(parameters).ReceiveJson(Of Object)().Result

'print response
Return coinbasewalletinfo.ToString
Catch ex As Exception
'get error message
Dim errormessagefull As String = ex.InnerException.Message
'get json from the error message and pass it tru
Dim errorJson As String = errormessagefull.Substring(errormessagefull.IndexOf("{"c))
Return errorJson
End Try

End Function

Private Function CreateSignature(ByVal message As String, ByVal key As String) As String
'decode the key with base64
Dim Decodedkey() As Byte = Convert.FromBase64String(key)
'get message as byte
Dim encoding = New System.Text.UTF8Encoding()
Dim messageBytes() As Byte = encoding.GetBytes(message)
'make HMACSHA512
Using hmacsha1 = New HMACSHA512(Decodedkey)
'compute hash with decoded key
Dim hashmessage() As Byte = hmacsha1.ComputeHash(messageBytes)
'return base64 encoded string
Return Convert.ToBase64String(hashmessage)
End Using
End Function


End Class
11 changes: 11 additions & 0 deletions examples/Visual Basic.net/example/Module1.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Module Module1

Sub Main()
Dim Bl3p As New Bl3p_PrivateApi With {.publickey = "", .privatekey = ""}
' Console.WriteLine(Bl3p.walletHistory("LTC", 25))
'Console.WriteLine(Bl3p.getLastDepositAddress("LTC"))
Console.WriteLine(Bl3p.fullDepth("LTC"))
Console.ReadKey()
End Sub

End Module

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions examples/Visual Basic.net/example/My Project/Application.myapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>false</MySubMain>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<ApplicationType>2</ApplicationType>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>
35 changes: 35 additions & 0 deletions examples/Visual Basic.net/example/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices

' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.

' Review the values of the assembly attributes

<Assembly: AssemblyTitle("example")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("example")>
<Assembly: AssemblyCopyright("Copyright © 2018")>
<Assembly: AssemblyTrademark("")>

<Assembly: ComVisible(False)>

'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("8f2b2e89-94a3-4e2d-b938-b5545d681809")>

' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
62 changes: 62 additions & 0 deletions examples/Visual Basic.net/example/My Project/Resources.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading