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:
- How do I install Wolfram Web Engine on Windows?
- How do I install Wolfram Web Engine on macOS?
- How do I install Wolfram Web Engine on Linux?
Deploying an API with Mathematica
Deploying the API
- 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"/> - Open a new Mathematica notebook.
- 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.
- Use ServiceDeploy to deploy your API function, such as:
ServiceDeploy[so, APIFunction["s" -> "String", StringReverse[#s] &], "myAPI"]
Testing the Deployed API
- Click the link in the ServiceDeploy output cell. This opens the API in a web browser.
- Append ?s=myString to the end of the URL to reverse “myString”.
http://localhost:8080/webengine/active/myAPI?s=myStringThe API was deployed successfully if you see “gnirtSym” on the screen.
Deploying an API Manually
Deploying the API
- Create a subdirectory with your desired API name, such as “myAPI”, in webapps/webengine/active in the Tomcat installation directory.
- In that subdirectory, create a file named “index.wl”.
- Enter your Wolfram Language API code into the index.wl file, such as:
APIFunction["s" -> "String", StringReverse[#s] &] - Enter your API’s URL into a web browser, such as:
http://localhost:8080/webengine/active/myAPI?s=myStringThe API was deployed successfully if you see the reversed string “gnirtSym” on the screen.
Testing the Deployed API
If you receive an error, please contact server-support@wolfram.com.
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