WOLFRAM

How do I deploy APIs with Wolfram Web Engine?


You can deploy APIs with Wolfram Web Engine (WWE) either with Mathematica or by manually placing the API code into the Tomcat directory structure.

Please ensure you have already installed WWE:

Deploying an API with Mathematica

Deploying the API

  1. Add the following line to the /conf/tomcat-users.xml file in the Tomcat installation directory to define a username and password for a Tomcat deployment user.
    <user username="username_of_choice" password="strong_password_of_choice" roles="deploy"/>
  2. Open a new Mathematica notebook.
  3. Connect to your WWE server using ServiceConnect and store the returning ServiceObject in a variable:
    so = ServiceConnect["WolframWebEngine", "http://localhost:8080/webengine"]

    You will be prompted to enter the username and password for the Tomcat deployment user you defined in step 1.

  4. Use ServiceDeploy to deploy your API function, such as:
    ServiceDeploy[so, APIFunction["s" -> "String", StringReverse[#s] &], "myAPI"]

Testing the Deployed API

  1. Click the link in the ServiceDeploy output cell. This opens the API in a web browser.
  2. Append ?s=myString to the end of the URL to reverse “myString”.
    http://localhost:8080/webengine/active/myAPI?s=myString

    The API was deployed successfully if you see “gnirtSym” on the screen.

Deploying an API Manually

Deploying the API

  1. Create a subdirectory with your desired API name, such as “myAPI”, in webapps/webengine/active in the Tomcat installation directory.
  2. In that subdirectory, create a file named “index.wl”.
  3. Enter your Wolfram Language API code into the index.wl file, such as:
    APIFunction["s" -> "String", StringReverse[#s] &]
  4. Testing the Deployed API

  5. Enter your API’s URL into a web browser, such as:
    http://localhost:8080/webengine/active/myAPI?s=myString

    The API was deployed successfully if you see the reversed string “gnirtSym” on the screen.

If you receive an error, please contact server-support@wolfram.com.

Is this article helpful?
Yes
No

Any comments?

Thank you for your feedback.

Submit

Contact Support

Whether you have a question about billing, activation or something more technical, we are ready to help you.

1-800-WOLFRAM (+1-217-398-0700 for international callers)

Customer Support

Monday–Friday
8am–5pm US Central Time

  • Product registration or activation
  • Pre-sales information and ordering
  • Help with installation and first launch

Advanced Technical Support (for eligible customers)

Monday–Thursday
8am–5pm US Central Time

Friday
8:30–10am & 11am–5pm US Central Time

  • Priority technical support
  • Product assistance from Wolfram experts
  • Help with Wolfram Language programming
  • Advanced installation support