@blinkstore/node-sdk v1.0.5
Blinkstore.in - Node.js SDK Documentation
Overview
The @blinkstore/node-sdk package provides a Node.js SDK for interacting with Blinkstore's services. This SDK facilitates various operations like authentication, managing carts, coupons, orders, products, profiles, and more.
Installation
To install the SDK, use npm:
npm install @blinkstore/node-sdkGetting Started
First, import the Blinkstore class from the package:
import { Blinkstore } from '@blinkstore/node-sdk';Initializing the SDK
Create an instance of the Blinkstore class. You can optionally pass a configuration object with a env. If not provided, it defaults to sandbox, you can use production.
const blinkstore = new Blinkstore({
env: 'sandbox', // Optional
});Connecting to the Service
Before performing any operations, establish a connection with the service:
await blinkstore.connect();Authentication
To authenticate, use the authenticate method with your API key:
await blinkstore.authenticate({
secretId: "3aa8f190-f710-4a89-89be-2d48fc5729b1",
clientId: "3aa8f190-9b27-4405-a0a4-2d48fc5729b1",
});Using SDK Services
Once connected and authenticated, you can use various services provided by the SDK:
blinkstore.Auth: Authentication-related operations.blinkstore.Cart: Managing shopping carts.blinkstore.Coupon: Coupon-related operations.blinkstore.Headless: Headless operations.blinkstore.Integration: Integration services.blinkstore.Offering: Managing offerings.blinkstore.Order: Order-related operations.blinkstore.Product: Product management.blinkstore.Profile: User profile operations.blinkstore.Stats: Statistics and analytics.blinkstore.Store: Store-related operations.blinkstore.Utils: Utility functions.blinkstore.Views: View-related operations.
Example Usage
Here's an example of how to get a user profile:
try {
await blinkstore.connect();
await blinkstore.authenticate({
secretId: "3aa8f190-f710-4a89-89be-2d48fc5729b1",
clientId: "3aa8f190-9b27-4405-a0a4-2d48fc5729b1",
});
const profile = await blinkstore.getProfile();
console.log(profile);
} catch (error) {
console.error(error);
}Clearing the Session
To clear the current session:
await blinkstore.clear();Documentation
For detailed API documentation and more examples, refer to the official Blinkstore SDK documentation.