Show HN: ThreadsPipePy: Python Library for the Official Instagram Threads API

pypi.org

2 points by javacrusher 2 days ago

Introducing ThreadsPipePy, a open-source python library for interacting with the Threads API the easiest way, and it uses the official Meta's Threads API.

One of the coolest things about the library is that it will automatically split posts into a X(fka Twitter)-like thread-like post if the text content or the provided files are more than the limit, so one doesn't have to worry about trying to make the text or files meet the limit set by the API, for example if the length of the characters of the text content of the post is more than 500 which is the current limit, and for example 1500 characters, and instead of the post to be sent just like that to the Threads API and which will result in rejection, it will split the 1500 character-long text into different batches ( and in this scenerio 3-4 batches) and send them as a X(fka Twitter) thread-like post with the first batch being the root post, it also does the same thing for the provided files if they are more than 20 which is the current limit for the media files allowed in a post (carousel post).

Another cool thing is that you don't have to worry when posting files that are not on public servers because Threads makes it compulsory for the media files (or media items) to be on a public server, so it will first of all upload the local files to GitHub and then delete the files later after uploading the files or if an error occurred and could not send the post, it also supports posting base64 file formats.

It also comes with a CLI tool for generating short and long lived access tokens and also for refreshing long lived access tokens before they expire, and it can also automatically update the long lived variable in the provided env file.

It can also automatically handle hashtags, like for example if there are multiple hashtags at the end of a post it can automatically strip them out and add only the first one to the end of the post or at the end of each thread post items if the post was turned into a thread-like post, that's because Threads currently only supports 1 hashtag per post

And many other cool things, and it is up to date, and I currently use it for my Astronomy Bot account that posts astronomy contents to Threads, if you would like to see the library in action on Threads checkout @astronomybot on Threads

The link to the library on Pypi is https://pypi.org/project/threadspipepy/ and the link to the source code on GitHub is https://github.com/paulosabayomi/ThreadsPipe-py

Thank you and have a productive rest of the week