Get started with the Project Model API
Note: The Model API is available as a custom early access add-on for enterprise customers. We expect active iteration with the customers who use this to refine the feature.
The Model API provides access to a JSON representation of Plasmic projects. This is the tree of elements that make up any Plasmic page or component, and then from there control the rendering yourself.
Get started with the Model API
curl \ --header 'x-plasmic-api-project-tokens: PROJECTID:APITOKEN' \ 'https://codegen.plasmic.app/api/v1/loader/repr-v2/preview/PROJECTID/COMPONENTNAME'
JSON representation examples
Components, props, and nested components inside a children
slot—note that these may be instances of either code components or Plasmic components:
{ "type": "component", "name": "List", "props": { "name": "Shopping list", "upvotes": 42, "children": [ { "type": "component", "name": "ListItem", "props": { "name": "Milk" } }, { "type": "component", "name": "ListItem", "props": { "name": "Cookies" } } ] }}
Rich text, including both span-level and block-level elements denoted within markers
(node markers replace the [child]
substring):
{ "type": "text", "value": "Hello world!\n[child]\nThis is the body text.", "markers": [ { "type": "style", "position": 0, "length": 5, "style": { "font-weight": "bold" } }, { "type": "node", "position": 13, "length": 7, "value": { "type": "text", "value": "This is a heading", "tag": "h1" } } ]}
Arbitrary box containers (aka stacks) are always returned as box
type, ignoring their layout styles:
{ "type": "box", "children": [ { "type": "component", "name": "HeroSection" }, { "type": "component", "name": "PricingSection" } ]}
Use cases and limitations
This is intended to serve use cases where Plasmic is being used primarily as a visual CMS, rather than a free-form page builder. This means it assumes you have implemented your own components for taking care of rendering.
It does not support the following:
- Styling and layout.
- Variants.
- Dynamic values.
- Visibility settings.
What is supported:
- Component instances, including both code components and Plasmic components
- Box containers (stacks)
- Rich text
More fields may be introduced into the JSON schema in the future, so please ensure your code tolerates additional keys that are not currently part of the returned object structures.