maelyn.js
v2.0.2
Published
Simple Usage For Maelyn Group
Downloads
126
Maintainers
Readme
Maelyn.js ✨
A powerful, elegant, and developer-friendly REST API client for Maelyn's ecosystem
🚀 What is Maelyn.js?
Maelyn.js is a modern, lightweight SDK that brings the power of Maelyn's AI services directly to your Node.js applications. Whether you're building chatbots, processing images, or managing file uploads, Maelyn.js makes integration seamless and intuitive.
✨ Key Features
- 🤖 AI-Powered Chat: Integrate with Gemini AI for intelligent conversations
- 📁 File Management: Effortless file uploads to Maelyn CDN
- 🔒 Secure Authentication: Header-based API key management
- 📱 Modern Promise API: Full async/await support
- 🛠️ TypeScript Ready: Built with developers in mind
- 🚀 Zero Dependencies: Lightweight and fast
📦 Installation
Get started in seconds with npm:
npm install maelyn.jsOr with yarn:
yarn add maelyn.js🎯 Quick Start
const Maelyn = require('maelyn.js');
// Initialize with your API key
const api = new Maelyn('YOUR_API_KEY');
// Start chatting with AI!
const response = await api.get('geminichat', {
q: 'Hello, how can AI help me today?'
});
console.log(response);📖 API Reference
Constructor
const api = new Maelyn(apiKey);Methods
get(endpoint, params) - GET Requests
Perfect for fetching data and querying AI services.
// Basic chat request
const chatResponse = await api.get('geminichat', {
q: 'What is the weather like today?'
});
// Chat with image analysis
const imageChat = await api.get('geminichat', {
q: 'Describe this image',
url: 'https://example.com/image.jpg'
});
// Get latest updates
const updates = await api.get('komikulastupdate');post(endpoint, data) - POST Requests
Ideal for sending data and creating resources.
// Send structured data
const result = await api.post('endpoint', {
title: 'My Data',
content: 'Some content here',
metadata: { type: 'example' }
});
// Create AI chat session with custom parameters
const chatSession = await api.post('geminichat', {
q: 'Start a conversation about AI',
context: 'Technical discussion',
temperature: 0.7
});
// Submit feedback or data
const feedback = await api.post('feedback', {
rating: 5,
comment: 'Great service!',
category: 'api-experience'
});uploadFile(filePath) - File Upload
Upload files to Maelyn CDN without API key requirements.
// Upload a file
const uploadResult = await api.uploadFile('./image.jpg');
console.log('File URL:', uploadResult.url);🎨 Usage Examples
🤖 AI Chatbot Integration
const Maelyn = require('maelyn.js');
const api = new Maelyn('YOUR_API_KEY');
async function chatWithAI(userMessage) {
try {
const response = await api.get('geminichat', {
q: userMessage
});
return response.answer || response.result;
} catch (error) {
console.error('Chat error:', error.message);
return 'Sorry, I encountered an error. Please try again.';
}
}
// Usage
const answer = await chatWithAI('Tell me a joke!');
console.log('AI:', answer);🖼️ Image Analysis with AI
async function analyzeImage(imageUrl, question) {
try {
const response = await api.get('geminichat', {
q: question,
url: imageUrl
});
return response;
} catch (error) {
throw new Error(`Image analysis failed: ${error.message}`);
}
}
// Analyze an image
const analysis = await analyzeImage(
'https://example.com/photo.jpg',
'What objects do you see in this image?'
);📝 Advanced POST Operations
async function createChatSession(sessionData) {
try {
const session = await api.post('chat/create', {
userId: sessionData.userId,
sessionName: sessionData.name,
settings: {
model: 'gemini-pro',
temperature: 0.8,
maxTokens: 1000
}
});
return session;
} catch (error) {
console.error('Failed to create chat session:', error.message);
throw error;
}
}
// Create a new chat session
const newSession = await createChatSession({
userId: 'user123',
name: 'AI Assistant Chat'
});🔄 Data Submission & Processing
async function submitProcessingJob(jobData) {
try {
const job = await api.post('process/submit', {
type: jobData.type,
parameters: jobData.params,
priority: 'high',
webhook: 'https://your-app.com/webhook'
});
console.log('Job submitted:', job.jobId);
return job;
} catch (error) {
throw new Error(`Job submission failed: ${error.message}`);
}
}
// Submit a processing job
const job = await submitProcessingJob({
type: 'image-analysis',
params: {
imageUrl: 'https://example.com/image.jpg',
analysis_type: 'object-detection'
}
});const path = require('path');
async function uploadAndProcess(filePath) {
try {
// Upload file
const uploadResult = await api.uploadFile(filePath);
console.log('✅ File uploaded:', uploadResult.url);
// Process with AI if it's an image
if (uploadResult.url && uploadResult.url.match(/\.(jpg|jpeg|png|gif)$/i)) {
const analysis = await api.get('geminichat', {
q: 'Analyze this uploaded image',
url: uploadResult.url
});
return {
fileUrl: uploadResult.url,
analysis: analysis
};
}
return { fileUrl: uploadResult.url };
} catch (error) {
console.error('Upload failed:', error.message);
throw error;
}
}
// Upload and analyze
const result = await uploadAndProcess('./my-image.jpg');📊 Batch Processing with Mixed Methods
async function batchProcess(operations) {
const results = [];
for (const operation of operations) {
try {
let response;
if (operation.method === 'GET') {
response = await api.get(operation.endpoint, operation.params);
} else if (operation.method === 'POST') {
response = await api.post(operation.endpoint, operation.data);
}
results.push({
operation: operation.name,
response,
success: true
});
} catch (error) {
results.push({
operation: operation.name,
error: error.message,
success: false
});
}
// Rate limiting - wait 1 second between requests
await new Promise(resolve => setTimeout(resolve, 1000));
}
return results;
}
// Mixed GET and POST operations
const operations = [
{
name: 'Get Chat Response',
method: 'GET',
endpoint: 'geminichat',
params: { q: 'What is AI?' }
},
{
name: 'Create Session',
method: 'POST',
endpoint: 'chat/session',
data: { userId: 'user123', name: 'AI Chat' }
},
{
name: 'Submit Feedback',
method: 'POST',
endpoint: 'feedback',
data: { rating: 5, comment: 'Great API!' }
}
];
const results = await batchProcess(operations);⚙️ Configuration
Environment Variables
Store your API key securely using environment variables:
// .env file
MAELYN_API_KEY=your_actual_api_key_here
// In your application
require('dotenv').config();
const api = new Maelyn(process.env.MAELYN_API_KEY);Error Handling Best Practices
async function robustAPICall() {
try {
const response = await api.get('geminichat', { q: 'Hello!' });
return response;
} catch (error) {
// Handle different types of errors
if (error.message.includes('API request failed')) {
console.error('API Error:', error.message);
// Maybe retry or use fallback
} else {
console.error('Unexpected error:', error);
}
throw error; // Re-throw if needed
}
}🌟 Available Endpoints
| Endpoint | Method | Description | Parameters |
|----------|--------|-------------|------------|
| geminichat | GET/POST | AI chat with Gemini | GET: q, url / POST: q, context, temperature |
| komikulastupdate | GET | Latest manga updates | None required |
| chat/create | POST | Create chat session | userId, sessionName, settings |
| chat/session | POST | Manage chat sessions | userId, sessionId, action |
| process/submit | POST | Submit processing job | type, parameters, priority |
| feedback | POST | Submit user feedback | rating, comment, category |
| uploadFile | POST | File upload to CDN | File path (no API key needed) |
💡 Tip: Check the official documentation for the complete list of available endpoints and their parameters.
🤝 Contributing
We welcome contributions! Here's how you can help:
- 🍴 Fork the repository
- 🌿 Create a feature branch (
git checkout -b feature/amazing-feature) - 💾 Commit your changes (
git commit -m 'Add amazing feature') - 📤 Push to the branch (
git push origin feature/amazing-feature) - 🔄 Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
👨💻 Author
Clayza Aubert
- GitHub: @ClayzaAubert
- Website: maelyn.tech
🆘 Support
- 📖 Documentation
- 📧 Email: [email protected]
Made with ❤️ by the Maelyn Team
Empowering developers to build amazing AI-powered applications
⭐ Star this repo if you find it helpful! ⭐
