Embed Studio Home Page

Studio can be embedded via iFrame just like code editor.

<iframe 
  frameBorder="0" 
  height="700px" 
  width="100%"
  src="https://onecompiler.com/embed/studio"
></iframe>

Embed Template Home Page

To embed a template launch page use the below URL.
Note: use the template id in the URL like python in the below example.

<iframe
  frameBorder="0"
  height="700px"
  width="100%"
  src="https://onecompiler.com/embed/studio/python"
></iframe>

Embed Workspace Page

To embed a workspace page use the below URL.

<iframe
  frameBorder="0"
  height="700px"
  width="100%"
  src="https://onecompiler.com/embed/studio/python/42964snje"
></iframe>

More options via query parameters

Query ParameterDescriptionRequired?
apiKeyYour API account key (not the accessToken)Required
userApiTokenToken you get when sync your application usersRequired
theme=darkLoad Studio in Dark ThemeOptional
hideWorkspaces=trueHide workspaces list, Only applicable in Embed Template Home PageOptional
externalIdExternal Id from 3rd party application. Shown in /api/v1/studio/workspaces APIOptional
properties.<key>Custom properties to be passed to the Studio. ex. properties.foo=barOptional

Please check the Enterprise APIs section for more advanced options like syncing user data and obtaining userApiToken.

Manage Studio workspaces programmatically

Read workspaces

You can read a user's workspaces data using the below API.

curl --location 'https://onecompiler.com/api/v1/studio/workspaces' \
--header 'Content-Type: application/json' \
--data '{
    "userApiToken": "user_api_token"
}'

Sample Response

{
  "status": "success",
  "workspaces": [
      {
          "_id": "42964snje",
          "externalId": "74528374",
          "properties" : {
            "foo": "bar",
            "baz": "qux"
          },
          "created": "2024-03-20T02:56:05.838Z",
          "template": {
              "_id": "python"
          },
          "status": "stopped",
          "usageTotal": 24,
          "backup" : "https://studio.datashortener.com/workspaces/abc/xyz.zip",
          "url": "https://onecompiler.com/studio/python/42964snje"
      },
      {
          "_id": "42964t2ex",
          "externalId": null,
          "created": "2024-04-01T02:56:10.840Z",
          "template": {
              "_id": "react"
          },
          "status": "stopped",
          "usageTotal": 0,
          "backup" : "https://studio.datashortener.com/workspaces/abc/xyz.zip",
          "url": "https://onecompiler.com/studio/react/42964t2ex"
      }
  ]
}

Get workspace by ID

Retrieve details of a specific workspace by its ID.

curl --location 'https://onecompiler.com/api/v1/studio/workspaces/42964snje' \
--header 'Content-Type: application/json' \
--data '{
    "userApiToken": "user_api_token"
}'

Sample Response

{
  "status": "success",
  "workspace": {
    "_id": "42964snje",
    "externalId": "74528374",
    "properties": {
      "foo": "bar",
      "baz": "qux"
    },
    "created": "2024-03-20T02:56:05.838Z",
    "template": {
      "_id": "python"
    },
    "status": "stopped",
    "lastSeen": "2024-03-21T10:15:30.000Z",
    "usageTotal": 24,
    "backup": "https://studio.datashortener.com/workspaces/abc/xyz.zip",
    "url": "https://onecompiler.com/studio/python/42964snje",
    "name": "My Python Project"
  }
}

Create workspace

Create a new Studio workspace programmatically.

curl --location 'https://onecompiler.com/api/v1/studio/workspaces/create' \
--header 'Content-Type: application/json' \
--data '{
    "userApiToken": "user_api_token",
    "templateId": "nodejs",
    "name": "My Project",
    "externalId": "proj-123",
    "properties": {
        "foo": "bar"
    }
}'

Parameters

ParameterTypeDescriptionRequired
userApiTokenstringUser's API tokenYes
templateIdstringTemplate ID (e.g., nodejs, python, react)Yes
namestringWorkspace nameNo
externalIdstringExternal ID from your applicationNo
datasetstringDataset to use, for database templates onlyNo
propertiesobjectCustom propertiesNo

Sample Response

{
  "status": "success",
  "workspace": {
    "_id": "42964xyz1",
    "externalId": "proj-123",
    "properties": {
      "foo": "bar"
    },
    "created": "2024-04-15T10:30:00.000Z",
    "template": {
      "_id": "nodejs"
    },
    "status": "running",
    "name": "My Project"
  }
}

Stop workspace

Stop a running workspace. This will save the workspace state and create a backup.

curl --location 'https://onecompiler.com/api/v1/studio/workspaces/stop' \
--header 'Content-Type: application/json' \
--data '{
    "userApiToken": "user_api_token",
    "workspaceId": "42964snje"
}'

Sample Response

{
  "status": "success",
  "message": "Workspace stopped successfully"
}

Delete workspace

Permanently delete a workspace. This action cannot be undone.

curl --location 'https://onecompiler.com/api/v1/studio/workspaces/delete' \
--header 'Content-Type: application/json' \
--data '{
    "userApiToken": "user_api_token",
    "workspaceId": "42964snje"
}'

Sample Response

{
  "status": "success",
  "message": "Workspace deleted successfully"
}

Note: The difference between stop and delete:

  • Stop: Pauses the workspace and creates a backup. The workspace can be resumed later. This is optional, if the workspace is inactive (user closes the browser tab), it will be automatically stopped.
  • Delete: Permanently removes the workspace without creating a backup.

Deploy workspace

Deploy a workspace to make it accessible via a public URL.

curl --location 'https://onecompiler.com/api/v1/studio/workspaces/deploy' \
--header 'Content-Type: application/json' \
--data '{
    "userApiToken": "user_api_token",
    "workspaceId": "42964snje",
    "appId": "my-app-123"
}'

Parameters

ParameterTypeDescriptionRequired
userApiTokenstringUser's API tokenYes
workspaceIdstringWorkspace ID to deployYes
appIdstringDeployment subdomain identifier (letters, numbers, hyphens only, min 6 chars)Yes

Sample Response

{
  "status": "success",
  "deployment": {
    "_id": "dep-xyz123",
    "workspaceId": "42964snje",
    "appId": "my-app-123",
    "url": "https://my-app-123.onecompiler.app",
    "status": "queued",
    "created": "2024-04-15T12:00:00.000Z"
  }
}

Note: The deployment process is asynchronous. The initial response will have status queued. The workspace will be backed up, deployed, and the status will change to completed or failed. You can poll the workspace details API to check the deployment status.