sanity_api 0.1.1
sanity_api: ^0.1.1 copied to clipboard
Pure Dart client for the Sanity.io Content Lake: GROQ queries, document mutations, transactions and asset uploads. Runs on Dart servers, CLIs and Flutter apps.
example/sanity_api_example.dart
import 'package:sanity_api/sanity_api.dart';
Future<void> main() async {
final client = SanityClient(
SanityConfig(
projectId: 'abc123',
dataset: 'production',
apiVersion: '2024-05-03',
),
);
final exercises = await client.fetch<List<Object?>>(
r'*[_type == "exercise" && $tag in tags][0...10]{_id, title}',
params: {'tag': 'shoulder'},
);
print('Found ${exercises.length} exercises');
final response = await client.fetchFull<Object?>('count(*[_type == "exercise"])');
print('Counted in ${response.ms}ms');
client.close();
}