Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:03 06 Jun 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Wolfram Alpha on Webmite

Author Message
terekgabor
Regular Member

Joined: 02/01/2026
Location: Hungary
Posts: 90
Posted: 03:58pm 05 Jun 2026
Copy link to clipboard 
Print this post

Hi Everybody!

I just want to try this API with Webmite:
https://api.wolframalpha.com/v1/result?appid=myappidhere&i=How+far+is+Los+Angeles+from+New+York%3f

It is a sample query, I have my appid.
Can anybody help how to start it? Is it possible with Webmite TLS connection?

I tried to build up something, but I got error.

Thanks a lot!

G@bor
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11435
Posted: 04:05pm 05 Jun 2026
Copy link to clipboard 
Print this post

Update the firmware to this:
WebMiteRP2350V6.03.00RC16.zip
Join the lines making up the request

Dim buff%(4096/8)
Dim CRLF$ = Chr$(13) + Chr$(10)
Dim b$ = "GET /v1/result?appid=myappid&i=How+far+is+Los+Angeles+from+New+York%3f HTTP/1.1"
Inc b$,CRLF$+ "Host: api.wolframalpha.com" + CRLF$+ "User-Agent: WebMite" + CRLF$
Inc b$, "Accept: text/plain" + CRLF$+ "Connection: close" + CRLF$ + CRLF$
Print b$
WEB OPEN TLS CLIENT "api.wolframalpha.com", 443
WEB TCP CLIENT REQUEST b$, buff%(), 20000
Pause 1000
LongString print buff%()
WEB CLOSE TCP CLIENT

Edited 2026-06-06 02:27 by matherp
 
terekgabor
Regular Member

Joined: 02/01/2026
Location: Hungary
Posts: 90
Posted: 04:09pm 05 Jun 2026
Copy link to clipboard 
Print this post

Peter!

Thanks. I exactly did this, I got this error during open the client;
Error: TLS client error -15

G@bor
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11435
Posted: 04:28pm 05 Jun 2026
Copy link to clipboard 
Print this post

Try again with firmware just posted

  Quote  onnecting to 140.177.18.10 port 443 (TLS)
Connected
HTTP/1.1 200 OK
Date: Fri, 05 Jun 2026 16:28:16 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 10
Connection: close
Vary: Origin
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *,Authorization
ETag: W/"a-ghAswtrRURXKiu3jHGFev/jboWQ"

2464 miles
 
terekgabor
Regular Member

Joined: 02/01/2026
Location: Hungary
Posts: 90
Posted: 04:29pm 05 Jun 2026
Copy link to clipboard 
Print this post

With RC16?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11435
Posted: 04:39pm 05 Jun 2026
Copy link to clipboard 
Print this post

Above in this thread - my first post
 
terekgabor
Regular Member

Joined: 02/01/2026
Location: Hungary
Posts: 90
Posted: 04:40pm 05 Jun 2026
Copy link to clipboard 
Print this post

Yes, clear. I updated. Just trying
G@bor
 
terekgabor
Regular Member

Joined: 02/01/2026
Location: Hungary
Posts: 90
Posted: 04:43pm 05 Jun 2026
Copy link to clipboard 
Print this post

Peter!

Many thanks it is working!  
What caused this error?

G@bor
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11435
Posted: 04:46pm 05 Jun 2026
Copy link to clipboard 
Print this post

RSA hadn't been enabled as an encryption method
 
terekgabor
Regular Member

Joined: 02/01/2026
Location: Hungary
Posts: 90
Posted: 04:48pm 05 Jun 2026
Copy link to clipboard 
Print this post

Very good! So it will upgrade in the following versions?

G@bor
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11435
Posted: 04:49pm 05 Jun 2026
Copy link to clipboard 
Print this post

Yes
Try this
' Wolfram Alpha "short answer" client for WebMite.
' Prompts for an English-language question, sends it to the v1/result
' endpoint over TLS, prints whatever the server returns as the answer body.
'
' Requires:
'   - WebMite firmware with TLS enabled (RP2350)
'   - WiFi already configured and connected
'   - Your own Wolfram AppID  replace APPID$ below
option web messages off
Const APPID$ = "myid"
Const HOST$  = "api.wolframalpha.com"
Const CRLF$  = Chr$(13) + Chr$(10)

Dim buff%(8192/8)
Dim question$

Print "Wolfram Alpha client  blank line to quit"
Print

Do
 Line Input "Ask: ", question$
 If question$ = "" Then Exit Do
 Print Ask$(question$)
 Print
Loop

End

' --------------------------------------------------------------------------
' Ask$    send one question, return the answer body (or an error string)
' --------------------------------------------------------------------------
Function Ask$(q$)
 Local req$, Integer hdr_end

 req$ = "GET /v1/result?appid=" + APPID$ + "&i=" + UrlEncode$(q$) + " HTTP/1.1" + CRLF$
 Cat req$, "Host: " + HOST$ + CRLF$
 Cat req$, "User-Agent: WebMite" + CRLF$
 Cat req$, "Accept: text/plain" + CRLF$
 Cat req$, "Connection: close" + CRLF$ + CRLF$

 LongString clear buff%()

 On Error Skip 1
 WEB OPEN TLS CLIENT HOST$, 443, 15000
 If MM.Errno <> 0 Then
   Ask$ = "[connection failed: " + MM.ErrMsg$ + "]"
   Exit Function
 EndIf

 WEB TCP CLIENT REQUEST req$, buff%(), 15000
 Pause 1000
 WEB CLOSE TCP CLIENT
 ' Split headers from body at the blank line (CRLF CRLF).
 hdr_end = LInStr(buff%(), CRLF$ + CRLF$)
 If hdr_end = 0 Then
   Ask$ = "[malformed response]"
   Exit Function
 EndIf

 Ask$ = LGetStr$(buff%(), hdr_end + 4, LLen(buff%()) - hdr_end - 3)
End Function

' --------------------------------------------------------------------------
' UrlEncode$    percent-encode a string for use in a URL query value
' --------------------------------------------------------------------------
Function UrlEncode$(s$)
 Local Integer i, c
 Local out$
 For i = 1 To Len(s$)
   c = Asc(Mid$(s$, i, 1))
   Select Case c
     Case 48 To 57, 65 To 90, 97 To 122      ' 0-9  A-Z  a-z
       Cat out$, Chr$(c)
     Case 45, 46, 95, 126                    ' - . _ ~
       Cat out$, Chr$(c)
     Case 32                                 ' space -> '+'
       Cat out$, "+"
     Case Else                               ' everything else -> %XX
       Cat out$, "%" + RIGHT$("0" + HEX$(c), 2)
   End Select
 Next i
 UrlEncode$=out$
End Function

Edited 2026-06-06 02:53 by matherp
 
terekgabor
Regular Member

Joined: 02/01/2026
Location: Hungary
Posts: 90
Posted: 05:05pm 05 Jun 2026
Copy link to clipboard 
Print this post

Peter!

That is I planned to integrate! Very cool.

Thanks again for support!
I like this programming language very much, and what you are doing is brilliant.

G@bor
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026