mainsequence-api-surfaces

Design and validate FastAPI API surfaces with explicit request and response models.

6|1|Updated Nov 14, 2024
One-click install
npx skills add https://github.com/mainsequence-sdk/mainsequence-sdk --skill mainsequence-api-surfaces
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mainsequence-api-surfaces
Source: https://github.com/mainsequence-sdk/mainsequence-sdk/tree/main/docs/astro/application_surfaces/api_surfaces
Command: npx skills add https://github.com/mainsequence-sdk/mainsequence-sdk --skill mainsequence-api-surfaces

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enable teams to design and validate application-facing APIs in a Main Sequence repository using FastAPI. The skill provides a framework for structuring FastAPI project resources, defining request/response contracts, and binding user context to API routes, ensuring widget-facing contracts when applicable.

Core Features & Use Cases

  • Define FastAPI structures as a Main Sequence project resource
  • Specify explicit request and response models and binding context
  • Consume published DataNodes via APIDataNode and read SimpleTables for tabular data
  • Enforce widget-facing contracts for UI integrations and maintain consistent contracts across routes
  • Guiding decisions on whether to own API logic or consume producer resources

Quick Start

Create a FastAPI surface for a Main Sequence project with explicit request/response contracts and widget-facing API contracts.

Frequently Asked Questions about mainsequence-api-surfaces

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design FastAPI request and response models for an application-facing API?

Define FastAPI API surfaces by declaring explicit request and response models for each endpoint. This contract-driven approach structures application-facing APIs in a Main Sequence project, ensuring validation and clear data binding.

What is a widget-facing contract in FastAPI and when do I need it?

A widget-facing contract defines API response structures specifically for UI component integration. You need widget-facing contracts when building FastAPI routes that directly supply data to UI widgets, maintaining consistent expectations across application surfaces.

How do I consume APIDataNode and SimpleTable resources in a FastAPI project?

Consume APIDataNode and SimpleTable resources by reading published DataNodes within your FastAPI routes. This lets your API surfaces retrieve tabular data and bind producer resources into structured responses without owning the underlying logic.

Can I bind user context to API routes in a Main Sequence FastAPI application?

Yes, you can bind user context to API routes by applying middleware to your FastAPI endpoints. This middleware intercepts requests to attach user context, ensuring API surfaces enforce project resource discovery and access rules.

Should I own API logic or consume producer resources when building FastAPI routes?

Decide whether to own API logic or consume producer resources based on project needs. Consuming APIDataNode resources avoids duplicate logic, while owning logic allows custom validation when structuring FastAPI project resources.

Does this approach require explicit contracts for every FastAPI endpoint?

Yes, designing API surfaces requires explicit request and response models for every endpoint. This contract-driven validation ensures alignment with project resource discovery and maintains consistent widget-facing contracts for UI integrations.