npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tabnews-sdk

v1.0.1

Published

Node.js library to interact with TabNews API

Readme

TabNews SDK

CI Coverage Quality Gate Status Bugs Code Smells Vulnerabilities

Esse projeto foi criado com o intuito de fornecer uma interface amigável de intergração com o tabnews

Sumário

Instalação

Para começar a usar o tabnews-sdk dentro do seu projeto basta instalar com o seu gerenciador de pacotes favorito

npm install tabnews-sdk
yarn add tabnews-sdk
pnpm add tabnews-sdk

Exemplos

Para iniciar o cliente do basta instanciar a classe TabNews, as credencias são opcionais, mas podem ser setadas por um arquivo .env ou direto no código conforme abaixo

TabNews

Instanciar sem credentials

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

Instanciar com credentials no arquivo .env

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();
TABNEWS_CREDENTIALS_EMAIL=<seu email>
TABNEWS_CREDENTIALS_PASSWORD=<sua senha>

Instanciar com credentials no código

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews({
  credentials: {
    email: '<seu email>',
    password: '<sua senha>',
  },
});

Sessão

A sessão tem dois métodos create e destroy, após a criação da sessão a biblioteca ira gerenciar automaticamente a sessão criando uma nova quando houver expiração do token, caso deseje consultar a api sem uma sessão apenas não chame o método create, contudo algumas rotas gerarão erros por falta de permissão

Exemplo com sessão gerenciada

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const session = await tabNews.session.create(); // sessão criada

const contents = await tabNews.contents.getAll();

await tabNews.session.destroy(); // sessão destruida

Exemplo com sessão não gerenciada

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const { contents } = await tabNews.contents.getAll();

Usuário

A api de usuários permite que buscar dados do usuário logado, atualizar e listar.

Buscar usuário logado

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

await tabNews.session.create();

const user = await tabNews.user.me();

Conteúdos

A api conteúdos permite listar todos os posts/comentários dentro do tabnews, alguns dos exemplos de como interagir com essa api está abaixo:

Buscar Conteúdos

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const { pagination, contents } = await tabNews.contents.getAll();

Buscar Conteúdos Paginados

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const { pagination, contents } = await tabNews.contents.getAll({
  page: 1,
  per_page: 30,
  strategy: 'relevant',
});
import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const { pagination, contents } = await tabNews.contents.getAll({
  page: 2,
  per_page: 50,
  strategy: 'relevant',
});

const prevContents = await tabNews.contents.getAll({
  page: pagination.previous_page,
  per_page: 50,
  strategy: 'relevant',
});

const nextContents = await tabNews.contents.getAll({
  page: pagination.next_page,
  per_page: 50,
  strategy: 'relevant',
});

Buscar Conteúdos de um Usuário

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const { pagination, contents } = await tabNews.contents.getAll({
  username: '<any_username>',
  page: 1,
  per_page: 30,
  strategy: 'relevant',
});

Buscar Conteúdos para o Usuário atual

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

await tabNews.session.create();

const { pagination, contents } = await tabNews.contents.getMy({
  page: 1,
  per_page: 30,
  strategy: 'relevant',
});

Buscar Detalhe do Conteúdo

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const content = await tabNews.contents.getBySlug({
  slug: '<slug>',
  username: '<username>',
});
import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

await tabNews.session.create();

// Não é preciso passar o username pois internamente a bliblioteca ira realizar o fecth do usuario atual

const content = await tabNews.contents.getBySlug({
  slug: '<slug>',
});

Buscar Comentarios do Conteúdo

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const contentChildren = await tabNews.contents.getChildren({
  slug: '<slug>',
  username: '<username>',
});
import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

await tabNews.session.create();

// Não é preciso passar o username pois internamente a bliblioteca ira realizar o fecth do usuario atual

const contentChildren = await tabNews.contents.getChildren({
  slug: '<slug>',
});

Buscar Conteúdo Pai

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const parentContent = await tabNews.contents.getParent({
  slug: '<slug>',
  username: '<username>',
});
import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

await tabNews.session.create();

// Não é preciso passar o username pois internamente a bliblioteca ira realizar o fecth do usuario atual

const parentContent = await tabNews.contents.getParent({
  slug: '<slug>',
});

Buscar Conteúdo Raiz

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const rootContent = await tabNews.contents.getRoot({
  slug: '<slug>',
  username: '<username>',
});
import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

await tabNews.session.create();

// Não é preciso passar o username pois internamente a bliblioteca ira realizar o fecth do usuario atual

const rootContent = await tabNews.contents.getRoot({
  slug: '<slug>',
});

Up or Down Vote Conteúdo

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const tabcoins1 = await tabNews.contents.tabcoins({
  slug: '<slug>',
  username: '<username>',
  transaction_type: 'credit',
});

// or

const tabcoins2 = await tabNews.contents.upVote({
  slug: '<slug>',
  username: '<username>',
});
import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

await tabNews.session.create();

// Não é preciso passar o username pois internamente a bliblioteca ira realizar o fecth do usuario atual

const tabcoins1 = await tabNews.contents.tabcoins({
  slug: '<slug>',
  username: '<username>',
  transaction_type: 'debit',
});

// or

const tabcoins2 = await tabNews.contents.downVote({
  slug: '<slug>',
  username: '<username>',
});

Criar Conteúdo

Na rota de criação de conteúdos, todos os campos são opcionais exceto o body, que é o seu post ou comentario, e o title que é opcional apenas quando há um parent_id

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

await tabNews.session.create();

const response = await tabNews.contents.create({
  parent_id: undefined,
  slug: 'e-opcional',
  title: 'test',
  body: 'test',
  status: 'published',
  source_url: 'https://google.com',
});
import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const { contents } = await tabNews.contents.getAll();

await tabNews.session.create();

const response = await tabNews.contents.create({
  parent_id: contents[0].id,
  body: 'comentando em um conteúdo',
  status: 'published',
});

Atualizar Conteúdo

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const content = await tabNews.contents.update({
  slug: '<slug>',
  username: '<username>',
  title: 'title',
  body: 'body',
  status: 'published',
  source_url: 'https://some.url',
});
import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

await tabNews.session.create();

// Não é preciso passar o username pois internamente a bliblioteca ira realizar o fecth do usuario atual

const content = await tabNews.contents.update({
  slug: '<slug>',
  title: 'title',
  body: 'body',
  status: 'published',
  source_url: 'https://some.url',
});

Deletar Conteúdo

import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

const content = await tabNews.contents.delete({
  slug: '<slug>',
  username: '<username>',
});
import { TabNews } from 'tabnews-sdk';

const tabNews = new TabNews();

await tabNews.session.create();

// Não é preciso passar o username pois internamente a bliblioteca ira realizar o fecth do usuario atual

const content = await tabNews.contents.delete({
  slug: '<slug>',
});