@tolinax/ayoune
v2025.9.13
Published
aYOUne - Business as a Service
Maintainers
Readme
aYOUne Node.js SDK
This SDK provides a comprehensive TypeScript interface for the aYOUne Business as a Service Platform by tolinax. Build powerful integrations with over 600 data models and 4500+ endpoints for CRM, ERP, PIM, marketing automation, and more.
If you're not already a customer, get your account here.
Features
- Complete Business Suite: CRM, ERP, PIM, marketing automation, affiliate networks
- Type-Safe: Full TypeScript support with comprehensive type definitions
- Fluent API: Chainable query methods for intuitive data manipulation
- Multiple Formats: Support for JSON, XML, YAML, CSV response formats
- Pagination: Built-in pagination handling with automatic link following
- Rate Limiting: Automatic rate limit monitoring and handling
Installation
npm install @tolinax/ayouneAuthentication
- Get your API token from your aYOUne dashboard
- Configure authentication:
- Set environment variable:
AYOUNE_TOKEN=your_token_here - Or pass directly to constructor:
new aYOUne(yourToken)
- Set environment variable:
Quick Start
import { aYOUne } from "@tolinax/ayoune";
const ayoune = new aYOUne(); // Uses AYOUNE_TOKEN env var
// or
const ayoune = new aYOUne("your_token_here");
(async () => {
try {
// Get consumers using module-based approach
const response = await ayoune.crm.consumers.list().exec();
console.log('Consumers:', response.payload());
console.log('Rate limit:', response.rateLimit());
// Get next page if available
if (response.links().find(link => link.rel === "next")) {
const nextPage = await response.next();
console.log('Next page:', nextPage.payload());
}
} catch (error) {
console.error('API Error:', error);
}
})();Fluent API Usage
The SDK provides a fluent interface with chainable methods:
// Basic list request
const consumers = await ayoune.crm.consumers.list().exec();
// With response formatting
const yamlData = await ayoune.crm.consumers.list().yaml().exec();
const csvData = await ayoune.crm.consumers.list().csv(',', '').exec();
// With query modifiers
const slicedData = await ayoune.crm.consumers.list()
.slice(10) // Limit to 10 results
.lean() // Hide metadata
.verbosity('minimal') // Minimal response
.exec();
// Debug mode
const debugData = await ayoune.crm.consumers.list().debug().exec();Available Query Methods
.lean()- Remove metadata from response.yaml()- Get response in YAML format.xml()- Get response in XML format.csv(delimiter, emptyValue)- Get response in CSV format.table()- Get response in table format.slice(n)- Limit results to n items.verbosity('default' | 'extended' | 'minimal')- Control response detail.debug()- Enable debug mode.describe()- Get API endpoint description.exec()- Execute the request
Method-Based Access
The SDK also supports direct method-based access for those who prefer a more traditional API approach:
// Create a new consumer
const leadData = {
first_name: "John",
last_name: "Doe",
email: "[email protected]",
type: "lead"
};
const newConsumer = await ayoune.create('consumers', leadData).exec();
// Get all consumers
const allConsumers = await ayoune.list('consumers').exec();
// Get a specific consumer by ID
const consumer = await ayoune.get('consumers', '123').exec();
// Update a consumer
const updatedData = { first_name: "Jane" };
const updatedConsumer = await ayoune.update('consumers', '123', updatedData).exec();
// Delete a consumer
await ayoune.delete('consumers', '123').exec();
// Method-based access also supports fluent API
const filteredConsumers = await ayoune.list('consumers')
.slice(5)
.yaml()
.lean()
.exec();Available Method-Based Operations
ayoune.list(resource)- Get multiple recordsayoune.get(resource, id?)- Get single record by ID (or all if no ID)ayoune.create(resource, data)- Create new recordayoune.update(resource, id, data)- Update existing recordayoune.delete(resource, id)- Delete record
All method-based operations support the same fluent API helpers as module-based access.
Response Handling
All API calls return an aYOUneApiResponseWrapper with helper methods:
const response = await ayoune.crm.consumers.list().exec();
// Get the actual data
const data = response.payload();
// Check rate limiting
const rateLimit = response.rateLimit();
console.log(`${rateLimit.remaining}/${rateLimit.limit} requests remaining`);
// Access pagination links
const links = response.links();
// Automatically get next page
if (response.links().find(link => link.rel === "next")) {
const nextPage = await response.next();
}API Access Patterns
The SDK supports two approaches for accessing the aYOUne API:
1. Module-Based Access (Domain Organization)
// Resources are organized by business domain
await ayoune.crm.consumers.list().exec();
await ayoune.sales.products.get('123').exec();
await ayoune.marketing.campaigns.list().exec();Available modules include:
ayoune.crm.*- Customer relationship managementayoune.sales.*- Sales operationsayoune.products.*- Product information management- And many more based on your aYOUne configuration
2. Method-Based Access (Direct Resource Access)
// Direct access to any resource by name
await ayoune.list('consumers').exec();
await ayoune.get('products', '123').exec();
await ayoune.create('campaigns', campaignData).exec();Both approaches support the same fluent API helpers and return the same response wrapper.
Development
Building
npm run build # Compile TypeScript
npm run prebuild # Clean dist directory
npm run postbuild # Copy package.jsonTesting
npm test # Run tests (builds first)Environment Setup
Create a .env file:
AYOUNE_TOKEN=your_token_hereAPI Documentation
For complete endpoint documentation, visit openapi.ayoune.app.
Support
- Issues: Report bugs
- Support: Get help
- Demo: Try aYOUne
License
Apache-2.0
Made with ❤️ at Tegernsee by tolinax
