EmbedCode

Todd Gayley

Wolfram Research

Introduction

Introduction

How can I deploy my Wolfram Language functionality to so that it can be called by me, my colleagues, and my customers, from anywhere and from any programming language?

Introduction

How can I deploy my Wolfram Language functionality to so that it can be called by me, my colleagues, and my customers, from anywhere and from any programming language?

APIFunction

Defining a callable function

CloudDeploy

Deploying the function to the cloud

EmbedCode

A convenience function that generates code in many languages for calling your cloud function

APIFunction: Cloud-Callable Packaging of Wolfram Language Functionality

func=APIFunction[{"x"->"Integer"}, #x^2&]

func[<|"x"->"123"|>]

$InterpreterTypes

Deploying an APIFunction with CloudDeploy

Let’s make things a little tricker by defining a function g with a dependency on another function:

f[x_] := x^2

g[x_] := f[x]+3

func=APIFunction[{"x"->"Number"}, g[#x]&]

deployed=CloudDeploy[func, Permissions->"Public"]

EmbedCode: Generating a Call to a CloudObject in a Desired Language

EmbedCode[deployed, "Python"]

$EmbedCodeEnvironments

FormFunction and HTML Embedding

A function that computes the number of days between now and a date in the past, deployed in a form.

EmbedCode[
	FormFunction[{{"d", "Enter your birthday"}->"Date"},
		ToString[DateDifference[#d, Now], OutputForm]&, "Text"],
	"HTML",
	ImageSize->{600,300}
]

Sample Java Application

Deploy a function that applies an image effect to an uploaded image.

EmbedCode[
	APIFunction[{"im"->"Image", "effect"->"String"},
				ImageEffect[#im, #effect]&, "PNG"],
	"Java",
	ExternalTypeSignature->{Automatic, "java.awt.Image"}
]

Google Docs

EmbedCode[
	APIFunction[{"n"->"Integer"}, Fibonacci[#n]&],
	"GoogleDocs",
	ExternalTypeSignature->{Automatic, "Integer"},
	ExternalFunctionName->"fib"
]