json_api
8.1.0, released 2 years ago by karapetov.com
Framework-agnostic implementations of JSON:API Client and Server.
What it does
Provides tools to build JSON:API compliant clients and servers in Dart. It decouples the JSON:API protocol handling from the underlying HTTP client via http_interop.
AI-written summary of version 8.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are building a client or server that communicates using the JSON:API specification (v1.0/v1.1).
- You need standard URI design routing and resource collection manipulation for JSON:API.
Skip it when
- Your backend uses standard REST or GraphQL instead of the strict JSON:API standard.
- You want an all-in-one HTTP client without dealing with explicit JSON:API protocol serializers.
Strengths
- Implements the official JSON:API standard.
- Framework-agnostic and decoupled from specific HTTP implementations.
Weaknesses
- Requires installing separate HTTP interop adapters like http_interop_http.
- Work-in-progress status with frequent breaking changes across major versions.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
Requires adding http_interop and an implementation like http_interop_http alongside http.
import 'package:http/http.dart' as http;
import 'package:http_interop_http/http_interop_http.dart';
import 'package:json_api/client.dart';
import 'package:json_api/routing.dart';
void main() async {
final baseUri = 'http://localhost:8080';
final uriDesign = StandardUriDesign(Uri.parse(baseUri));
final httpClient = http.Client();
final httpHandler = httpClient.handleInterop;
final jsonApiClient = Client(httpHandler);
final client = RoutingClient(uriDesign, jsonApiClient);
try {
final response = await client.fetchCollection('colors');
for (final resource in response.collection) {
print('${resource.type}:${resource.id}');
}
} on RequestFailure catch (e) {
for (final error in e.errors) {
print(error.title);
}
}
httpClient.close();
}Alternatives
Packages that do the same job and could replace json_api.
- dart_mcp
A Dart library for building Model Context Protocol (MCP) servers and clients.
87Compare - cronet_http
An Android Flutter plugin providing access to the Cronet HTTP client.
87Compare - http_cache_hive_store
Hive cache store implementation for HTTP and Dio clients using hive_ce.
79Compare - http2
An HTTP/2 implementation in Dart for low-level transport and pooled HTTP/2 requests.
91Compare
Works with
Packages commonly used together with json_api: ones it builds on, ones built on it, and its own family.