Skip to content

Commit

Permalink
feat: support V2 endpoints
Browse files Browse the repository at this point in the history
addresses #30
  • Loading branch information
spencerlepine committed Jan 6, 2025
1 parent 108af0a commit 2e9e509
Show file tree
Hide file tree
Showing 68 changed files with 1,302 additions and 668 deletions.
19 changes: 12 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,29 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.0] - 2025-01-06

- Added support for V2 endpoints.
- Removed verbose stack trace from errors.

## [1.2.0] - 2025-01-03

- Organized shared types and fixed bundle export
- Improved configuration object
- Organized shared types and fixed bundle export.
- Improved configuration object.

## [1.1.0] - 2024-11-08

- Replaced `fetch` with `axios` for improved security
- Applied minor internal refactors for better maintainability
- Replaced `fetch` with `axios` for enhanced security.
- Refactored internal code for better maintainability.

## [1.0.2] - 2024-10-24

Improved error log for easier debugging
- Added error logging for easier debugging.

## [1.0.1] - 2024-07-29

Documentation update for TypeScript support
- Updated documentation to include TypeScript support.

## [1.0.0] - 2024-07-26

Initial release for Printify API v1
- Initial release for Printify API v1.
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Printify SDK for TypeScript (Node.js)
# Printify SDK for Node.js (TypeScript)

[![NPM Version](https://img.shields.io/npm/v/printify-sdk-js)](https://www.npmjs.com/package/printify-sdk-js)
![Coverage](https://img.shields.io/badge/Coverage-100%25-brightgreen.svg) ![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)
Expand All @@ -8,14 +8,13 @@ The Printify Node SDK provides convenient access to the Printify API from applic

Guidelines and source endpoints can be found here: [developers.printify.com](https://developers.printify.com).

> 📢 Note: This SDK currently supports V1 API endpoints only. A 2.0.0 release is planned once the majority of V2 endpoints have been migrated.
## Documentation

See the [`printify-sdk-js` API docs](./docs/API.md) for Node.js
See the [`API.md`](./docs/API.md) docs

- [Shops](./docs/API.md#shops) - `printify.shops.*`
- [Catalog](./docs/API.md#catalog) - `printify.catalog.*`
- [Catalog V2](./docs/API.md#catalog-v2) - `printify.v2.catalog.*`
- [Products](./docs/API.md#products) - `printify.products.*`
- [Orders](./docs/API.md#orders) - `printify.orders.*`
- [Uploads](./docs/API.md#uploads) - `printify.uploads.*`
Expand Down Expand Up @@ -51,17 +50,15 @@ console.log(orders); // { current_page: 1, data: [{ id: "5a9", address_to: {}, l
### Usage with TypeScript

```typescript
import Printify from 'printify-sdk-js';
import type { ListWebhooksResponse, Webhook } from 'printify-sdk-js';
import Printify, { Webhook } from 'printify-sdk-js';

const printify = new Printify({
accessToken: process.env.PRINTIFY_API_TOKEN,
shopId: '123456',
});

const result: ListWebhooksResponse = await printify.webhooks.list();
const webhook: Webhook = result[0];
console.log(webhook); // { "topic": "order:created", "url": "https://example.com/webhooks/order/created", "shop_id": "1", "id": "5cb87a8cd490a2ccb256cec4" }
const webhooks: Webhook[] = await printify.webhooks.list();
console.log(webhooks[0]); // { "topic": "order:created", "url": "https://example.com/webhooks/order/created", "shop_id": "1", "id": "5cb87a8cd490a2ccb256cec4" }
```

### Usage with CommonJS
Expand Down Expand Up @@ -89,20 +86,18 @@ const printify = new Printify({
accessToken: process.env.PRINTIFY_API_TOKEN,
shopId: '123456',
enableLogging: true,
apiVersion: 'v1',
host: 'api.printify.com',
timeout: 5000, // in ms
});
```

| Option | Default | Description |
| --------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------- | --- |
| --------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `accessToken` | `null` | The API access token for authenticating requests. Generate one at [Printify API](https://printify.com/app/account/api). |
| `shopId` | `null` | (optional) The ID of the shop to use for API requests. Can be found using `printify.shops.list()`. |
| `enableLogging` | `true` | (optional) Enables logging of API requests and responses. Enabled by default. |
| `apiVersion` | `'v1'` | (optional) The API version |
| `host` | `'api.printify.com'` | The host for API requests. | |
| `timeout` | `5000` | (optional) Reqeust timeout in ms |
| `shopId` | `null` | (optional) Your personal shop ID. Can be found using `printify.shops.list()`. |
| `enableLogging` | `true` | (optional) Enables logging of API requests and errors. Enabled by default. |
| `host` | `'api.printify.com'` | (optional) The host for API requests. |
| `timeout` | `5000` | (optional) Request timeout in ms. |

## Development

Expand All @@ -115,9 +110,10 @@ yarn test
```sh
# (optional) test the bundle locally
cd examples/typescript && yarn && cd ../../
yarn build
mv dist examples/development
cd examples/development
rm -rf examples/typescript/node_modules/printify-sdk-js/dist && mv dist examples/typescript/node_modules/printify-sdk-js
cd examples/typescript
yarn start
```

Expand Down
Loading

0 comments on commit 2e9e509

Please sign in to comment.