Skip to content

Instantly share code, notes, and snippets.

@dewomser
Created November 3, 2025 11:12
Show Gist options
  • Select an option

  • Save dewomser/9f57259c555bdc2be7ab139cf33af54d to your computer and use it in GitHub Desktop.

Select an option

Save dewomser/9f57259c555bdc2be7ab139cf33af54d to your computer and use it in GitHub Desktop.
Mastodon Toots API . No Token needed, Read own Posts and Media , Javascript Example: https://www.untergang.de/index.php/dewomser-auf-mastodon
<div id="statuses"></div>
<script>
  
    fetch('https://dein.masto-dingsbums.org/api/v1/accounts/<yournumber>/statuses')
      .then(response => response.json())
      .then(data => {
        const container = document.getElementById('statuses');
        data.forEach(status => {
          // Display status content (it's HTML)
          const contentDiv = document.createElement('div');
          contentDiv.innerHTML = status.content;
          // Display images if they exist
          if (status.media_attachments && status.media_attachments.length > 0) {
            status.media_attachments.forEach(media => {
              if (media.type === "image" && media.url) {
                const img = document.createElement('img');
                img.src = media.url;
                img.style.maxWidth = "300px";
                img.style.display = "block";
                contentDiv.appendChild(img);
              }
            });
          }
          container.appendChild(contentDiv);
          // Add a horizontal line after each status
          const hr = document.createElement('hr');
          container.appendChild(hr);
        });
      });
  </script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment