@rynn-k/api
v1.0.5
Published
NekoLabs API Client - Easy-to-use wrapper for NekoLabs API endpoints
Downloads
2
Maintainers
Readme
NekoLabs API Client
Easy-to-use Node.js client untuk NekoLabs API. Module ini menyediakan interface yang simple dan intuitif untuk mengakses semua endpoint NekoLabs API.
Installation
npm install nekolabs-apiQuick Start
const NekoLabsClient = require('nekolabs-api');
// Inisialisasi client
const client = new NekoLabsClient();
// Atau dengan custom base URL
const client = new NekoLabsClient({
baseURL: 'https://rynekoo-api.hf.space',
timeout: 30000
});
// Gunakan API
(async () => {
// Contoh 1: AI Chat
const response = await client.request('ai/ai4chat', {
text: 'Hi! How are you?'
});
console.log(response);
// Contoh 2: Generate Image
const image = await client.request('ai/flux/dev', {
text: 'Girl wearing glasses',
ratio: '1:1'
});
console.log(image);
// Contoh 3: TikTok Downloader
const video = await client.request('downloader/tiktok', {
url: 'https://tiktok.com/...'
});
console.log(video);
})();Features
- ✅ Auto-load endpoints dari API
- ✅ Type-safe dengan TypeScript definitions
- ✅ Handle dynamic routes
- ✅ Support multipart/form-data untuk upload
- ✅ Error handling yang baik
- ✅ Custom base URL support
- ✅ Timeout configuration
Usage Examples
Basic GET Request
// Tanpa params
const result = await client.request('random/blue-archive');
// Dengan required params
const result = await client.request('ai/claude/sonnet-4', {
text: 'What is JavaScript?'
});
// Dengan required dan optional params
const result = await client.request('canvas/quote-chat', {
text: 'Hello World',
name: 'Rynn',
profile: 'https://tmpfiles.org/...',
color: '#ff5733' // optional
});POST Request
// POST dengan JSON body
const result = await client.request('cloudflare-ai/text-generation', {
messages: [
{
role: 'user',
content: 'Hi! How are you?'
}
],
model: '@cf/microsoft/phi-2'
});Dynamic Routes
// Single dynamic parameter
const result = await client.request('example/:id', {
id: '12345'
});
// Multiple dynamic parameters
const result = await client.request('example/:category/:slug', {
category: 'technology',
slug: 'nodejs-tutorial'
});File Upload
const fs = require('fs');
// Upload image
const result = await client.request('example/upload-image', {
image: fs.createReadStream('./image.jpg'),
title: 'My Image' // optional
});Shortcut Methods
// GET shortcut
const result = await client.request('ai/ai4chat', {
text: 'Hello'
});
// POST shortcut
const result = await client.post('example/method/post', {
title: 'Post Title',
content: 'Post Content'
});Advanced Usage
Change Base URL
const client = new NekoLabsClient();
// Switch ke URL alternatif
client.setBaseURL('https://rynekoo-api.hf.space');
// Gunakan API dengan URL baru
const result = await client.request('ai/ai4chat', {
text: 'Hello'
});Get Available Endpoints
// Load semua endpoints
const endpoints = await client.requestEndpoints();
console.log(endpoints);
// Get info endpoint tertentu
const info = await client.requestEndpointInfo('ai/ai4chat');
console.log(info);
/*
{
alias: 'AI 4Chat (Text Generation)',
method: 'GET',
path: '/ai/ai4chat',
category: 'AI',
status: 'ready',
parameters: {
required: [
{
name: 'text',
description: 'Input text for generating response.',
type: 'string',
example: 'Hi! How are you?'
}
],
optional: []
}
}
*/Custom Axios Options
// Dengan custom headers atau options
const result = await client.request('ai/ai4chat',
{ text: 'Hello' },
{
headers: {
'Custom-Header': 'value'
},
timeout: 5000
}
);API Response Format
Success Response
{
success: true,
result: {
// response data
},
timestamp: '2025-10-23T17:50:37.601Z',
responseTime: '1ms'
}Module akan otomatis return result jika success.
Error Response
{
success: false,
message: 'Error message',
timestamp: '2025-10-23T17:50:37.601Z'
}Module akan otomatis return message jika gagal.
Configuration Options
const client = new NekoLabsClient({
baseURL: 'https://api.nekolabs.my.id', // default API URL
timeout: 30000 // request timeout in milliseconds (default: 30000)
});Error Handling
try {
const result = await client.request('ai/ai4chat', {
text: 'Hello'
});
console.log(result);
} catch (error) {
console.error('Error:', error.message);
}TypeScript Support
import NekoLabsClient from 'nekolabs-api';
const client = new NekoLabsClient({
baseURL: 'https://api.nekolabs.my.id'
});
const response = await client.request('ai/ai4chat', {
text: 'Hello'
});License
MIT
Author
@rynekooo
Support
Untuk bug reports dan feature requests, silakan buat issue di repository GitHub.
Links
- API Documentation: https://api.nekolabs.my.id
- Alternative URL: https://rynekoo-api.hf.space
