Code Monkey home page Code Monkey logo

lemmy_api_client's Introduction

⚠️ THIS PROJECT IS NOT MAINTAINED ANYMORE ⚠️

This project has been officially dropped due to lack of interest and political differences. If anyone is interested in continuing developement, feel free to fork it. For any questions you can message krawieck (who was responsible for the flutter app) or shilangyu (who was responsible for lemmy_api_client).


Lemmy Dart API client

A Dart client for the Lemmy API

Features

  • Future-based
  • Works both for Web and Native environments
  • Strictly typed responses
  • Room websocket joins
  • Pictrs endpoints
  • Models have a .instanceHost property that indicate the instance that returned this model

Example

import 'package:lemmy_api_client/v3.dart';

Future<void> main() async {
  // instantiate your lemmy instance with the host uri
  const lemmy = LemmyApiV3('lemmy.ml');

  // call methods that are named after op codes from the lemmy docs
  final response =
      await lemmy.run(const Login(usernameOrEmail: 'asd', password: 'ads'));

  final messages = await lemmy
      .run(GetPrivateMessages(unreadOnly: true, auth: response.jwt!.raw));

  print(messages);
}

check out Lemmur, a mobile Lemmy client in Flutter


Original Lemmy logo made by Andy Cuccaro (@andycuccaro) under the CC-BY-SA 4.0 license. Remixed by Marcin Wojnarowski (@shilangyu) and re-released under the CC-BY-SA 4.0 license.

lemmy_api_client's People

Contributors

ilpianista avatar imgbotapp avatar krawieck avatar louismarotta avatar shilangyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lemmy_api_client's Issues

Support Lemmy API v2

So we're finalizing and readying the release of the v2 of the lemmy API within a week or two. I've updated lemmy-js-client, which is what lemmy-ui uses, and you'll have to do a similar process for this dart client, and lemmur.

Here's the docs for the v2 API, which mostly link to the lemmy-js-client, which has the full typings:

https://github.com/LemmyNet/lemmy-docs/blob/main/src/en/contributing/websocket_http_api.md#data-types

The biggest differences you'll find are that the objects are much more hierarchical and normalized; rather than having a flat PostView, with things like community_name at the top level, you now have hierarchical objects:

export interface PostView {
    post: Post;
    creator: UserSafe;
    community: CommunitySafe;
    creator_banned_from_community: boolean;
    counts: PostAggregates;
    subscribed: boolean;
    saved: boolean;
    read: boolean;
    my_vote?: number;
}

All of these new types, forms, etc are linked in the docs above. Rather than find specific differences, it might be easier to just copy paste the typescript objects, then convert them to dart (I actually did this process going from rust -> typescript, to make sure everything matched exactly).

Let me know if there's anything I can do to help with this effort.

If you need an instance to test these with, https://enterprise.lemmy.ml and all the federation instances are using it.

cc @Nutomic

Create functions for all API endpoints

All functions have temporary return type String and will throw UnimplementedError when called until they become functional

  • GET /user
  • POST /user/login
  • POST /user/register
  • GET /user/get_captcha
  • GET /user/followed_communities
  • GET /user/replies
  • GET /user/mentions
  • POST /user/mentions/mark_as_read
  • PUT /save_user_settings
  • GET /private_message/list
  • POST /private_message
  • PUT /private_message
  • POST /private_message/delete
  • POST /private_message/mark_as_read
  • POST /user/mark_all_as_read
  • POST /user/delete_account
  • POST /admin/add
  • POST /user/ban
  • GET /categories
  • POST /search
  • GET /modlog
  • POST /site
  • PUT /site
  • GET /site
  • POST /site/transfer
  • GET /site/config
  • PUT /site/config
  • GET /community
  • POST /community
  • PUT /community
  • GET /community/list
  • POST /community/ban_user
  • POST /community/mod
  • POST /community/delete
  • POST /community/remove
  • POST /community/follow
  • POST /community/transfer
  • POST /post
  • GET /post
  • GET /post/list
  • POST /post/like
  • PUT /post
  • POST /post/delete
  • POST /post/remove
  • POST /post/lock
  • POST /post/sticky
  • POST /post/save
  • POST /comment
  • PUT /comment
  • POST /comment/delete
  • POST /comment/remove
  • POST /comment/mark_as_read
  • POST /comment/save
  • POST /comment/like

Create response json models

Based on lemmy API objects that are equivalents to those returned by said API:

regular stuff

  • CommunityView
  • CommunityFollowerView
  • CommunityModeratorView
  • PostView
  • CommentView
  • ReplyView
  • UserView
  • UserMentionView
  • PrivateMessageView
  • SiteView
  • Category
  • User_ -> renamed to User

indirect models

mod stuff

  • ModRemovePostView
  • ModLockPostView
  • ModRemoveCommentView
  • ModRemoveCommunityView
  • ModBanFromCommunityView
  • ModBanView
  • ModAddCommunityView
  • ModAddView

Implement API v1 endpoints

An item is checked if:

  • tests are written
  • implementation is written
  • tests pass

  • GET /user
  • POST /user/login
  • POST /user/register
  • GET /user/get_captcha
  • GET /user/followed_communities
  • GET /user/replies
  • GET /user/mentions
  • POST /user/mentions/mark_as_read
  • POST /user/ban
  • PUT /save_user_settings
  • GET /private_message/list
  • POST /private_message
  • PUT /private_message
  • POST /private_message/delete
  • POST /private_message/mark_as_read
  • POST /user/mark_all_as_read
  • POST /user/delete_account
  • POST /admin/add
  • GET /categories
  • POST /search
  • GET /modlog
  • POST /site
  • PUT /site
  • GET /site
  • POST /site/transfer
  • GET /site/config
  • PUT /site/config
  • GET /community
  • POST /community
  • PUT /community
  • GET /community/list
  • POST /community/ban_user
  • POST /community/mod
  • POST /community/delete
  • POST /community/remove
  • POST /community/follow
  • POST /community/transfer
  • POST /post
  • GET /post
  • GET /post/list
  • POST /post/like
  • PUT /post
  • POST /post/delete
  • POST /post/remove
  • POST /post/lock
  • POST /post/sticky
  • POST /post/save
  • POST /comment
  • PUT /comment
  • POST /comment/delete
  • GET /comment/list
  • POST /comment/remove
  • POST /comment/mark_as_read
  • POST /comment/save
  • POST /comment/like

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.