misskey 0.0.1
misskey: ^0.0.1 copied to clipboard
This library provides the easiest and powerful Dart/Flutter library for Misskey API.
example/example.dart
// Copyright 2023 Kato Shinya. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.
import 'package:misskey/misskey.dart';
Future<void> main() async {
//! You need to specify misskey instance (domain) you want to access.
final misskey = MisskeyApi(
instance: 'misskey.io',
accessToken: 'YOUR_ACCESS_TOKEN',
//! Automatic retry is available when server error or network error occurs
//! when communicating with the API.
retryConfig: RetryConfig(
maxAttempts: 5,
onExecute: (event) => print(
'Retry after ${event.intervalInSeconds} seconds...'
'[${event.retryCount} times]',
),
),
//! The default timeout is 10 seconds.
timeout: Duration(seconds: 20),
);
try {
final me = await misskey.accounts.lookupMe();
print(me);
} on UnauthorizedException catch (e) {
print(e);
} on RateLimitExceededException catch (e) {
print(e);
} on MisskeyException catch (e) {
print(e);
}
}