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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tabua-mare-sdk

v1.0.4-6b9e3dd

Published

SDK JavaScript/TypeScript para a API Tábua de Marés do Brasil

Readme

Tábua de Marés SDK - JavaScript/TypeScript

SDK JavaScript/TypeScript para integração com a API Tábua de Marés do Brasil.

Sobre o Projeto

Este SDK faz parte do ecossistema Tábua da Maré:

Para mais informações, acesse: tabuamare.devtu.qzz.io

Características

  • ✅ Funciona em Node.js e Browser
  • ✅ Suporte completo a TypeScript
  • ✅ Zero dependências
  • ✅ API simples e intuitiva
  • ✅ Totalmente tipado

Instalação

Via NPM/Yarn/PNPM/Bun

# NPM
npm install tabua-mare-sdk

# Yarn
yarn add tabua-mare-sdk

# PNPM
pnpm add tabua-mare-sdk

# Bun
bun add tabua-mare-sdk

Via CDN

<!-- unpkg -->
<script src="https://unpkg.com/tabua-mare-sdk/src/index.js"></script>

<!-- unpkg (minificado) -->
<script src="https://unpkg.com/tabua-mare-sdk/src/index.min.js"></script>

<!-- jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/tabua-mare-sdk/src/index.js"></script>

<!-- jsDelivr (minificado) -->
<script src="https://cdn.jsdelivr.net/npm/tabua-mare-sdk/src/index.min.js"></script>

<!-- Uso -->
<script>
  const client = new TabuaMareClient();
  client.getStates().then(data => console.log(data));
</script>

Cópia Direta

Ou copie o arquivo src/index.js diretamente para seu projeto.

Uso

Node.js (ES Modules - Recomendado)

import { TabuaMareClient } from 'tabua-mare-sdk';

console.log('📘 Exemplo de uso do Tabua Mare SDK\n');

const client = new TabuaMareClient();

async function exemploCompleto() {
  try {
    // 1. Listar todos os estados disponíveis
    console.log('1️⃣  Buscando estados...');
    const states = await client.getStates();
    console.log('   Estados:', states);

    // 2. Listar portos de Santa Catarina
    console.log('\n2️⃣  Buscando portos de SC...');
    const harbors = await client.getHarborsByState('sc');
    console.log('   Portos:', harbors);

    // 3. Obter detalhes de um porto
    if (harbors && harbors.length > 0) {
      const harborId = harbors[0].id;
      console.log(`\n3️⃣  Buscando detalhes do porto ${harborId}...`);
      const harbor = await client.getHarbors(harborId);
      console.log('   Detalhes:', harbor);
    }

    // 4. Obter tábua de maré do mês atual
    const now = new Date();
    const month = now.getMonth() + 1;
    console.log(`\n4️⃣  Buscando tábua de maré do mês ${month}...`);
    const tabuaMare = await client.getTabuaMareMonth(1, month);
    console.log('   Tábua de Maré:', tabuaMare);

    // 5. Obter porto mais próximo de coordenadas
    console.log('\n5️⃣  Buscando porto mais próximo de Florianópolis...');
    const nearestHarbor = await client.getNearestHarbor(-27.5954, -48.5480);
    console.log('   Porto mais próximo:', nearestHarbor);

  } catch (error) {
    console.error('\n❌ Erro na execução:', error.message);
    console.error('   Detalhes:', error);
    
    if (error.message.includes('502')) {
      console.log('\n⚠️  A API está temporariamente indisponível (erro 502).');
      console.log('   Isso pode acontecer se o servidor estiver em manutenção.');
    }
  }
}

exemploCompleto();

Node.js (CommonJS)

const { TabuaMareClient } = require('tabua-mare-sdk');

const client = new TabuaMareClient();

// Usando async/await
async function exemplo() {
  const states = await client.getStates();
  console.log('Estados:', states);
}

exemplo();

// Ou usando .then()
client.getStates().then(data => {
  console.log('Estados:', data);
});

CDN (Browser)

<!DOCTYPE html>
<html>
<head>
  <title>Tábua de Marés</title>
</head>
<body>
  <script src="https://unpkg.com/tabua-mare-sdk/src/index.js"></script>
  <script>
    const client = new TabuaMareClient();
    
    client.getStates().then(data => {
      console.log('Estados:', data);
    }).catch(error => {
      console.error('Erro:', error);
    });
  </script>
</body>
</html>

TypeScript

import { TabuaMareClient } from 'tabua-mare-sdk';

(async () => {
  const client = new TabuaMareClient();

  try {
    console.log('1️⃣  getStates()');
    const states = await client.getStates();
    console.log(JSON.stringify(states, null, 2));
    console.log('\n───────────────────────────────────────\n');

    console.log('2️⃣  getHarborsByState("sc")');
    const harbors = await client.getHarborsByState('sc');
    console.log(JSON.stringify(harbors, null, 2));
    console.log('\n───────────────────────────────────────\n');

    console.log('3️⃣  getHarbors(1)');
    const harbor = await client.getHarbors(1);
    console.log(JSON.stringify(harbor, null, 2));
    console.log('\n───────────────────────────────────────\n');

    console.log('4️⃣  getTabuaMare(1, 1, [1, 2, 3])');
    const tabuaMare = await client.getTabuaMare(1, 1, [1, 2, 3]);
    console.log(JSON.stringify(tabuaMare, null, 2));
    console.log('\n───────────────────────────────────────\n');

    console.log('5️⃣  getTabuaMareMonth(1, 1)');
    const tabuaMareMonth = await client.getTabuaMareMonth(1, 1);
    console.log(JSON.stringify(tabuaMareMonth, null, 2));
    console.log('\n───────────────────────────────────────\n');

    console.log('6️⃣  getNearestHarbor(-27.5954, -48.5480)');
    const nearestHarbor = await client.getNearestHarbor(-27.5954, -48.5480);
    console.log(JSON.stringify(nearestHarbor, null, 2));

  } catch (error) {
    console.error('❌ Erro:', error);
  }
})()