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 🙏

© 2024 – Pkg Stats / Ryan Hefner

rastrojs

v1.2.0

Published

Library for scraping Correios (Brazil) postal service and tracking orders.

Downloads

21

Readme

RastroJs

Uma biblioteca Nodejs para rastreamento de encomendas nos Correios.

Este projeto não é oficial dos Correios e apesar de se alimentar de um sistema web legítimo dos Correios este não realiza integrações com o webservice dos Correios.

Instalação - Exemplos - Respostas - Contribuição - Licença


Install

npm install --save rastrojs

Examples

import rastrojs, { RastroJS, Tracking } from 'rastrojs';

// By function
const tracksA = await rastrojs.track('JT124720455BR');
const tracksB = await rastrojs.track(['JT124720455BR', '123']);
const tracksC = await rastrojs.track('JT124720455BR', 'JT124720455BC', '123');


// Using classes
class MyDeliveries extends RastroJS {

    constructor(private codes: string[]) {
        super();
    }

    public get tracks(): Promise<Tracking[]> {
        return this.track(this.codes);
    }

}

const myDeliveries = new MyDeliveries(['JT124720455BR', 'JT124720455BC', '123']);
const tracks = await myDeliveries.tracks;

Para TypeScript, certifique-se de incluir "rastrojs" em "types" no tsconfig.json do seu projeto

Response

Fields

|Field|Type|Description|Exemple |-|-|-|-| |code|String|Código do objeto pesquisado|JT124720455BR |type|String|Tipo de enconenda segundo os Correios|Registrado Urgente |isDelivered|Boolean|Flag de entrega|true/false |postedAt|Date|Data da postagem do objeto|2021-12-22T21:15:00.000Z |updatedAt|Date|Data da última atualização do objeto|2022-01-07T17:18:00.000Z |tracks|Array| Lista de eventos registrados do objeto|- |tracks.locale|String|Local do evento|São Paulo / SP |tracks.status|String|Status do objeto segundo dos correios|Objeto postado |tracks.observation|String|Observações do evento registrado|De unidade X para ... |tracks.trackedAt|Date|Data do evento registrado|2022-01-03T14:26:00.000Z |error?|String|Mensagem de erro possível|service_unavailable* |isInvalid?|Boolean|Flag de resposta não esperada (erro)|true*

*. isInvalid e error só existem em casos de respostas de erro.

[
    {
        code: 'JT124720455BR',
        type: 'registrado urgente',
        isDelivered: true,
        postedAt: 2021-12-22T21:15:00.000Z,
        updatedAt: 2022-01-07T17:18:00.000Z,
        tracks: [
            /* ... */
            {
                locale: 'sao paulo / sp',
                status: 'objeto entregue ao destinatário',
                observation: null,
                trackedAt: 2022-01-07T17:18:00.000Z
            }
        ]
    },
    {
        code: 'JT124720455CH',
        error: 'not_found',
        isInvalid: true,
    },
    {
        code: 'JT124720455FR',
        error: 'service_unavailable',
        isInvalid: true,
    }
]

Errors

|Erro|Description |-|-| |invalid_code|O código informado não corresponde ao formato dos correios. |not_found|A encomenda não foi encontrada no serviços dos correios |service_unavailable|O serviço web dos correios estava indisponível no momento |internal_server_error|Ocorreu um erro interno no serviço web dos correios

Contribution

Veja como em: CONTRIBUTING.md - Qualquer dúvida ou sugestão: [email protected]

License

RastroJS é totalmente aberta e está sob licença MIT, use a vontade.