Introducing the Embed API

    Turn any Carlo simulation into an interactive widget. Pass parameters via URL, auto-run on load, and build dynamic experiences powered by Monte Carlo.

    ProductAPIEmbedding
    Carlo
    ·
    Introducing the Embed API

    Embedding a Monte Carlo simulation is nice. Embedding one that responds to user input? That's powerful.

    Today we're launching the Embed API, a feature that turns any Carlo simulation into an interactive widget you can control from your website.

    The problem with static embeds

    Traditional embeds are one-way. You copy an iframe code, paste it into your site, and it shows whatever the simulation author configured. If you want to show different scenarios, you need different simulations.

    That's limiting. Financial advisors want to pre-populate with client data. Educators want students to experiment with different inputs. Product teams want to connect simulations to their existing UI.

    The Embed API solves this by letting you pass parameters directly through the URL.

    How it works

    When you enable parameter overrides in the Share dialog, Carlo exposes every adjustable value in your simulation as a URL parameter. Change the URL, change the simulation.

    For Constant blocks, use the variable name directly:

    /embed/template/fire-advanced?interest_rate=0.07

    For Variable blocks (which have distributions), append the distribution parameter with an underscore:

    /embed/template/fire-advanced?returns_mean=0.09&returns_std=0.18

    Auto-run on load

    By default, embeds show the model diagram and wait for users to click "Run". Sometimes that's what you want— it lets viewers explore the model structure first.

    But for interactive widgets, you usually want results immediately. Add autorun=1 to run the simulation as soon as the embed loads:

    /embed/template/fire-advanced?autorun=1&interest_rate=0.07

    Live demo

    Here's a working example. The sliders below are just HTML inputs on this page. When you move them, we update the iframe URL with the new parameter values. The simulation reloads with your inputs and runs automatically.

    Move the sliders above to see the simulation update with your parameters

    No special integration required. Just string concatenation.

    Building your own interactive widget

    The implementation is straightforward:

    embed.js
    javascript
    1const> iframe = document.getElementById(>class>="text-[#ce9178]">'simulation'>);
    2const> returnSlider = document.getElementById(>class>="text-[#ce9178]">'return>-slider'>);
    3
    4returnSlider.addEventListener(>class>="text-[#ce9178]">'input'>, (e) => {
    5 const> returnValue = e.target.value / 100>;
    6 iframe.src = class>="text-[#ce9178]">`/embed/template/your-sim?autorun=1>&return_mean=${returnValue}`>;
    7});

    Use cases

    We're excited to see what people build with this. Some ideas:

    • Financial calculators - Pre-populate with user's actual portfolio data and let them explore scenarios
    • Interactive articles - Let readers adjust assumptions and see how conclusions change
    • Educational tools - Students can experiment with distribution parameters and see the effects
    • Client presentations - Advisors can walk through personalized projections in real-time
    • Product features - Embed Monte Carlo analysis into your own application

    Getting started

    Open any simulation you own, click Share, switch to the Embed tab, and toggle on the options you need. The embed code will update to include the URL parameters.

    Check out the documentation for the full parameter reference and more examples.

    Simulations shouldn't be static images. They should be tools that respond to questions.

    Try it: FIRE Advanced with Parameter Overrides

    We can't wait to see the interactive experiences you create.

    Try the Embed API

    Create your own simulation and embed it with parameter overrides. Build interactive calculators and dynamic experiences powered by Monte Carlo.

    • Drag-and-drop probability distributions
    • Run thousands of scenarios instantly
    • Export and share results

    More Articles