Group Abstract Group Abstract

Message Boards Message Boards

0
|
6.9K Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Request calculation result from my server

Posted 6 years ago

Just a basic question (I'm very new to WolframAlpha, so I beg your pardon if this sounds too basic).

I'd like to use the free WolframAlpha cloud (or any other free WA product) to request the result of calculation and return it to my server in JSON format. Of course, the request would contain dynamic parameters: the idea is to have a sort of REST endpoint (even public) that can accept parameters and return results in JSON format. The calculation would not be intensive and the data would be requested a couple of times every day.

Is this possible?

POSTED BY: Mauro D.B.
4 Replies

It's very possible (and no worries, basic questions are absolutely welcome).

What you probably want is an APIFunction deployed to the Wolfram Cloud. You can sign up for a (free) account on https://www.wolframcloud.com/, create a new notebook, and evaluate the following (copy & paste the code and press Shift+Enter):

CloudDeploy[
 APIFunction[{"x" -> "Integer"}, #x + 1 &, "JSON"], "myapi", 
 Permissions -> "Public"]

This will create a cloud object (basically a file in the Wolfram Cloud) called "myapi" inside your personal cloud root directory. It's an API that takes an integer parameter x, increments it by 1 and returns the result as JSON (which is just a number in this case). It's public, so anyone who knows the URL can execute it. Example:

https://www.wolframcloud.com/obj/jpoeschko/myapi?x=5

You can read more about APIFunction, CloudDeploy, etc. in the Wolfram Language documentation. There are lots of examples and also guides such as how to Deploy a Web API.

APIFunctions consume Cloud Credits depending on the time they need to execute. With a free Basic subscription, you get a limited number of Cloud Credits each month, which might be enough for your purposes. If you need more, you can upgrade to one of the paid plans.

A note about names (which, admittedly, can be confusing): There's Wolfram (the company) and we make both Wolfram|Alpha (the web application where you can enter natural-language queries for computation) and the Wolfram Cloud (a platform where you can work with notebooks similarly to Mathematica, just on the web, and that allows you to deploy web applications and APIs based on the Wolfram Language). I assume your question is about Wolfram Cloud, not Wolfram|Alpha.

Hope this helps.

POSTED BY: Jan Poeschko
Posted 6 years ago

Thank you very much! My calculation is a little bit more complicated but I suppose this is not an issue.

POSTED BY: Mauro D.B.

Yes, that should not be an issue, as long as the computation finishes within the API evaluation time limit (which is 60 seconds for the free plan).

POSTED BY: Jan Poeschko
Posted 6 years ago

60 seconds is really too much, even my server would time out :-) Thanks!

POSTED BY: Mauro D.B.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard