2023-10-12 SteemLife Development JournalsteemCreated with Sketch.

in Steem Dev3 years ago (edited)

I'm a full-stack developer, working on various apps and projects.
And I'm constantly sharing articles related to development.
If you're curious about the project, you can learn more about it through the following links: [Steemlife] Dreaming of a free life on Steem


I used the condenser_api.get_discussions_by_feedAPI to get the Feed list of My Friends from the Steemit API.
However, I got an error like below.

{
    "jsonrpc":"2.0",
    "id":1,
    "error":{
        "code":-32603,
        "message":"Internal Error",
        "data":{
            "error_id":"da9bad15-8d96-4c65-a3e0-7ba44322798d",
            "jussi_request_id":"000849412037747723"
        }
    }
}

I remember this API working well in the past.
You can read about it in the following articles: [Flutter] Mobile App Development with Flutter - Implementing a Steemit Feed

This error prevented us from continuing development. So I looked at what APIs the other services were calling.
The steemit condenser and UPVU , ECBlog services were all using the bridge.get_account_posts API. However I couldn't find that API in the Steem API documentation.

Since there was no API documentation, I developed it by referring to the condenser source code.


Below is the Dart code to parse the bridge.get_account_posts result.

import 'package:freezed_annotation/freezed_annotation.dart';

part "post.freezed.dart";
part "post.g.dart";

@freezed
@immutable
class Post with _$Post {
  const factory Post({
    @JsonKey(name: "post_id") required int postId,
    @JsonKey(name: "author") required String author,
    @JsonKey(name: "permlink") required String permlink,
    @JsonKey(name: "category") required String category,
    @JsonKey(name: "title") required String title,
    @JsonKey(name: "body") required String body,
    @JsonKey(name: "json_metadata") required JsonMetadata jsonMetadata,
    @JsonKey(name: "created") required DateTime created,
    @JsonKey(name: "updated") required DateTime updated,
    @JsonKey(name: "depth") required int depth,
    @JsonKey(name: "children") required int children,
    @JsonKey(name: "net_rshares") required int netRShares,
    @JsonKey(name: "is_paidout") required bool isPaidOut,
    @JsonKey(name: "payout_at") required DateTime payoutAt,
    @JsonKey(name: "payout") required double payout,
    @JsonKey(name: "pending_payout_value") required String pendingPayoutValue,
    @JsonKey(name: "author_payout_value") required String authorPayoutValue,
    @JsonKey(name: "curator_payout_value") required String curatorPayoutValue,
    @JsonKey(name: "promoted") required String promoted,
    @JsonKey(name: "replies") required List<dynamic> replies,
    @JsonKey(name: "active_votes") required List<ActiveVote> activeVotes,
    @JsonKey(name: "author_reputation") required double authorReputation,
    @JsonKey(name: "stats") required PostState stats,
    @JsonKey(name: "beneficiaries") required List<dynamic> beneficiaries,
    @JsonKey(name: "max_accepted_payout") required String maxAcceptedPayout,
    @JsonKey(name: "percent_steem_dollars") required int percentSteemDollars,
    @JsonKey(name: "url") required String url,
    @JsonKey(name: "blacklists") required List<dynamic> blacklists,
    @JsonKey(name: "community") required String? community,
    @JsonKey(name: "community_title") required String? communityTitle,
    @JsonKey(name: "author_role") required String? authorRole, // "guest" or "admin" or "mod"
    @JsonKey(name: "author_title") required String? authorTitle,
  }) = _Post;

  factory Post.fromJson(Map<String, dynamic> json) => _$PostFromJson(json);
}

@freezed
@immutable
class JsonMetadata with _$JsonMetadata {
  const factory JsonMetadata({
    required List<String>? tags,
    required List<String>? image,
    required List<String>? users,
    required String? app,
    required String? format,
  }) = _JsonMetadata;

  factory JsonMetadata.fromJson(Map<String, dynamic> json) =>
      _$JsonMetadataFromJson(json);
}

@freezed
@immutable
class ActiveVote with _$ActiveVote {
  const factory ActiveVote({
    @JsonKey(name: "voter") required String voter,
    @JsonKey(name: "rshares") required String rShares,
  }) = _ActiveVote;

  factory ActiveVote.fromJson(Map<String, dynamic> json) =>
      _$ActiveVoteFromJson(json);
}

@freezed
@immutable
class PostState with _$PostState {
  const factory PostState({
    @JsonKey(name: "hide") required bool hide,
    @JsonKey(name: "gray") required bool gray,
    @JsonKey(name: "total_votes") required int totalVotes,
    @JsonKey(name: "flag_weight") required double flagWeight,
  }) = _PostState;

  factory PostState.fromJson(Map<String, dynamic> json) =>
      _$PostStateFromJson(json);
}

I'd love it if you could follow me (@anpigon) and upvote me, I'd appreciate it. Your comments and feedback are always welcome, so feel free to reach out with a comment or a mention.

Thanks again for visiting the blog, and I look forward to continuing to share upcoming development projects and technical content with you. Thank you for your support!

Sort:  

안녕하세요.
SteemitKorea팀에서 제공하는 'steemit-enhancer'를 사용해 주셔서 감사합니다. 개선 사항이 있으면 언제나 저에게 연락을 주시면 되고, 관심이 있으신 분들은 https://cafe.naver.com/steemitkorea/425 에서 받아보실 수 있습니다. 사용시 @응원해 가 포함이 되며, 악용시에는 모든 서비스에서 제외될 수 있음을 알려드립니다.

[광고] STEEM 개발자 커뮤니티에 참여 하시면, 다양한 혜택을 받을 수 있습니다.


안녕하세요.
이 글은 SteemitKorea팀(@ayogom)님께서 저자이신 @anpigon님을 응원하는 글입니다.
소정의 보팅을 해드렸습니다 ^^ 항상 좋은글 부탁드립니다
SteemitKorea팀에서는 보다 즐거운 steemit 생활을 위해 노력하고 있습니다.
이 글은 다음날 다시 한번 포스팅을 통해 소개 될 예정입니다. 감사합니다!

안녕하세요.
SteemitKorea팀에서 제공하는 'steemit-enhancer'를 사용해 주셔서 감사합니다. 개선 사항이 있으면 언제나 저에게 연락을 주시면 되고, 관심이 있으신 분들은 https://cafe.naver.com/steemitkorea/425 에서 받아보실 수 있습니다. 사용시 @응원해 가 포함이 되며, 악용시에는 모든 서비스에서 제외될 수 있음을 알려드립니다.

Upvoted! Thank you for supporting witness @jswit.

안녕하세요.
SteemitKorea팀에서 제공하는 'steemit-enhancer'를 사용해 주셔서 감사합니다. 개선 사항이 있으면 언제나 저에게 연락을 주시면 되고, 관심이 있으신 분들은 https://cafe.naver.com/steemitkorea/425 에서 받아보실 수 있습니다. 사용시 @응원해 가 포함이 되며, 악용시에는 모든 서비스에서 제외될 수 있음을 알려드립니다.

안녕하세요.
SteemitKorea팀에서 제공하는 'steemit-enhancer'를 사용해 주셔서 감사합니다. 개선 사항이 있으면 언제나 저에게 연락을 주시면 되고, 관심이 있으신 분들은 https://cafe.naver.com/steemitkorea/425 에서 받아보실 수 있습니다. 사용시 @응원해 가 포함이 되며, 악용시에는 모든 서비스에서 제외될 수 있음을 알려드립니다.

안녕하세요.
SteemitKorea팀에서 제공하는 'steemit-enhancer'를 사용해 주셔서 감사합니다. 개선 사항이 있으면 언제나 저에게 연락을 주시면 되고, 관심이 있으신 분들은 https://cafe.naver.com/steemitkorea/425 에서 받아보실 수 있습니다. 사용시 @응원해 가 포함이 되며, 악용시에는 모든 서비스에서 제외될 수 있음을 알려드립니다.

안녕하세요.
SteemitKorea팀에서 제공하는 'steemit-enhancer'를 사용해 주셔서 감사합니다. 개선 사항이 있으면 언제나 저에게 연락을 주시면 되고, 관심이 있으신 분들은 https://cafe.naver.com/steemitkorea/425 에서 받아보실 수 있습니다. 사용시 @응원해 가 포함이 되며, 악용시에는 모든 서비스에서 제외될 수 있음을 알려드립니다.

Coin Marketplace

STEEM 0.04
TRX 0.33
JST 0.099
BTC 62546.27
ETH 1774.38
USDT 1.00
SBD 0.38