Complete TypeScript SDK for Getfly CRM API v4.0 with Call Center, Tickets, Funds, and Campaigns support
npm install @warriorteam/getfly-crm-sdk


A powerful, type-safe TypeScript SDK for Getfly CRM API v6.1. This SDK provides a clean, modern interface for interacting with Getfly CRM's REST API.
- ๐ Full TypeScript Support - 100% type safety with IntelliSense
- ๐ฏ Strict Mode - Enforced type checking for better reliability
- โ
Runtime Validation - Zod schemas for request/response validation
- ๐ Auto-completion - Full IDE support with comprehensive typing
- ๐ก๏ธ Error Handling - Detailed error information and proper error types
- ๐ Custom Fields Support - Dynamic custom fields integration
- ๐ Query Builder - Powerful filtering, sorting, and pagination
- ๐ฆ Modular Design - Organized by API version and modules
- ๐งช Well Tested - Comprehensive unit tests with Jest
- ๐ Complete Documentation - Detailed API documentation and examples
``bash`
npm install getfly-crm-sdkor
yarn add getfly-crm-sdkor
pnpm add getfly-crm-sdk
`typescript
import { GetflyClient } from 'getfly-crm-sdk';
// Initialize the client
const client = new GetflyClient({
subdomain: 'your-company', // your-company.getflycrm.com
apiKey: 'your-api-key',
version: '6.1', // optional, defaults to '6.1'
});
// Test connection
const isConnected = await client.testConnection();
console.log('Connected:', isConnected);
// Get all accounts
const accounts = await client.v61.accounts.list({
fields: ['id', 'account_name', 'email'],
limit: 20,
});
console.log('Accounts:', accounts);
// Create a new account
const newAccount = await client.v61.accounts.create({
account_name: 'Acme Corporation',
account_type: 1, // 1: Customer
email: 'contact@acme.com',
phone_office: '+1234567890',
});
console.log('New account:', newAccount);
`
#### Accounts (client.v61.accounts)
- List, create, update, delete accounts
- Advanced filtering by type, status, date range
- Search by name, email, phone
- Custom fields support
`typescript
// Get customers with filtering
const customers = await client.v61.accounts.getByType(1, {
filtering: {
'created_at:gte': '2023-01-01',
'account_status:eq': 1,
},
sort: 'account_name',
direction: 'ASC',
});
// Search accounts by name
const searchResults = await client.v61.accounts.searchByName('Acme');
`
#### Products (client.v61.products)
- Complete product management
- Variants and attributes support
- Inventory tracking
- Price range filtering
`typescript
// Get products by category
const electronics = await client.v61.products.getByCategory('Electronics');
// Get low stock products
const lowStock = await client.v61.products.getLowStock(5);
// Search products by SKU or name
const products = await client.v61.products.search('LAPTOP-001');
`
#### Sale Orders (client.v61.saleOrders)
- Order management and tracking
- Payment status management
- Date range filtering
- Customer-specific orders
`typescript
// Get pending orders
const pendingOrders = await client.v61.saleOrders.getByStatus(1);
// Get orders by customer
const customerOrders = await client.v61.saleOrders.getByAccount(123);
// Get orders in date range
const monthlyOrders = await client.v61.saleOrders.getByDateRange(
'2023-01-01',
'2023-01-31'
);
`
#### Purchase Orders (client.v61.purchaseOrders)
- Purchase order management
- Approval workflow
- Vendor-specific orders
- Order status tracking
`typescript
// Get orders pending approval
const pendingApproval = await client.v61.purchaseOrders.getPendingApproval();
// Approve an order
await client.v61.purchaseOrders.approve(456, 789); // order_id, approved_by
// Reject an order with reason
await client.v61.purchaseOrders.reject(457, 'Budget exceeded', 789);
`
`typescript
const client = new GetflyClient({
// Required
subdomain: 'your-company', // Your Getfly CRM subdomain
apiKey: 'your-api-key', // Your API key from Getfly CRM
// Optional
version: '6.1', // API version (defaults to '6.1')
timeout: 30000, // Request timeout in ms (defaults to 30000)
headers: { // Additional headers
'User-Agent': 'MyApp/1.0',
},
baseURL: 'https://custom.domain.com', // Custom base URL (overrides subdomain)
});
`
All list methods support powerful filtering:
`typescript
const accounts = await client.v61.accounts.list({
// Select specific fields
fields: ['id', 'account_name', 'email', 'account_type'],
// Filter with various operations
filtering: {
'account_name:contains': 'corp', // Contains
'account_type:eq': 1, // Equals
'created_at:gte': '2023-01-01', // Greater than or equal
'created_at:lte': '2023-12-31', // Less than or equal
'annual_revenue:between': [10000, 50000], // Between values
'tags:in': ['VIP', 'Premium'], // In array
},
// Sorting
sort: 'created_at',
direction: 'DESC',
// Pagination
limit: 50,
offset: 0,
});
`
Getfly CRM supports dynamic custom fields:
`typescript
// Get custom fields schema
const customFieldsSchema = await client.v61.accounts.getCustomFields();
// Create account with custom fields
const account = await client.v61.accounts.create({
account_name: 'Custom Corp',
account_type: 1,
custom_fields: {
'custom_industry': 'Technology',
'custom_website_visits': 1250,
'custom_priority': 'High',
},
});
`
The SDK provides detailed error information:
`typescript
import { GetflyApiError, GetflyValidationError } from 'getfly-crm-sdk';
try {
const account = await client.v61.accounts.create(invalidData);
} catch (error) {
if (error instanceof GetflyValidationError) {
console.error('Validation failed:', error.getErrorSummary());
error.validationErrors.forEach(err => {
console.error(${err.field}: ${err.message});`
});
} else if (error instanceof GetflyApiError) {
console.error('API Error:', error.message);
console.error('Status:', error.status);
console.error('Code:', error.code);
}
}
Test your API connection:
`typescript
const isConnected = await client.testConnection();
if (!isConnected) {
console.error('Failed to connect to Getfly CRM API');
}
// Get detailed API info
const apiInfo = await client.getApiInfo();
console.log('API Info:', apiInfo);
/*
{
version: '6.1',
baseURL: 'https://your-company.getflycrm.com',
connected: true
}
*/
`
`bashClone the repository
git clone https://github.com/getfly-crm/typescript-sdk.git
cd typescript-sdk
$3
`
src/
โโโ client/ # Main client class
โโโ utils/ # HTTP client and validation utilities
โโโ versions/
โ โโโ v6.1/ # API v6.1 implementation
โ โโโ modules/ # API modules (accounts, products, etc.)
โ โโโ types/ # TypeScript type definitions
โ โโโ index.ts # Version entry point
โโโ index.ts # Main entry pointtests/ # Unit tests
examples/ # Usage examples
docs/ # Documentation
``Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions or need help:
- ๐ง Email: support@getflycrm.com
- ๐ Documentation: Getfly CRM API Docs
- ๐ Issues: GitHub Issues
- Getfly CRM for providing the API
- Zod team for the excellent validation library
- TypeScript team for the amazing language