@buun_group/interparcel-api-sdk v1.7.0
Interparcel API Client
A TypeScript-based Node.js client for interacting with the Interparcel API.
Supports quoting, shipment creation, and parcel tracking.
โจ Features
- ๐ฆ Get shipping quotes (API v3)
- ๐ Create shipments (API v3)
- ๐ Track parcels (API v1)
- ๐ Built-in API key authentication
- ๐งช Unit tests with Jest
- ๐ก Written in TypeScript with full type safety
๐ Project Structure
interparcel-api-client/
โโโ src/
โ โโโ index.ts # Entry point exports all modules
โ โโโ quote/
โ โ โโโ getQuote.ts # Quote API logic (v3)
โ โ โโโ types.ts # Quote request/response types
โ โ โโโ index.ts # Index
โ โ โโโ __tests__/ # Unit tests for quotes
โ โโโ shipment/
โ โ โโโ createShipment.ts # Shipment creation logic (v3)
โ โ โโโ types.ts # Shipment request/response types
โ โ โโโ index.ts # Index
โ โ โโโ __tests__/ # Unit tests for shipment
โ โโโ tracking/
โ โโโ trackShipment.ts # Tracking endpoint logic (v1)
โ โโโ types.ts # Tracking request/response types
โ โโโ __tests__/ # Unit tests for tracking
โโโ dist/ # Compiled output
โโโ test/ # Global test setup/utils
โโโ .github/workflows/ci.yml # GitHub Actions CI workflow
โโโ .npmignore
โโโ .gitignore
โโโ tsconfig.json
โโโ jest.config.js
โโโ package.json
โโโ README.md๐ Installation
npm install @buun_group/interparcel-api-sdkSee the full usage guide: docs/getting-started.md
Optional: You can use the included
Makefileto run all checks and commands with simplemakecommands (requires GNU Make, standard on Linux/macOS, available for Windows via WSL or MinGW). For example:
make installโ install dependenciesmake buildโ build the projectmake testโ run testsmake lintโ lint codemake formatโ format codemake checkโ run lint, format check, build, and test in sequence
๐ Git Hooks with Husky
This project uses Husky to enforce code quality via Git hooks.
After installing dependencies, run the following command to enable Git hooks:
npx huskyThis will set up the following hooks:
- pre-commit: Runs lint and format check
npm run lint && npm run format-check - pre-push: Runs tests
npm test
If you skip this step, code quality checks will not run automatically before commits or pushes.
For more details, see the Husky documentation.
๐ฆ Usage
import {
getQuote,
trackParcel,
addShipment,
QuoteRequest,
} from '@buungroup/interparcel-api-sdk';
const apiKey = process.env.INTERPARCEL_API_KEY;
const quoteRequest: QuoteRequest = {
collection: {
city: 'Sydney',
postcode: '2000',
country: 'AU',
},
delivery: {
city: 'Melbourne',
postcode: '3000',
country: 'AU',
},
parcels: [
{
weight: 2,
length: 10,
width: 20,
height: 15,
},
],
};
const quote = await getQuote(apiKey, quoteRequest);
console.log(quote);๐ Documentation Links
- ๐ Get a Quote API
- ๐ Track Parcel API
- ๐ Add Shipment API
- ๐ Full Interparcel API Docs
๐ Environment Variables
Set your Interparcel API key in a .env.local file or export it in your environment:
INTERPARCEL_API_KEY=your_api_key_here๐งช Running Tests
npm testTest files are colocated in __tests__/ folders inside each module (quote, shipment, tracking).
Uses jest with axios mocking for API behavior simulation.
๐ Build
npm run buildCompiles TypeScript code into the dist/ directory.
๐งน Code Formatting & Linting
This project uses Prettier for code formatting and ESLint for linting. All code must be properly formatted and linted before submitting a PR.
- To check and fix linting issues:
npm run lint - To format code with Prettier:
npm run format - To check formatting without writing changes:
npm run format -- --check
The CI pipeline will fail if code is not properly linted or formatted.
๐ค CI/CD
This project includes a GitHub Actions workflow in .github/workflows/ci.yml that runs:
- Linting (
npm run lint) - Build (
npm run build) - Unit tests (
npm test) - Security audit (
npm audit --omit dev)
All workflows run on PRs and pushes to main.
๐ Dependencies
| Package | Purpose |
|---|---|
| axios | HTTP client for API requests |
| typescript | Type-safe development |
| jest | Testing framework |
| axios-mock-adapter | Mocking axios for unit tests |
| @types/node | Node.js type definitions |
| ts-jest | TypeScript support for Jest |
๐ค Contributing
- Fork the repository
- Create a branch (
git checkout -b feature/foo) - Commit changes (
git commit -am 'Add foo feature') - Push to GitHub (
git push origin feature/foo) - Create a Pull Request
Please lint and format TypeScript code before submitting a PR.
๐ค Authors
Created by Buun Group Lead Developer: Sacha Roussakis-Notter
โ ๏ธ Disclaimer
This package is an unofficial community-developed client for the Interparcel API.
We are not affiliated, associated, authorized, endorsed by, or in any way officially connected with Interparcel.
All product and company names are trademarksโข or registeredยฎ trademarks of their respective holders.