h3poteto / megalodon

Fediverse API client library for node.js and browser
https://h3poteto.github.io/megalodon/
MIT License
249 stars 30 forks source link

Add example for retrieving an account's own statuses #1905

Open ndarilek opened 1 year ago

ndarilek commented 1 year ago

Hey, sorry if this is included somewhere and I missed it. I'm trying to use this library to download my own statuses from Friendica and output a compatible outbox to import into Firefish. I'm not immediately clear how to get my own statuses. I don't think any of the timeline methods do that (E.g. home/local/public timelines, though I'm not entirely clear on what the public timeline is and how it differs from the local timeline.) There are methods to get account statuses but I don't see a way to get my own account ID. Am I missing something obvious?

Thanks.

h3poteto commented 1 year ago

Please use verifyAccountCredentials: https://github.com/h3poteto/megalodon/blob/d58c7d66938a4e0d5934fc9797fa667457868e74/megalodon/src/megalodon.ts#L121

Ryuno-Ki commented 2 weeks ago

I was solving this very problem today :) Using GoToSocial this is the gist (for @andre@fedi.jaenis.ch, i.e. acct andre):

import generator from 'megalodon'

const BASE_URL = process.env.GOTOSOCIAL_URL
const access_token = process.env.GOTOSOCIAL_ACCESS_TOKEN
const client = new generator.Gotosocial(BASE_URL, access_token)
const account = await client.lookupAccount('andre');
const statuses = await client.getAccountStatuses(account.data.id, {
  exclude_reblogs: true,
  exclude_replies: true,
  limit: 10
});

You might need to tweak the options to fit your use case.