Wolfram Alpha

By Kiddo96 on Jun 23, 2012

A request from Ric James in the forums. I thought I'd share this snippet.

It requires to register an account at https://developer.wolframalpha.com/portal/apisignup.html. Once you're done and you've gotten your APP ID, replace it where it says "APP ID HERE" in line 16 of this snippet. You can make 2000 requests every month. That's approximately 66 each day, so it should be enough. Now you're good to go! :-)

The command is /wolfram -query- if you want to use it as an alias. Otherwise it's !wa, which works both in a channel or PM.


!wa integral from 1 to 3 x^2 | integral_1^3 x^2 dx = 26/3 | !wa november 18 1996 | Monday, November 18, 1996 | Row[^18/_11-1996] (day/month - year) | 15 years 7 months 5 days ago | 813 weeks 5 days ago | 5696 days ago | 15.59 years ago | 323rd day | 47th week | (no official holidays or major observances) | A train catches fire in the Channel Tunnel | first quarter moon | !wa sum x=1 to infinity 9/10^x | sum_(x=1)^infinity 9/10^x = 1 | By the decreasing geometric series test, the series converges. | sum_(x=1)^n 9/10^x = 10^(-n) (10^n-1) | !wa cupcakes | cupcakes (English word) | noun | small cake baked in a muffin tin | k'uhpk,eyks (IPA: kˈʌpkˌeɪks) | cupcake | cake | (none among common words) |

Please come with suggestions and bug reports if you find any.

;Wolfram Alpha!
;Using Wolfram Alpha API to get result.
;Command !wa -query- or /wolfram -query-
on $*:text:/^!wa /Si:#,?:{
  wolfram $2-
alias wolfram {
  if $sock(wolfram) || $sock($+(wolfram,$nick)) {
    sockclose $v1
  sockopen $iif($event == text,$+(wolfram,$nick),wolfram) api.wolframalpha.com 80
  sockmark $iif($event == text,$+(wolfram,$nick) $iif(#,msg #,msg $nick),wolfram echo -a) $1-
on *:sockopen:wolfram*:{
  tokenize 32 $sock($sockname).mark
  sockwrite -nt $sockname GET $+(/v2/query?input=,$urlencode($3-),&format=plaintext&appid=APP ID HERE) HTTP/1.1
  sockwrite -nt $sockname Host: api.wolframalpha.com
  sockwrite -nt $sockname Connection: close
  sockwrite -nt $sockname $crlf
on *:sockread:wolfram*:{
  tokenize 32 $sock($sockname).mark
  var %wreader
  sockread %wreader
  if $regex($+(wolfram,$2),%wreader,/<plaintext>(.+?)<\/plaintext>/) {
    set $+(%,wresult,$2) $($+(%,wresult,$2),2) $regml($+(wolfram,$2),1) 04 $+ $chr(124) $+ 
on *:sockclose:wolfram*:{
  tokenize 32 $sock($sockname).mark
  $1-2 $iif($($+(%,wresult,$2),2),04 $+ $chr(124) $+  $utf16($($+(%,wresult,$2),2)),No result was found.)
  unset $+(%,wresult,$2)
alias urlencode return $regsubex($1,/(\W)/g,% $+ $base($asc(\1),10,16,2)))
alias UTF16 return $regsubex($1-,/\Q\:\E([a-f\d]{4})/ig,$chr($base(\1,16,10)))


Sign in to comment.
illhawkthat   -  Jan 13, 2013

I made a wolfram alpha script a while ago that I just posted. http://www.hawkee.com/snippet/9797/

uneek   -  Dec 07, 2012

Working now. Guess it just took a bit for my API to go through.

Thanks for the script,.

uneek   -  Dec 06, 2012

I just get "No result was found." I'm guessing the code on the site changed?

amclay   -  Jul 19, 2012

Oh, some of the results are too large to fit into one message, so it splits it into two, and sends both simultaniously. I'm having problems with a IRC server booting me for spam, so it would be nice to fit long messages into one single message, with a link at the end to expand it if need be.

Example for the link:

: !wa 2+2 | 2+2 | 4 | four | * * * * | http://www.wolframalpha.com/input/?i=2%2B2
Kiddo96   -  Jul 11, 2012

I'm not following on what you mean. Please explain a little more.

amclay   -  Jul 10, 2012

Would be nice to have a 1 message option, or to shortcut it to end in a link to the wolfram alpha page

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.