thread.js is a Node.js library that allows you to interact with the Threads API
- Object-oriented
- Performant
- Authenticated
- 100% coverage
npm install @threadsjs/threads.js
const { Client } = require('@threadsjs/threads.js');
(async () => {
const client = new Client();
// You can also specify a token: const client = new Client({ token: 'token' });
await client.login('username', 'password');
await client.users.fetch('25025320').then(user => {
console.log(user);
});
})();
In the parameters, pass the userId of the user whose information you want to get.
await client.users.fetch("1")
Pass the userId of the user you want to subscribe to in the parameters
await client.users.follow("1")
Pass the query as the first parameter, and the number of objects in the response as the second parameter (by default - 30)
await client.users.search("zuck", "10")
In the parameters, pass the userId of the user whose followers you want to get.
await client.users.followers("1")
In the parameters, pass the userId of the user whose followings you want to get.
await client.users.following("1")
In the parameters, pass the userId of the user whose threads you want to get.
await client.feeds.fetchThreads("1")
In the parameters, pass the userId of the user whose replies you want to get.
await client.feeds.fetchReplies("1")
Getting a list of recommendations.
await client.feeds.recommended()
In the parameters pass the id of the post you want to get information about
await client.posts.fetch("aAaAAAaaa")
In the parameters pass the id of the post whose likes you want to get
await client.posts.likers("aAaAAAaaa")
The method is used to create a thread. Pass the text of the thread as the first parameter, and the user id as the second
await client.posts.create("Hello world!", "1")
The method is used to create reply to a thread. Pass the text of the reply as the first parameter, the user id as the second, and post id as the third
await client.posts.reply("Hello world!", "1", "aAaAAAaaa")
The method is used to delete a thread. Pass the post id as the first parameter, and the user id as the second
await client.posts.delete("aAaAAAaaa", "1")
The method is used to like a thread. Pass the post id as the first parameter, and the user id as the second
await client.posts.like("aAaAAAaaa", "1")