Developer

Projects API

Read project metadata from your custom resource.

Projects API

The Projects API provides read-only access to project metadata. Use it to list all projects or get the project that owns the current resource.

Capability required: projects:read

Frontend (iframe)

import { createResourceClient } from "@rightplace/sdk";

const rp = createResourceClient();
await rp.ready();

// Get the project that owns this resource
const current = await rp.projects.getCurrent();
// -> { id: "abc123", name: "My Site", icon: "globe", color: "#3b82f6" }

// List all projects
const all = await rp.projects.list();
// -> [{ id: "abc123", name: "My Site", ... }, { id: "def456", name: "Blog", ... }]

Backend (Node.js)

import { createResourceServer } from "@rightplace/sdk/server";

const server = createResourceServer({
  methods: {
    getProjectInfo: async (_params, { rp }) => {
      const project = await rp.projects.getCurrent();
      return { projectName: project.name };
    },

    listAllProjects: async (_params, { rp }) => {
      return await rp.projects.list();
    },
  },
});

server.start();

API Reference

rp.projects.getCurrent()

Returns the project that owns the current resource.

ParameterTypeDescription
ReturnsPromise<ProjectInfo>The owning project

rp.projects.list()

Returns all projects in the workspace.

ParameterTypeDescription
ReturnsPromise<ProjectInfo[]>All projects

ProjectInfo

FieldTypeDescription
idstringProject ID
namestringProject name
iconstring | nullIcon identifier
colorstring | nullHeader color (hex)

Manifest Configuration

{
  "capabilities": [
    "projects:read"
  ]
}

Notes

  • This API is read-only. Resources cannot create, update, or delete projects.
  • The folderPath is not exposed for security reasons. Use the Project Filesystem API to access project files.