Documentation/Minimal Working Example #33
-
Hello, I am interested in trying to use this api client but I don't see any documentation or a minimal working example. I was wondering if it could be added to the repository or if someone could point me in the right direction. I found the deprecated older version on pub.dev but I am guessing the code must have changed significantly since then. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey there! Just to preface this, the API is expected change quite a bit as we start work on the re-architecture (and alongside that, support for v4 and v1.0.0 of the Lemmy API). See #30 for a general idea of the new architecture. I do expect this to take a fair amount of time, so in the meantime, I can provide some quick start guides on how you can use the current API if you're still interested.
There's no published version of this package on pub.dev, so you'll have to add the dependency yourself in your project with the associated commit tag. For example: # pubspec.yaml
dependencies:
lemmy_api_client:
git:
url: "https://github.com/thunder-app/lemmy_api_client.git"
ref: f352a17afad3d7a4fa98e1711a4886d1fa3929ae Here's a quick example of how you can use the API once you have the dependency added: import 'package:lemmy_api_client/v3.dart';
Future<void> main() async {
// Initialize the Lemmy API Client with the given instance URI
const lemmy = LemmyApiV3('lemmy.ml');
// Fetch posts
final response = await lemmy.run(const GetPosts(page: 1));
print(response);
} Most, but not all of the endpoints are covered in this API. If there's a specific endpoint that is missing that you would like to see added, feel free to create a new issue or PR for it! Additionally, you can perform an authenticated request to nearly all of the endpoints by passing in import 'package:lemmy_api_client/v3.dart';
Future<void> main() async {
// Initialize the Lemmy API Client with the given instance URI
const lemmy = LemmyApiV3('lemmy.ml');
// Fetch posts
final response = await lemmy.run(const GetPosts(page: 1, auth: "{jwt_token}"));
print(response); Let me know if you have any more questions! |
Beta Was this translation helpful? Give feedback.
Hey there!
Just to preface this, the API is expected change quite a bit as we start work on the re-architecture (and alongside that, support for v4 and v1.0.0 of the Lemmy API). See #30 for a general idea of the new architecture. I do expect this to take a fair amount of time, so in the meantime, I can provide some quick start guides on how you can use the current API if you're still interested.
There's no published version of this package on pub.dev, so you'll have to add the dependency yourself in your project with the as…