Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support V2 endpoints #33

Merged
merged 7 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
26 changes: 12 additions & 14 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 @@ -97,9 +94,9 @@ const printify = new Printify({
| 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) Your personal shop ID. Can be found using `printify.shops.list()`. |
| `enableLogging` | `true` | (optional) Enables logging of API requests and responses. Enabled by default. |
| `host` | `'api.printify.com'` | (optional) The host for API requests. |
| `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 @@ -113,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
Loading