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 Parameter | Description | Required? |
---|---|---|
apiKey | Your API account key (not the accessToken) | Required |
userApiToken | Token you get when sync your application users | Required |
theme=dark | Load Studio in Dark Theme | Optional |
hideWorkspaces=true | Hide workspaces list, Only applicable in Embed Template Home Page | Optional |
externalId | External Id from 3rd party application. Shown in /api/v1/studio/workspaces API | Optional |
properties.<key> | Custom properties to be passed to the Studio. ex. properties.foo=bar | Optional |
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"
}
]
}
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
Parameter | Type | Description | Required |
---|---|---|---|
userApiToken | string | User's API token | Yes |
templateId | string | Template ID (e.g., nodejs, python, react) | Yes |
name | string | Workspace name | No |
externalId | string | External ID from your application | No |
dataset | string | Dataset to use, for database templates only | No |
properties | object | Custom properties | No |
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.