Closed yekayee closed 12 months ago
Hey!
Yes, after install this library you have to call the get_user_threads()
function in your code and replace the username for the username that you want to get posts.
Here you have an example (Remember replace the username):
from threads_api.src.threads_api import ThreadsAPI
import asyncio
import os
# Asynchronously gets the threads for a user
async def get_user_threads():
api = ThreadsAPI()
username = "YOUR-USERNAME"
user_id = await api.get_user_id_from_username(username)
if user_id:
threads = await api.get_user_threads(user_id)
print(f"The threads for user '{username}' are:")
for thread in threads:
print(f"{username}'s Post: {thread['thread_items'][0]['post']['caption']} || Likes: {thread['thread_items'][0]['post']['like_count']}")
else:
print(f"User ID not found for username '{username}'")
asyncio.run(get_user_threads())
If you wanna explore more functions, please review this example file.
can get post from user specify?