Friendly Correios SRO API wrapper and command-line utility
📦🔍 Friendly Correios SRO API wrapper and command-line utility.
npm install sro
import { track } from 'sro'
const [items, failures] = await track('TE123456789BR')
If installed globally using the npm -g
flag, SRO can also be invoked from the command-line:
$ sro
Usage: sro [options] <numbers...>
Options:
-V, --version output the version number
-o, --output <format> specify the output format (table|json|pretty) [table] (default: "table")
-c, --check check tracking number check digit (default: false)
-h, --help display help for command
track(numbers, options?): Promise<[items, failures]>
Tracks a collection of tracking numbers.
numbers
(String|Array) - Tracking number or array of tracking numbers to be tracked.options
(Object) - Optional tracking options:checkDigit
(Boolean) - Whether to validate the tracking number check digitonProgress(progress, item)
(Function) - Callback function called for each number once its data has been retrieved. progress
is a float number between 0 and 1. item
is the item object. Invalid tracking numbers are filtered before any requests are made, so they will not be passed here.[items, failures]
(Array)
items
(Array) - Item objects.failures
(Array) - Objects containing the tracking numbers that did not pass validation.validate(number, options?): [passes, failures]
Validates a collection of tracking numbers.
numbers
(String|Array) - Tracking number or array of tracking numbers to be validatedoptions
(Object) - Optional tracking options:checkDigit
(Boolean) - Whether to validate the tracking number check digit[passes, failures]
(Array)
passes
(Array) - Objects containing the tracking numbers that passed validation.failures
(Array) - Objects containing the tracking numbers that did not pass validation.