# apithreads

> Unofficial, Reverse-Engineered Node.js/TypeScript client for Meta's [Threads](https://threads.net).

Latest version **1.0.5** (published 2023-07-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install apithreads
pnpm add apithreads
yarn add apithreads
bun add apithreads
```

Provides the command `apithreads`.

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2023-07-12 |
| First published | 2023-07-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=14 |
| Dependencies | 5 |
| Unpacked size | 51.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Viraj Bhartiya |
| Maintainers | heyxviraj |
| Keywords | threads, instagram, facebook, meta, api, threads-api |

## Links

- npm: https://www.npmjs.com/package/apithreads
- Repository: https://github.com/virajbhartiya/apithreads
- Homepage: https://virajbhartiya.github.io/projects/apithreads.html
- Issues: https://github.com/virajbhartiya/apithreads/issues
- npm.io page: https://npm.io/package/apithreads

## Dependencies (5)

- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [axios](https://npm.io/package/axios.md) ^1.4.0
- [@swc/cli](https://npm.io/package/@swc/cli.md) ^0.1.62
- [@swc/core](https://npm.io/package/@swc/core.md) ^1.3.68
- [mime-types](https://npm.io/package/mime-types.md) ^2.1.35

## Recent versions

- 1.0.5 (latest) — 2023-07-12
- 1.0.4 — 2023-07-12
- 1.0.3 — 2023-07-12
- 1.0.2 — 2023-07-12
- 1.0.1 — 2023-07-12

## README

# Threads API

[![NPM](https://img.shields.io/npm/v/apithreads.svg?style=flat-square&labelColor=black)](https://www.npmjs.com/package/apithreads) [![MIT License](https://img.shields.io/badge/license-MIT-blue?style=flat-square&labelColor=black)](https://github.com/junhoyeo/apithreads/blob/main/LICENSE) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg?style=flat-square&labelColor=black)](https://prettier.io)

Unofficial, Reverse-Engineered Node.js/TypeScript client for Meta's [Threads](https://threads.net).

<summary><h3>🚀 Usage (Read)</h3></summary>

```ts
import { ThreadsAPI } from "apithreads";

// or in Deno 🦖:
// import ThreadsAPI from "npm:apithreads";

const main = async () => {
  const threadsAPI = new ThreadsAPI();

  const username = "heyxviraj";

  // 👤 Details for a specific user
  const userID = await threadsAPI.getUserIDfromUsername(username);
  if (!userID) {
    return;
  }
  const user = await threadsAPI.getUserProfile(username, userID);
  console.log(JSON.stringify(user));
  const posts = await threadsAPI.getUserProfileThreads(username, userID);
  console.log(JSON.stringify(posts));
  const replies = await threadsAPI.getUserProfileReplies(username, userID);
  console.log(JSON.stringify(replies));

  // 📖 Details for a specific thread
  const postID = await threadsAPI.getPostIDfromURL("[THREAD_URL]");
  if (!postID) {
    return;
  }
  const post = await threadsAPI.getThreads(postID);
  console.log(JSON.stringify(post.containing_thread));
  console.log(JSON.stringify(post.reply_threads));

  const likers = await threadsAPI.getThreadLikers(postID);
  console.log(JSON.stringify(likers));
};
main();
```

### 🚀 Usage (Write)

#### ✨ Text Threads

```ts
import { ThreadsAPI } from "apithreads";

const main = async () => {
  const threadsAPI = new ThreadsAPI({
    username: "heyxviraj", // Your username
    password: "PASSWORD", // Your password
  });

  await threadsAPI.publish({
    text: "🤖 Hello World",
  });
};

main();
```

#### ✨ Threads with Image

```ts
await threadsAPI.publish({
  text: "🤖 Threads with Image",
  image: "[LINK_TO_IMAGE].jpg",
});
```

#### ✨ Threads with Link Attachment

```ts
await threadsAPI.publish({
  text: "🤖 Threads with Link Attachment",
  url: "https://github.com/virajbhartiya/apithreads",
});
```

#### ✨ Reply to Other Threads

```ts
const parentURL = "https://www.threads.net/t/[THREAD_ID]";
const parentPostID = await threadsAPI.getPostIDfromURL(parentURL); // or use `getPostIDfromThreadID`

await threadsAPI.publish({
  text: "🤖 Beep",
  link: "https://github.com/virajbhartiya/apithreads",
  parentPostID: parentPostID,
});
```

#### ✨ Like/Unlike a Thread

```ts
const threadURL = "https://www.threads.net/t/[THREAD_ID]";
const postIDToLike = await threadsAPI.getPostIDfromURL(threadURL); // or use `getPostIDfromThreadID`

// 💡 Uses current credentials
await threadsAPI.like(postIDToLike);
await threadsAPI.unlike(postIDToLike);
```

#### ✨ Follow/Unfollow a User

```ts
const userIDToFollow = await threadsAPI.getUserIDfromUsername("heyxviraj");

// 💡 Uses current credentials
await threadsAPI.follow(userIDToFollow);
await threadsAPI.unfollow(userIDToFollow);
```

## Installation

```bash
yarn add apithreads
# or with npm
npm install apithreads
# or with pnpm
pnpm install apithreads
```

```typescript
// or in Deno 🦖
import ThreadsAPI from "npm:apithreads";

const threadsAPI = new ThreadsAPI.ThreadsAPI({});
```

---
_Source: https://npm.io/package/apithreads · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
