Android Question Fetching Currency Exchange Rates with APILayer

Azhar

Active Member
Licensed User
Longtime User
Hello,

I was following an older thread (updated) on how to fetch currency exchange rates via apiLayer. I have registered and have been provided with an API Key.
Following Don Manfred's example with the update (to include the API Key) I get an error from the API Service "You cannot consume this service".

API Call:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("frmSetup")
    DownloadRates("https://api.apilayer.com/fixer/latest?apikey=I5prDI8J--------------8Q2i32")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub DownloadRates(Link As String)
    Dim job As HttpJob
    job.Initialize("", Me)
    job.Download(Link)
    Wait For (job) JobDone(job As HttpJob)
    If job.Success Then
        Log(job.GetString)
        ToastMessageShow(job.GetString,True)
        Dim parser As JSONParser
        parser.Initialize(job.GetString)
        Dim root As Map = parser.NextObject
        Dim date As String = root.Get("date")
        Dim rates As Map = root.Get("rates")
        Dim SGD As Double = rates.Get("SGD") 
        Dim MYR As Double = rates.Get("MYR")
        Dim GBP As Double = rates.Get("GBP")   
        Dim AUD As String =root.Get("base")   
        Log($"The ${AUD} is worth ${SGD}  Singapore Dollar on ${date}"$)   
      
    Else
        Log("Error: " & job.ErrorMessage)
        ToastMessageShow("Error: " & job.ErrorMessage, True)
    End If
    job.Release
End Sub

Can anyone tell me how to structure the Link String correctly?

Thanks

Azhar
 

mangojack

Expert
Licensed User
Longtime User
I finally gave up on using APILayer . I was using the free service but they started changing the Key on a monthly basis.
Even when issued with a new key , I would still get similar error messages.
Support was non existent, I seem to recall opening a ticket and getting a response 3 months later.

I Have copies of all previous links I have used over the years , and yours above is good and should work ... (with the key being correct and current)


I have been using AnyAPI for a year now (personal use only) and so far so good

"https://anyapi.io/api/v1/exchange/rates?base=AUD&apiKey=62ABC123"
 
Upvote 0
Top