Flutter/Dart 패키지로 WordPress REST API와 원활한 상호작용을 가능하게 합니다. 일반적인 엔드포인트와 게시물, 페이지, 댓글 등에 대한 완전한 CRUD 작업을 지원합니다. WordPress 기반 웹사이트와 통합되는 앱을 개발하는 개발자를 위한 것으로, 다양한 플랫폼 간 데이터 검색 및 관리를 단순화합니다. 가볍고 잘 문서화되어 있으며 지속적으로 유지보수되고 있습니다.
사용 사례
블로그 게시물과 페이지를 가져오는 중
프로그래밍을 통해 콘텐츠 생성 및 업데이트
댓글 및 미디어 관리
맞춤형 워드프레스 프론트엔드 빌드
WordPress를 헤드리스 CMS로 통합하기
주요 기능
핵심 엔드포인트에 대한 완전한 CRUD 지원
크로스 플랫폼 호환성
간단하고 직관적인 API
토큰을 통한 인증을 지원합니다
내장된 오류 처리 및 응답 파싱
적합한 대상
WordPress 통합이 필요한 Flutter 앱
헤드리스 CMS 애플리케이션
콘텐츠 기반 모바일 및 웹 앱
백엔드로 WordPress를 사용하는 개발자
고려 사항
유효한 WordPress REST API 접근 권한이 필요합니다
보호된 엔드포인트에 대한 인증 설정이 필요합니다
WordPress REST API 기능에 제한됨
복잡한 워드프레스 전용 논리에 적합하지 않습니다
외부 워드프레스 서버의 안정성에 따라 달라짐
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
WordPress Client
The modern, strongly‑typed WordPress REST API client for Dart & Flutter — fast, flexible, and production‑ready.
🚀 Features
📦 API discovery support.
⏲️ Measures request completion time.
📝 Supports all CRUD operations.
🌐 Supports all common REST endpoints.
🧩 GraphQL (WPGraphQL) support: client.graphql.query/mutate/raw() with auth.
🎨 Custom Requests & Authorization systems.
🔐 3 Popular authorization methods.
🗄️ Third‑party Database integration.
🔧 Middlewares for request & response operations.
🎣 Events for preprocessing response.
🚀 Execute requests in Parallel (with configurable error handling).
🧠 Optional in‑memory caching for GET requests.
🌊 Polling-based streaming for single-resource retrieve endpoints (works great with Riverpod's StreamProvider).
📦 Install
Add wordpress_client to your pubspec.yaml:
dependencies:
wordpress_client: ^9.2.0
Then run flutter pub get or dart pub get.
🔧 Quick start
Import and initialize:
import'package:wordpress_client/wordpress_client.dart';
final client = WordpressClient.forSite(
siteUrl: Uri.parse('https://example.com'),
// or: baseUrl via WordpressClient(baseUrl: Uri.parse('.../wp-json/wp/v2'))
);
🧩 GraphQL (WPGraphQL)
If your site uses the WPGraphQL plugin (canonical), you can send GraphQL operations using the same client and auth.
final client = WordpressClient.forSite(
siteUrl: Uri.parse('https://example.com'),
bootstrapper: (b) => b
.withDefaultAuthorization(
WordpressAuth.appPassword(user: 'user', appPassword: 'xxxx-xxxx'),
)
.build(),
);
// Auto-resolves https://example.com/graphql from the REST base.final result = await client.graphql.query<List<Map<String, dynamic>>>(
document: '''
query Posts($limit: Int!) {
posts(first: $limit) {
nodes { id title }
}
}
''',
variables: { 'limit': 5 },
parseData: (data) {
final nodes = (data['posts']?['nodes'] asList<dynamic>? ?? const [])
.cast<Map<String, dynamic>>();
return nodes;
},
requireAuth: false, // set true for restricted queries/mutations
);
switch (result) {
caseWordpressSuccessResponse():
print(result.data);
caseWordpressFailureResponse():
print('GraphQL error: ${result.error}');
}
// Custom endpoint path if your site exposes a different GraphQL path
client.graphql.setEndpointPath('/custom-graphql');