Skip to content

Threads Media Data Source

Use the threads-media data source to fetch media from a Threads public account.

Usage

Add it to your enpage.config.js file

javascript
import { defineDataSources } from "@enpage/sdk/datasources";

export const datasources = defineDataSources({
  // Define a data source named "mymedia" using the "threads-media" provider
  mymedia: {
    // Label of the data source that will be displayed in the Enpage Editor
    name: "Threads Media",
    // use the "threads-media" provider
    provider: "threads-media",
    options: {
      // Number of media items to fetch
      limit: 10
    }
  }
});

Schema

Note

The schema displayed below is for reference only. It does not need to be included in your project.

ts
import { Type, type Static } from "@sinclair/typebox";

export const threadsMediaSchema = Type.Object({
  data: Type.Array(
    Type.Object({
      id: Type.String(),
      media_product_type: Type.Literal("THREADS"),
      media_type: Type.Union([
        Type.Literal("TEXT_POST"),
        Type.Literal("IMAGE"),
        Type.Literal("VIDEO"),
        Type.Literal("CAROUSEL_ALBUM"),
        Type.Literal("AUDIO"),
        Type.Literal("REPOST_FACADE"),
      ]),
      media_url: Type.String(),
      permalink: Type.String(),
      owner: Type.Object({
        id: Type.String(),
      }),
      username: Type.String(),
      text: Type.String(),
      timestamp: Type.String(),
      thumbnail_url: Type.String(),
      shortcode: Type.String(),
      is_quote_post: Type.Boolean(),
    }),
  ),
  paging: Type.Object({
    cursors: Type.Object({
      before: Type.String(),
      after: Type.String(),
    }),
  }),
});

export type ThreadsMediaSchema = Static<typeof threadsMediaSchema>;

Enpage SDK is released under AGPL-3.0 license