fadiinho / tabnews-api-wrapper

Um wrapper pra API do TabNews

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TabNews API Wrapper

Todos os endpoints e seus respectivos parâmetros podem ser encontrados aqui

Uso

Instancie a classe da API

import { TabnewsApi } from "tabnews-api";
// ou
const { TabnewsApi } = require("tabnews-api");

const api = new TabnewsApi();

Conteúdo

Listar os posts da página inicial

// 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

Listar os posts de um determinado usuário

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;
}[]

Buscar os detalhes de um post, incluindo corpo do post

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;
}[]

Buscar os comentários de um post

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;
}[]

Buscar a thumbnail de um post

const postThumbnail = await api.getPostThumbnail("<username>", "<slug>");

Retorna um Buffer

TODO: Criação de posts

Analytics

Buscar quantos usuários foram criados por dia

const postComments = await api.userAnalytics();
Interface de Resposta
interface UsersCreatedStatus {
    /**
     * Date in the format dd/mm
     */
    date: string;
    cadastrados: number;
}[]

Buscar quantos posts (root content) foram criados por dia

const postComments = await api.postAnalytics();
Interface de Resposta
interface RootContentPublishedStatus {
    /**
     * Date in the format dd/mm
     */
    date: string;
    conteudos: number;
}[]

Buscar quantos comentários (child content) foram criados por dia

const postComments = await api.commentsAnalytics();
Interface de Resposta
interface ChildContentPublishedStatus {
    /**
     * Date in the format dd/mm
     */
    date: string;
    respostas: number;
}[]

Autenticação

TODO :)

About

Um wrapper pra API do TabNews

License:GNU General Public License v3.0


Languages

Language:TypeScript 100.0%