data-client-rest

Define type-safe REST resources and endpoints with automatic normalization and caching.

2.0k|99|Updated Feb 15, 2019
One-click install
npx skills add https://github.com/reactive/data-client --skill data-client-rest
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-client-rest
Source: https://github.com/reactive/data-client/tree/main/.agents/skills/data-client-rest
Command: npx skills add https://github.com/reactive/data-client --skill data-client-rest

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @data-client/rest, and includes references (resource) components.

What problem does it solve?

Writing REST API integration code in React or TypeScript apps often means manually handling fetch calls, response parsing, cache updates, and type definitions. This Skill guides AI code generation to produce idiomatic @data-client/rest definitions so endpoints, resources, and mutations are type-safe and automatically normalized.

Core Features & Use Cases

  • Resource Definitions: Generate CRUD resources with resource() covering GET, POST, PUT, PATCH, and DELETE with typed path parameters and searchParams.
  • Custom Endpoints: Create standalone RestEndpoint instances with polling, optimistic responses, custom headers, and lifecycle overrides like parseResponse.
  • Advanced Patterns: Handle pagination, optimistic updates, authentication headers, file downloads, and resource extension via .extend().
  • Use Case: Ask the AI to model a JSONPlaceholder todos API and it produces a TodoResource with typed searchParams, pagination support, and optimistic mutations ready for useSuspense and controller.fetch calls.

Quick Start

Define a REST resource for the todos API at jsonplaceholder.typicode.com with typed search params and pagination using @data-client/rest.

Frequently Asked Questions about data-client-rest

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

FAQPage Schema
How do I define a REST resource with CRUD endpoints in TypeScript?

Use resource() from @data-client/rest with a path template and an Entity schema. It generates get, getList, update, partialUpdate, and delete endpoints with typed path parameters, plus push and unshift mutations on getList.

When should I use RestEndpoint instead of resource()?

Use RestEndpoint for standalone single endpoints or when mutation endpoints are not needed. The resource() helper is intended for full CRUD collections; defining it without mutations adds unnecessary endpoints.

Does @data-client/rest support pagination and infinite scroll?

Yes, set paginationField on resource() to add a getList.getPage endpoint for fetching additional pages. Cursor and offset pagination patterns are covered in the pagination reference guide.

How do I add authentication headers to REST requests?

Override getHeaders() in a RestEndpoint subclass or extended resource to inject tokens into every request. The auth reference guide covers login, logout, and token-based header flows.

Can @data-client/rest handle file downloads and non-JSON responses?

Yes, override parseResponse() in the endpoint lifecycle to handle blobs and other non-JSON payloads. The network-transform reference documents the file download pattern.