Giter Club home page Giter Club logo

Comments (4)

krijnsent avatar krijnsent commented on August 25, 2024

Can you share your code please? And what does the example in the example xlsm do, does that work?

from crypto_vba.

ForrestHerman avatar ForrestHerman commented on August 25, 2024

The code in the example Coinbase sheet (ShtCoinbase) works as expected.
For my testing I have created a new Worksheet called CoinTest and have configured the following on it:

  • Created a table named "Coin_Test"
  • Added a named field/reference scoped to the worksheet called "apikey_coinbase" containing my API key
  • Added a named field/reference scoped to the worksheet called "secretkey_coinbase" containing my secret key

I have also copied and modified the code from the original ShtCoinbase to the CoinTest and modified it as such

Sub GetTrans()

Dim JsonResponse As String
Dim Json As Object
'-> normally JSON is returned like {}, a dictionary in VBA,
'-> some functions return JSON is returned like [], a collection in VBA
'-> so to catch both, Dim Json as Object

Dim JsonRes As Dictionary
Dim apiKey As String
Dim secretKey As String

Set Sht = Worksheets("CoinTest")

Set Tb42 = Sht.ListObjects("Coin_Test")

'Put the credentials in a dictionary
apiKey = Sht.Range("apikey_coinbase").Value
secretKey = Sht.Range("secretkey_coinbase").Value

'Put the credentials in a dictionary
Dim Cred As New Dictionary
Cred.Add "apiKey", apiKey
Cred.Add "secretKey", secretKey

Dim Params As New Dictionary
Params.Add "CB-VERSION", "2005-05-05"
JsonResponse = PrivateCoinbase("accounts", "GET", Cred)
strToFile JsonResponse, "TestResponse", "json"

End Sub

The function strToFile is just something simple I wrote that allows me to "dump" the JsonResponse to a file so I can see the output in Notepad++.

Running the above code as written results in the expected output with all of the account/wallet information in the JSON response as it does on the example ShtCoinbase.

Modifying the second to last line line in the following ways (based on the Coinbase API example) results in the following responses (Note: xxxxx-xx..... is a single hard coded asset/wallet id obtained from the output of the working accounts code)

  • JsonResponse = PrivateCoinbase("accounts//xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx//transactions", "GET", Cred)
    • 401: HTTP-Unauthorized
  • JsonResponse = PrivateCoinbase("accounts/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/transactions", "GET", Cred)
    • 404: HTTP-Not Found

(The above aren't the only two things I have tried, but most have been some variation of the above)

from crypto_vba.

krijnsent avatar krijnsent commented on August 25, 2024

Hi there,
got around to testing it. This works for me:

Dim Params As New Dictionary
Params.Add "CB-VERSION", "2005-05-05"
JsonResponse = PrivateCoinbase("accounts/xxxxxxxxxxxxxxxxxxxxxxxxxxx/transactions", "GET", Cred, Params)

Note: you see that your credentials get added with the Cred parameter. The header CB-VERSION is passed as a Parameter.
Hope that helps. If so, please close the issue.

from crypto_vba.

krijnsent avatar krijnsent commented on August 25, 2024

No response, am closing the issue. Feel free to create a new issue if things don't work.

from crypto_vba.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.