Todos os endpoints e seus respectivos parâmetros podem ser encontrados aqui
Instancie a classe da API
import { TabnewsApi } from "tabnews-api";
// ou
const { TabnewsApi } = require("tabnews-api");
const api = new TabnewsApi();
// Todos os parâmetros são opcionais
const posts = await api.getPosts({
page: 1,
per_page: 2,
strategy: "new",
});
Interface de Resposta
Content {
id: string;
parent_id: string | null;
owner_id: string;
slug: string;
title: string | null;
status: 'published' | 'draft';
source_url: string | null;
created_at: Date;
updated_at: Date;
published_at: Date;
deleted_at: Date | null;
tabcoins: number;
owner_username: string;
children_deep_count: number;
}[]
Nota: Os posts da página inicial não contêm
body
const userPosts = await api.getPostsByUser("<username>", {
page: 1,
per_page: 2,
strategy: "new",
});
Interface de Resposta
Content {
id: string;
parent_id: string | null;
owner_id: string;
slug: string;
body?: string;
title: string | null;
status: 'published' | 'draft';
source_url: string | null;
created_at: Date;
updated_at: Date;
published_at: Date;
deleted_at: Date | null;
tabcoins: number;
owner_username: string;
children_deep_count: number;
}[]
const posts = await api.getPostDetails("<username>", "<slug>");
Interface de Resposta
Content {
id: string;
parent_id: string | null;
owner_id: string;
slug: string;
body?: string;
title: string | null;
status: 'published' | 'draft';
source_url: string | null;
created_at: Date;
updated_at: Date;
published_at: Date;
deleted_at: Date | null;
tabcoins: number;
owner_username: string;
children_deep_count: number;
}[]
const postComments = await api.getPostComments("<username>", "<slug>");
Interface de Resposta
Content {
id: string;
parent_id: string | null;
owner_id: string;
slug: string;
body?: string;
title: string | null;
status: 'published' | 'draft';
source_url: string | null;
created_at: Date;
updated_at: Date;
published_at: Date;
deleted_at: Date | null;
tabcoins: number;
owner_username: string;
children_deep_count: number;
}[]
const postThumbnail = await api.getPostThumbnail("<username>", "<slug>");
Retorna um Buffer
TODO: Criação de posts
const postComments = await api.userAnalytics();
Interface de Resposta
interface UsersCreatedStatus {
/**
* Date in the format dd/mm
*/
date: string;
cadastrados: number;
}[]
const postComments = await api.postAnalytics();
Interface de Resposta
interface RootContentPublishedStatus {
/**
* Date in the format dd/mm
*/
date: string;
conteudos: number;
}[]
const postComments = await api.commentsAnalytics();
Interface de Resposta
interface ChildContentPublishedStatus {
/**
* Date in the format dd/mm
*/
date: string;
respostas: number;
}[]
TODO :)