Share My Creation Crypto Exchange API Browser

This is a simple and very basic app that demonstrates how to hit a crypto exchange public API. This could apply to any open API.

The app lets you compose an API call and see what the exchange returns. You can use a list of available calls or provide your own.

It is easy to add more exchanges and API calls into the source, but it could be made more efficient by parsing a preferences file (CSV or JSON, etc.).

2023.01.01 - v1.7 - No longer crashes if web API input is invalid (e.g., FTX, the exchange, is defunct and its API no longer available)
2021.11.18 - v1.6 - Valid JSON array no longer considered invalid
2021.11.18 - v1.5 -Enhanced Parameters field again; if first character is "/" it will interpret that as a manually-entered Request URL
2021.11.18 - v1.4 -Enhanced functionality for the Parameters field; allows parameters like "bittrex/assets" or "symbols=ETHBTC" or "some/other/api?symbol=SYM"
2021.11.17 - v1.3 - Additional calls for Binance; again, this should probably be done in a preferences file so people can add their own stuff; added a parameters box
2021.11.16 - v1.2 - Results in JSON format now shown in pretty JSON format; truncates very large strings of text from the request result;
2021.11.16 - v1.1 - Fixes bug with CLV management; got rid of drop-downs, the worst UI element ever invented by mankind, change my mind
 

Attachments

  • Exchange-API-Browser-1.7.zip
    15.6 KB · Views: 194
Last edited:

cklester

Well-Known Member
Licensed User
I've uploaded a new version. It is a slight UI change to make it easier/nicer to use. Drop-down controls are of the devil.

There is a bug I can't figure out. Here's how to find it:

1. Select Coinbase Pro in Available Exchanges.
2. Select "time" in Public Request
3. Click "Send"
4. Now select "FTX" in Available Exchanges

At that point, it crashes for me, but I'm not sure why. Can anybody hunt that down?

I'm going to add more exchanges and more requests as time goes on. Eventually, I'd like to include private requests along with the public ones! That way, you could see, for example, your orders or wallet balances.

(I'm leaving the old one for now for educational purposes/historical records.)
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
The problem is that your SelectedItems list refers to the list of items before it was changed.

if you change the code like this you can see the problem (and it stops it crashing)


B4X:
Public Sub Clear
    If SelectedItems.Size = 0 Then Return
    For Each i As Int In SelectedItems.AsList
        If (i < mCLV.Size) Then
        mCLV.GetPanel(i).Color = UnselectedColor
        Else
            Log($"i is ${i} mclv.size is ${mCLV.size}"$)
        End If
    Next
    SelectedItems.Clear
End Sub

There is no need to call clear on the Public Requests clv as you change the selection in Available exchanges as the clv is fully reset.
 

cklester

Well-Known Member
Licensed User
Version 1.2 prettifies JSON results.

For long results strings, it is very slow. I'm truncating long results for now.

Is there a better way to show the entire string in a more performant manner?
 

ilan

Expert
Licensed User
Longtime User
looks really nice, can you explain how do i get the price for MATIC-USDT? using Binance?
 

cklester

Well-Known Member
Licensed User
@ilan , I've updated the functionality to make your request easier to send. See version 1.3, and usage below:

1637184350766.png
 

Attachments

  • 1637184079640.png
    1637184079640.png
    73.8 KB · Views: 216

cklester

Well-Known Member
Licensed User
Big enhancement to the Parameters text field. Allows for this now:

1637273642648.png


and still this:


1637273678252.png


Still some usability enhancements to be made... but it's coming along as a nice demo.
 

cklester

Well-Known Member
Licensed User
If you start the Parameters text field with a forward slash, it will ignore the "Public Requests" item. See example below, obtaining the 10 best bids and asks for XLMBTC at the Bittrex exchange. Notice that the "orderbooks" public request is not in the Public Requests list, but we can call it manually with the forward slash.

1637277928704.png
 
Top