Official Node.js/TypeScript SDK for Stream API - Complete payment processing with consumers, products, subscriptions, invoices, and payment links
npm install @streamsdk/typescriptOfficial Node.js/TypeScript SDK for Stream API



---
- Overview
- Installation
- Quick Start
- SDK Features
- Usage
- Examples
- Express.js Integration
- API Documentation
- Error Handling
- Contributing
- Support
- License
---
The Stream SDK provides a complete TypeScript/JavaScript interface to the Stream payment platform. Process payments, manage subscriptions, create invoices, and handle customer data with full type safety and modern JavaScript features.
Key Features:
- ๐ Secure API Key authentication
- ๐ฅ Customer (Consumer) management
- ๐ฆ Product catalog management
- ๐ณ Payment link creation
- ๐ Subscription handling
- ๐งพ Invoice generation
- ๐๏ธ Coupon & discount management
- ๐ Full TypeScript support
- โก ES Modules and CommonJS compatible
---
``bash`
npm install @streamsdk/typescript
Or install from GitHub:
`bash`
npm install github:streampayments/streamsdk-typescript#v1.0.0
`json`
{
"dependencies": {
"@streamsdk/typescript": "^1.0.0"
}
}
---
`typescript
import StreamSDK from "@streamsdk/typescript";
// Initialize the SDK
const client = StreamSDK.init(process.env.STREAM_API_KEY!);
// Create a payment link
const result = await client.createSimplePaymentLink({
name: "Monthly Subscription",
amount: 99.99,
consumer: {
email: "customer@example.com",
name: "Ahmad Ali",
phone: "+966501234567",
},
product: {
name: "Premium Plan",
price: 99.99,
},
successRedirectUrl: "https://yourapp.com/success",
failureRedirectUrl: "https://yourapp.com/failure",
});
console.log("Payment URL:", result.paymentUrl);
`
---
| Feature | Description |
| ------------------ | ------------------------------------------ |
| Authentication | API Key and Bearer Token support |
| Consumers | Create, update, list, and delete customers |
| Products | Manage your product catalog |
| Payment Links | Generate secure payment links |
| Subscriptions | Handle recurring payments |
| Invoices | Create and manage invoices |
| Coupons | Discount and promotion management |
| Webhooks | Real-time event notifications |
- โ
Single or multiple products per payment
- โ
Guest checkout (no consumer required)
- โ
Smart resource matching (automatic deduplication)
- โ
SAR currency (default)
- โ
Custom metadata support
- โ
Full TypeScript type definitions
- โ
ESM and CommonJS support
---
For detailed usage examples and API documentation, please refer to the API Documentation section below.
Initialize the SDK with your API key:
`typescript
import StreamSDK from "@streamsdk/typescript";
const client = StreamSDK.init(process.env.STREAM_API_KEY!);
`
For more authentication options and detailed examples for each resource, see the documentation links in the Available Resources and Operations section.
---
Explore complete TypeScript SDK examples in the examples directory:
- basic.mjs - Basic SDK usage
- comprehensive.mjs - Advanced features
- multiple-products.mjs - Multiple products guide
For Express.js examples, see streamsdk-express
---
For Express.js applications, we provide a separate adapter package with declarative handlers for checkout and webhooks:
---
Available methods
#### Consumers
* create - Create Consumer
* list - Get All Consumers
* get - Get Consumer
* update - Update Consumer
* delete - Delete Consumer
#### Coupons
* list - List Coupons
* create - Create Coupon
* update - Update Coupon
* get - Get Coupon
* delete - Delete Coupon
#### Invoices
* get - Get Invoice
* list - List Invoices
#### PaymentLinks
* get - Get Payment Link
* create - Create Payment Link
* list - List Payment Links
#### Payments
* list - List Payments
* get - Get Payment
* refund - Refund Payment
#### Products
* list - List Products
* create - Create Product
* get - Get Product
* update - Update Product
* delete - Delete Product
#### Subscriptions
* get - Get Subscription
* update - Update Subscription
* list - List Subscriptions
* create - Create Subscription
* cancel - Cancel Subscription
* freeze - Freeze Subscription
* listFreezes - List Subscription Freezes
* updateFreeze - Update Subscription Freeze
#### Subscriptions.Freeze
* delete - Delete Subscription Freeze
> Click on each resource above to see detailed documentation with code examples, parameters, and response types.
---
The SDK throws errors for failed requests:
`typescript`
try {
const consumer = await client.createConsumer({
name: "Ahmad Ali",
email: "invalid-email",
});
} catch (error) {
console.error("Error creating consumer:", error.message);
console.error("Status:", error.status);
console.error("Response:", error.response);
}
---
We welcome contributions! Please see our Contributing Guide for details.
`bashClone the repository
git clone https://github.com/streampayments/streamsdk-typescript.git
cd streamsdk-typescript
---
- API Documentation
- OpenAPI Specification
- Examples
- Express Adapter
- Multiple Products Guide
- Framework Support
- ๐ง Email: support@streampay.sa
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
---
MIT License - see LICENSE for details.
---