Skip to content

Can I use API to retrieve a single bluesky post that I specify? #1169

Answered by myConsciousness
e1blue asked this question in Q&A
Discussion options

You must be logged in to vote

@e1blue

The Bluesky API does not provide an endpoint to get only a specific single post. But instead, we can use an endpoint that gets multiple posts as follows:

import 'package:bluesky/bluesky.dart';

Future<void> main() async {
  final session = await createSession(
    service: 'SERVICE_NAME',
    identifier: 'YOUR_HANDLE_OR_EMAIL',
    password: 'YOUR_PASSWORD',
  );

  final bsky = Bluesky.fromSession(session.data);

  // Just get only a specific single post
  final posts = await bsky.feed.getPosts(uris: [
    AtUri('at://did:plc:iijrtk7ocored6zuziwmqq3c/app.bsky.feed.post/3khvrjf2c7v25'),
  ]);

  print(posts.data.posts.first); // And access like this
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@e1blue
Comment options

Answer selected by e1blue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants