Developer Center

Resources to get you started with Algorithmia

Wolfram

Updated

The Wolfram Language is quite powerful and puts a wide variety of algorithms and curated data at your fingertips.

When you’re ready to extend this with any of the 8,000+ algorithms available from Algorithmia, or by hosting your own ML Model written in your preferred language, you can easily do so by calling your Algorithm directly from within Wolfram!

You can run this code sample by downloading the free Wolfram Engine and/or WolframScript, or by using any product you already have which supports the Wolfram Language (such as Wolfram One).

First, we specify the URL of the algorithm we want to run. You can get this from the Algorithm’s page (such as https://algorithmia.com/algorithms/nlp/SentimentAnalysis) under the “Install and Use”> cURL sample – but in most cases it is just “https://api.algorithmia.com/v1/algo/” followed by the algorithm and version you want to use.

Next, we specify the input we want to send to the Algorithm.

Lastly, we set the Authorization and Content-Type headers (your API Key is in your Account Page).

The rest is boilerplate – no need to change it. We just send the JSON-encoded HTTPRequest via URLRead:

algo = "https://api.algorithmia.com/v1/algo/nlp/SentimentAnalysis/1.0.5"
input = {"document"->"I love Algorithmia"}
headers = {"Authorization"->"Simple YOUR_API_KEY","Content-Type"->"application/json"}
req = HTTPRequest[algo, <|Method->"POST","Headers"->headers,"Body"->ExportString[input,"json"]|>]
response = URLRead[req, {"Body"}]

The response variable now contains the Algorithm response, for you to use as you wish:

{  
   "result":[  
      {  
         "document":"I love Algorithmia",
         "sentiment":0.6369
      }
   ],
   "metadata":{  
      "content_type":"json",
      "duration":0.000866891
   }
}