API Documentation

RESTful API for the React Style Guide

GET

Get Rules (JSON)

Endpoint

GET /api/rules.json

Description

Returns a comprehensive collection of React development rules including state management, component design, performance optimization, and best practices.

Response Schema


              {
  "rules": [
    {
      "id": "string",           // Unique identifier for the rule
      "directive": "string",    // The rule statement/guideline  
      "rationale": "string"     // Explanation of why the rule exists
    }
  ]
}
            

Example Response


              {
  "rules": [
    {
      "id": "STATE_SCOPE",
      "directive": "Hold each piece of React state in the lowest common ancestor that consumes it; lift only when multiple siblings need the same data.",
      "rationale": "Minimises re‑render surface and keeps ownership obvious."
    },
    {
      "id": "COMPONENT_FUNCTIONAL", 
      "directive": "Use function components and Hooks exclusively; avoid class components in new code.",
      "rationale": "Aligns with the current React runtime and future features (concurrency, RSC)."
    }
  ]
}
            
Try it out
GET

Get Cursor Rules (Text)

Endpoint

GET /api/cursorrules.txt

Description

Returns React style guide rules formatted as plain text, suitable for use with Cursor AI editor or other text-based tooling integrations.

Response Format

Content-Type: text/plain

Example Response


              # Cursor Rules

## React Style Guide

This is a style guide for React. It is a set of rules that are designed to help you write better React code.

## React Style Guide
            
Try it out

HTTP Status Codes

200 OK - Request successful
404 Not Found - Endpoint does not exist
500 Internal Server Error - Something went wrong

Usage Examples

JavaScript/Node.js

// Fetch React style guide rules
const response = await fetch('/api/rules.json');
const data = await response.json();

console.log(`Found ${data.rules.length} rules`);
data.rules.forEach(rule => {
  console.log(`${rule.id}: ${rule.directive}`);
});

Python

import requests

# Get rules as JSON
response = requests.get('https://yourdomain.com/api/rules.json')
rules_data = response.json()

for rule in rules_data['rules']:
    print(f"{rule['id']}: {rule['directive']}")

cURL

# Get JSON rules
curl -X GET /api/rules.json

# Get text rules for Cursor
curl -X GET /api/cursorrules.txt