https://github.com/remarkablemark/paccurate
:package: Node.js library for Paccurate.
https://github.com/remarkablemark/paccurate
api javascript node nodejs npm paccurate typescript
Last synced: 3 months ago
JSON representation
:package: Node.js library for Paccurate.
- Host: GitHub
- URL: https://github.com/remarkablemark/paccurate
- Owner: remarkablemark
- License: mit
- Created: 2022-04-14T00:18:17.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T09:14:47.000Z (over 1 year ago)
- Last Synced: 2024-10-29T10:59:35.682Z (over 1 year ago)
- Topics: api, javascript, node, nodejs, npm, paccurate, typescript
- Language: TypeScript
- Homepage: https://b.remarkabl.org/paccurate
- Size: 2.22 MB
- Stars: 3
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# paccurate
[](https://nodei.co/npm/paccurate/)
[](https://www.npmjs.com/package/paccurate)
[](https://github.com/remarkablemark/paccurate/actions/workflows/build.yml)
[](https://codecov.io/gh/remarkablemark/paccurate)
Node.js client library for [Paccurate](https://paccurate.io/). The types are generated from [Paccurate OpenAPI](https://api.paccurate.io/static/api/).
See [docs](https://remarkabl.org/paccurate/).
## Quick Start
```ts
import { pack } from 'paccurate'
const data = await pack({
key: 'YOUR_API_KEY',
itemSets: [
{
refId: 0,
dimensions: { x: 5.5, y: 6, z: 6 },
quantity: 3,
weight: 4.5,
},
],
boxTypeSets: ['customer'],
})
console.log(data)
```
## Documentation
- [TypeDoc](https://remarkabl.org/paccurate/)
- [Paccurate docs](https://docs.paccurate.io/)
- [API docs](https://api.paccurate.io/docs/)
## Prerequisites
- [Node.js](https://nodejs.org/)
- [Paccurate account](https://manage.paccurate.io/sign_up)
## Installation
[NPM](https://www.npmjs.com/package/paccurate):
```sh
npm install paccurate
```
[Yarn](https://yarnpkg.com/package/paccurate):
```sh
yarn add paccurate
```
## Usage
The package needs to be configured with your account's secret key:
```ts
const { Paccurate } = require('paccurate')
const paccurate = new Paccurate('YOUR_API_KEY')
paccurate
.pack({
// ...
})
.then((data) => console.dir(data, { depth: null }))
.catch((error) => console.error(error.code, error.message))
```
The same can be done with ES Modules and async-await:
```ts
import { Paccurate } from 'paccurate'
const paccurate = new Paccurate('YOUR_API_KEY')
async function main() {
try {
const data = await paccurate.pack({
// ...
})
console.dir(data, { depth: null })
} catch (error) {
console.error(error.code, error.message)
}
}
main()
```
### API Endpoint
The request can be sent to two endpoints:
| Endpoint | Description |
| ------------------------------- | --------------------------------------------------- |
| https://api.paccurate.io/ | 30-second timeout, best for real-time |
| https://cloud.api.paccurate.io/ | 1 hour timeout, best for large, parallel batch jobs |
The default endpoint is https://api.paccurate.io/. To send to a different endpoint, you can:
1. Instantiate with endpoint:
```ts
import { Paccurate } from 'paccurate'
const paccurate = new Paccurate('YOUR_API_KEY', 'https://cloud.api.paccurate.io/')
await paccurate.pack(data)
```
2. Call method with endpoint:
```ts
import { Paccurate } from 'paccurate'
const paccurate = new Paccurate('YOUR_API_KEY')
await paccurate.pack(data, 'https://cloud.api.paccurate.io/')
```
3. Call function with endpoint:
```ts
import { pack } from 'paccurate'
await pack(data, 'https://cloud.api.paccurate.io/')
```
### TypeScript
The following types can be imported:
```ts
import type { Body, Response } from 'paccurate'
```
## Migration
### v2
Updated Paccurate OpenAPI version from 1.7.0 to 1.7.1.
**BREAKING CHANGE:** Pack property `key` has been removed from the OpenAPI schema.
## Contributing
Contributions are welcome! See our [guide](https://github.com/remarkablemark/paccurate/blob/master/.github/CONTRIBUTING.md) on how to proceed. 👋
## License
[MIT](https://github.com/remarkablemark/paccurate/blob/master/LICENSE)