Skip to main content

Myop Cloud APIs

Overview

Myop Cloud provides APIs to retrieve the latest component configurations for your applications in real time. These configurations are essential for rendering and managing components dynamically.

Consume API

The Consume API is the primary way to fetch component configurations for rendering in your application.

API Endpoint

GET https://cloud.myop.dev/consume?id={COMPONENT_ID}

Parameters

ParameterTypeRequiredDescription
idstringYesThe unique identifier for your component. You can find this in the Myop Dashboard when viewing the component.
envstringNoThe environment to load from (e.g., prod, staging). If not specified, defaults to preview mode.
previewbooleanNoSet to true to load the unpublished preview version. Defaults to true when env is not specified.

Examples

Load published component from production:

GET https://cloud.myop.dev/consume?id=abc123&env=prod

Load published component from staging:

GET https://cloud.myop.dev/consume?id=abc123&env=staging

Load preview (unpublished) version:

GET https://cloud.myop.dev/consume?id=abc123&preview=true

Response

The API returns a JSON object containing the component configuration:

{
"item": {
"id": "abc123",
"name": "my-component",
"consume_variant": [
{
"id": "variant-id",
"name": "default",
"loader": {
// Component loader configuration (HTML, styles, scripts)
}
}
]
}
}

Error Responses

Status CodeDescription
400Bad Request - Missing required id parameter
404Not Found - Component or variant not found

Flow API (Legacy)

Deprecation Notice

The Flow API is deprecated and will be removed in a future version. Please migrate to the Consume API for fetching component configurations.

The legacy Flow API fetches component configurations based on User Flows.

API Endpoint

GET https://cloud.myop.dev/flow?id={FLOW_ID}&resolve=components

Parameters

  • FLOW_ID – The unique identifier for your User Flow. You can find this in the browser's URL when viewing the flow in the Myop Dashboard.
  • resolve=components – Ensures that the response includes the full component configuration.

Response

The API returns an object of type IUserFlow, which contains details about the user flow and its associated components.

Migration Guide

To migrate from the Flow API to the Consume API:

  1. Get your component ID from the Myop Dashboard (instead of the Flow ID)
  2. Replace your API call:
    - GET https://cloud.myop.dev/flow?id={FLOW_ID}&resolve=components
    + GET https://cloud.myop.dev/consume?id={COMPONENT_ID}&env=prod
  3. Update your response handling to use the new response structure

Purpose of Myop Cloud

Myop Cloud is designed to provide a centralized and scalable way to manage UI components dynamically. It enables:

  • Real-time updates: Ensure that your application always uses the latest published component configurations.
  • Environment support: Test components in staging before deploying to production.
  • Preview mode: Test unpublished changes before making them live.
  • Decoupled component management: Define components in the Myop Dashboard and retrieve them as needed without hardcoding configurations in your frontend.
  • Micro frontend integration: Myop Cloud makes it easier to load and manage remote UI components across different applications, improving flexibility in micro frontend architectures.