chatgpt-share-parser
v0.1.1
Published
Typescript ChatGPT shared conversation link parser
Downloads
192
Maintainers
Readme
chatgpt-share-parser
Typescript ChatGPT shared conversation link parser.
This is a small TypeScript module ported from ChatPeek for use in JavaScript and TypeScript projects.
Install
pnpm add chatgpt-share-parserUsage
import {
chatGptShareToMarkdown,
fetchChatGptShare,
parseChatGptShareHtml,
} from "chatgpt-share-parser";
const chat = await fetchChatGptShare(
"https://chatgpt.com/share/your-public-share-id",
);
console.log(chat.title);
console.log(chat.replies.length);
console.log(chatGptShareToMarkdown(chat));If you already have the HTML, parse it directly:
const chat = parseChatGptShareHtml(html);API
fetchChatGptShare(url)fetches and parses a public ChatGPT share URL.fetchChatGptShareHtml(url)fetches the raw share HTML with browser-like headers.parseChatGptShareHtml(html)parses modern React Flight shares and falls back to legacy__NEXT_DATA__shares.chatGptShareToMarkdown(chat)renders a parsed conversation to Markdown.getChatGptShareId(url)extracts a share id fromchatgpt.com/share/...orchat.openai.com/share/....isChatGptShareUrl(url)returns whether a URL is a supported public share URL.
Parsed Shape
fetchChatGptShare() and parseChatGptShareHtml() return:
type ChatGptShareConversation = {
shareId: string;
aiModel: string;
title: string;
updatedAt: number | null;
replies: ChatGptShareReply[];
};
type ChatGptShareReply = {
authorName: string;
type: "user" | "assistant" | "tool";
statement: string;
createdAt: number | null;
assets: ChatGptShareAsset[];
};
type ChatGptShareAsset = {
assetType: "image" | "file";
url: string;
filename: string;
description: string | null;
downloadable: boolean;
};Timestamps are Unix seconds from the shared conversation payload when present.
Notes
This library is intended for personal exports of public ChatGPT shared conversations. It does not access private chats or authenticated APIs.
License
MIT
