This META Threads API allows the developer to easily pull and manipulate profile information from any Threads profile.
The API also includes AI capability that allows the developer to parse a profile into very readable OSINT information as well as pull out pertinent information from an infinite number of posts.
A demo video is located here: https://youtu.be/55a9mEaP-ao
'Selenium' is used in this package. Please ensure you have Chrome installed, if you do not want to install Chrome, you can adjust the API code to use a web driver executable. The code to adjust would be located in 'threads_api.py' under the getSoup function.
Please execute the following pip installs:
pip install beautifulsoup4
pip install selenium
pip install openaiIn order to use AI functions, you will need to get an OpenAI API Key as well as an OpenAI organization identifier. Although AI is not a requirement to use this package.
- AI credentials are no longer a required parameter. Use api.openAIOrg="YOUR-ORG" and api.openAIKey="YOUR_KEY" to enable AI capability
- These values are required to use AI. An error will be returned if they are not set and api.usingAI is set to True
- api.replies() has been added, retrieve all replies from account
- api.replyLinks() has been added, retrieve all links from all replies on account
- Update pushed to github, developers can now retrieve the url of the account owners instagram account using 'api.linkedInstagram'
- Fixed 'api.name' issues. Only the name is now returned, rather than the entire title
- Update pushed to github, developers can now retrieve the numeric user_id variable from selected profiles using 'api.userId'
- Package published to github with described capability
- Initial package finalized and prepped for release
Step 1. Clone this repository and place the 'threads_api' package in your python project.
Step 2. Import the library into your project:
from threads_api import ThreadsApiStep 3. Initialize the API:
api = ThreadsApi('ANY-THREADS-USERNAME')Step 4. Set the following optional parameters:
NOTE: If you are not using openAI, disregard the openAI parameters and set api.usingAI=False
api.aiRequestType = 'osint.profile' # osint.character_prompt || osint.profile || osint.links || osint.mentions
api.openAIOrg = 'OPENAI-ORGANIZATION' # your OpenAI Api organization identifier
api.openAIKey = 'OPENAI-API-KEY' # your OpenAI Api Key
api.gptModel = 'gpt-4' # 'gpt-4' or 'gpt-3.5-turbo' recommended
api.maxPosts = 50 # max number of posts to scrape
api.pageLoadWaitTime = 3 # time to wait for page to load (change according to internet speed)
api.usingAI = True # set to False to completely skip AI functionality
api.statusPrintingEnabled = True # set to False to disable print statements from APIStep 5. Start the execution process:
api.start()Step 6. Retrieve and manipulate the API data:
print(api.aiResponse) # return AI request response
print(api.userId) # return numeric user_id of account
print(api.bio) # return users bio
print(api.name) # return users name
print(api.posts) # return posts in array format
print(api.links) # return links, also includes mentions
print(api.linkedInstagram) # return linked instagram account url
print(api.replies) # return all replies
print(api.replyLinks) # return all links contained in replies
print(api.followers) # return follower countFinal product should look like this:
from threads_api.threads_api import ThreadsApi
api = ThreadsApi('THREADS-USERNAME', 'OPENAI-ORGANIZATION', 'OPENAI-API-KEY')
api.aiRequestType = 'osint.profile' # osint.character_prompt || osint.profile || osint.links || osint.mentions
api.gptModel = 'gpt-4' # 'gpt-4' or 'gpt-3.5-turbo' recommended
api.maxPosts = 50 # max number of posts to scrape
api.pageLoadWaitTime = 3 # time to wait for page to load (change according to internet speed)
api.usingAI = True # set to False to completely skip AI functionality
api.statusPrintingEnabled = True # set to False to disable print statements from API
api.start()
print(api.aiResponse) # return AI request response
print(api.bio) # return users bio
print(api.name) # return users name
print(api.posts) # return posts in array format
print(api.links) # return links, also includes mentions
print(api.linkedInstagram) # return linked instagram account url
print(api.replies) # return all replies
print(api.replyLinks) # return all links contained in replies
print(api.followers) # return follower countIt should be mentioned that if the Selenium driver fails to pull profile data, you can do a few things to fix it. You can either increase the pageLoadWaitTime variable or edit the 'tag_references.py' and ensure they point to the correct paths.