Skip to content

API

The extension provides an API which you can use to control the extension.

You can enable the API by setting the demoTime.api.enabled setting to true.

Once the API is enabled, it will run on the port defined in the demoTime.api.port setting.

API URL: http://localhost:3710/api/next

Once enabled, it shows the API and its port number in the status bar of Visual Studio Code.

API enabled with port 3710

API endpoints

/api/next

This endpoint will execute the next step in the demo.

  • Method: GET
  • Query parameters:
    • bringToFront: Bring the Visual Studio Code window to the front. Default is false.

/api/runById

This endpoint will execute a specific step by its ID in your demo.

You can call this endpoint via a GET or POST request.

GET request

  • Method: GET
  • Query parameters:
    • id: The ID of the step you want to
    • bringToFront: Bring the Visual Studio Code window to the front. Default is false.

POST request

  • Method: POST

  • Body:

    API Body
    {
    "id": "<step id>",
    "bringToFront": "<bring the Visual Studio Code window to the front (optional) - default is false>"
    }
  • Headers:

    • Content-Type: application/json

/api/demos

Returns all act files, the next demo, and the currently executing act file.

  • Method: GET

Response

Demos API Response
{
"demoFiles": [
{
"filePath": "/absolute/path/to/demo.json",
"demos": [
{ "id": "demo1", "title": "Demo 1" },
{ "id": "demo2", "title": "Demo 2" }
]
}
],
"nextDemo": { "id": "demo2", "title": "Demo 2" },
"currentDemoFile": {
"filePath": "/absolute/path/to/demo.json",
"demo": [
{ "id": "demo1", "title": "Demo 1" }
]
}
}

Description

  • demoFiles: Array of act files, each with its file path and contained demos (id and title).
  • nextDemo: The next demo to be executed (id and title), if available.
  • currentDemoFile: The currently executing act file, with its file path and demos.
  • slides.notes: The speaker notes of the current slide, if it has any.

/api/previous

This endpoint will execute the previous step in the demo.

  • Method: GET
  • Query parameters:
    • bringToFront: Bring the Visual Studio Code window to the front. Default is false.

/api/notes

Returns the notes as markdown text.

  • Method: GET or POST

  • Body (POST, optional):

    API Body
    {
    "path": "<relative path to a notes file>"
    }
  • Headers:

    • Content-Type: application/json

Description

  • Without a path, it returns the notes of the current slide (its <!-- notes --> block). When the slide has no notes, it returns the notes file of the current scene.
  • With a path, it returns the content of that notes file in the workspace.
  • Returns 404 when there are no notes.

/api/screenshot

Returns a screenshot of the next slide as a base64-encoded image.

  • Method: GET

Response

Screenshot API Response
{
"screenshot": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
}

Description

  • screenshot: Base64-encoded PNG image data of the next slide or step. Perfect for remote control PWA previews.

/api/zoom-in

Increases the editor font size.

  • Method: GET

/api/zoom-out

Decreases the editor font size.

  • Method: GET