api-integration
БесплатноБез исполняемых скриптовНе проверенUse when integrating Apidog + OpenAPI specifications with your React app. Covers MCP server setup, type generation, and query layer integration. Use when…
Об этом скилле
API Integration (Apidog + MCP)
Integrate OpenAPI specifications with your frontend using Apidog MCP for single source of truth.
Goal
The AI agent always uses the latest API specification to generate types and implement features correctly.
Architecture
Apidog (or Backend)
→ OpenAPI 3.0/3.1 Spec
→ MCP Server (apidog-mcp-server)
→ AI Agent reads spec
→ Generate TypeScript types
→ TanStack Query hooks
→ React Components
Process
1. Expose OpenAPI from Apidog
Option A: Remote URL
- Export OpenAPI spec from Apidog
- Host at a URL (e.g.,
https://api.example.com/openapi.json)
Option B: Local File
- Export OpenAPI spec to file
- Place in project (e.g.,
./api-spec/openapi.json)
2. Wire MCP Server
// .claude/mcp.json or settings
{
"mcpServers": {
"API specification": {
"command": "npx",
"args": [
"-y",
"apidog-mcp-server@latest",
"--oas=https://api.example.com/openapi.json"
]
}
}
}
With Local File:
{
"mcpServers": {
"API specification": {
"command": "npx",
"args": [
"-y",
"apidog-mcp-server@latest",
"--oas=./api-spec/openapi.json"
]
}
}
}
Multiple APIs:
{
"mcpServers": {
"Main API": {
"command": "npx",
"args": ["-y", "apidog-mcp-server@latest", "--oas=https://api.main.com/openapi.json"]
},
"Auth API": {
"command": "npx",
"args": ["-y", "apidog-mcp-server@latest", "--oas=https://api.auth.com/openapi.json"]
}
}
}
3. Generate Types & Client
Create /src/api directory for all API-related code:
/src/api/
├── types.ts # Generated from OpenAPI
├── client.ts # HTTP client (axios/fetch)
├── queries/ # TanStack Query hooks
│ ├── users.ts
│ ├── posts.ts
│ └── ...
└── mutations/ # TanStack Mutation hooks
├── users.ts
├── posts.ts
└── ...
Option A: Hand-Written Types (Lightweight)
// src/api/types.ts
import { z } from 'zod'
// Define schemas from OpenAPI
export const UserSchema = z.object({
id: z.string(),
name: z.string(),
email: z.string().email(),
createdAt: z.string().datetime(),
})
export type User = z.infer<typeof UserSchema>
export const CreateUserSchema = UserSchema.omit({ id: true, createdAt: true })
export type CreateUserDTO = z.infer<typeof CreateUserSchema>
Option B: Code Generation (Recommended for large APIs)
# Using openapi-typescript
pnpm add -D openapi-typescript
npx openapi-typescript https://api.example.com/openapi.json -o src/api/types.ts
# Using orval
pnpm add -D orval
npx orval --input https://api.example.com/openapi.json --output src/api
4. Create HTTP Client
// src/api/client.ts
import axios from 'axios'
import createAuthRefreshInterceptor from 'axios-auth-refresh'
export const apiClient = axios.create({
baseURL: import.meta.env.VITE_API_URL,
headers: {
'Content-Type': 'application/json',
},
})
// Request interceptor - add auth token
apiClient.interceptors.request.use((config) => {
const token = localStorage.getItem('accessToken')
if (token) {
config.headers.Authorization = `Bearer ${token}`
}
return config
})
// Response interceptor - handle token refresh
const refreshAuth = async (failedRequest: any) => {
try {
const refreshToken = localStorage.getItem('refreshToken')
const response = await axios.post('/auth/refresh', { refreshToken })
const { accessToken } = response.data
localStorage.setItem('accessToken', accessToken)
failedRequest.response.config.headers.Authorization = `Bearer ${accessToken}`
return Promise.resolve()
} catch (error) {
localStorage.removeItem('accessToken')
localStorage.removeItem('refreshToken')
window.location.href = '/login'
return Promise.reject(error)
}
}
createAuthRefreshInterceptor(apiClient, refreshAuth, {
statusCodes: [401],
pauseInstanceWhileRefreshing: true,
})
5. Build Query Layer
Feature-based query organization:
// src/api/queries/users.ts
import { queryOptions } from '@tanstack/react-query'
import { apiClient } from '../client'
import { User, UserSchema } from '../types'
// Query key factory
export const usersKeys = {
all: ['users'] as const,
lists: () => [...usersKeys.all, 'list'] as const,
list: (filters: string) => [...usersKeys.lists(), { filters }] as const,
details: () => [...usersKeys.all, 'detail'] as const,
detail: (id: string) => [...usersKeys.details(), id] as const,
}
// API functions
async function fetchUsers(): Promise<User[]> {
const response = await apiClient.get('/users')
return z.array(UserSchema).parse(response.data)
}
async function fetchUser(id: string): Promise<User> {
const response = await apiClient.get(`/users/${id}`)
return UserSchema.parse(response.data)
}
// Query options
expo
Установить api-integration в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл api-integration?
Use when integrating Apidog + OpenAPI specifications with your React app. Covers MCP server setup, type generation, and query layer integration. Use when setting up API clients, generating types from OpenAPI, or integrating with Apidog MCP.
Как установить скилл api-integration?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл api-integration запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic