July 2026 — the entire x2y suite is now free. Code Leak Detector moves to a one-time $29 on 1 Sep.

View products

Professional SDK for API Monitoring & Code Refactoring

x2y SDK

v1.0.0MIT

A comprehensive solution for modern software development, combining powerful API monitoring capabilities with intelligent code refactoring. Designed for developers who want to improve their API integration practices and code quality through automated analysis and suggestions.

NODE.JS 18+ES6 + COMMONJSTYPESCRIPTZERO TELEMETRY

Free & open source — MIT licence. No account, no telemetry, no cloud dependency.

x2y-sdk · live examples
module: monitorruntime: node:22telemetry: 0 B

Overview

API intelligence and code quality in one package

The x2y SDK is a comprehensive solution for modern software development, combining powerful API monitoring capabilities with intelligent code refactoring. It is designed for developers who want to improve their API integration practices and code quality through automated analysis and suggestions.

With support for both CommonJS and ES6 modules, the x2y SDK integrates seamlessly into any JavaScript or TypeScript project, providing real-time insights into API behaviour and actionable code improvement recommendations — all processed locally, with zero telemetry.

SDK at a glance
Packagex2y-dev-tools-sdk
Versionv1.0.0
RuntimeNode.js 18+
ModulesES6 + CommonJS
TypesTypeScript definitions included
LicenceMIT
Telemetry0 bytes

Key features

Six capabilities, one import

API Traffic Monitoring

Record and analyse API calls with detailed metrics — endpoint, method, response time, status code and headers — stored entirely in memory or on your filesystem.

Predictive Issue Analysis

Anticipate API failures before they happen. The SDK analyses recorded traffic patterns to surface risk levels, rate-limit proximity and suggested fallback endpoints.

Code Refactoring Suggestions

Get intelligent, line-level suggestions to improve code quality — idiomatic patterns, performance fixes and modern async conversions — for strings or entire files.

Performance Optimization

Identify and fix performance bottlenecks like DOM queries inside loops, repeated allocations and unbatched operations. Suggestions include the corrected code, not just a warning.

Async Pattern Improvements

Modernise legacy promise chains into clean async/await syntax. The SDK detects nested .then() patterns and produces the equivalent await-based rewrite.

Rate Limit Detection

Monitor x-ratelimit-remaining and related headers across every recorded call. Predict when a limit will be reached and receive proactive warnings before requests start failing.

Installation

Three ways to get started

npm install x2y-dev-tools-sdk
npm install -g x2y-dev-tools-sdk
git clone https://github.com/x2yDevs/x2y-sdk.git
cd x2y-sdk
npm install
npm run build

Import & setup

ES6 or CommonJS — your choice

The SDK ships with both module formats and bundled TypeScript definitions. Import whichever style your project uses and initialise with a single constructor call.

JavaScript// ES6 modules import { X2YSdk } from 'x2y-dev-tools-sdk'; // CommonJS (Node.js) const { X2YSdk } = require('x2y-dev-tools-sdk'); // Initialize the SDK const sdk = new X2YSdk();

Basic usage

Record, predict and refactor in one flow

JavaScriptimport { X2YSdk } from 'x2y-dev-tools-sdk'; const sdk = new X2YSdk(); // Record API traffic sdk.recordAPITraffic({ endpoint: '/api/users', method: 'GET', timestamp: Date.now(), responseTime: 200, statusCode: 200, headers: { 'x-ratelimit-remaining': '85' } }); // Predict issues const prediction = await sdk.predictAPIIssues('/api/users'); console.log(prediction); // Refactor code const suggestions = await sdk.refactorCode(` for (let i = 0; i < arr.length; i++) { console.log(arr[i]); } `); console.log(suggestions);

API monitoring

Record traffic, predict failures, configure thresholds

01

Recording API traffic

Build a dataset by recording API traffic data for predictions. Each call captures endpoint, method, timestamp, response time, status code and headers — the raw material the prediction engine learns from.

JavaScriptsdk.recordAPITraffic({ endpoint: '/api/users', method: 'POST', timestamp: Date.now(), responseTime: 250, statusCode: 201, headers: { 'x-ratelimit-remaining': '45', 'x-ratelimit-limit': '100', 'content-type': 'application/json' } });
02

Predicting API issues

The SDK analyses recorded traffic to predict potential problems — risk level, rate-limit proximity, suggested fallback endpoints and a confidence score — before the next call is made.

JavaScriptconst prediction = await sdk.predictAPIIssues('/api/users'); console.log(prediction);
/* Output: { endpoint: '/api/users', riskLevel: 'medium', predictedFailure: false, rateLimitApproaching: true, suggestedAlternatives: ['/api/v2/users', '/api/users?cached=true'], confidence: 85 } */
03

Configuration options

Customise SDK behaviour with two configuration objects — one for API monitoring, one for refactoring. Every value has a sensible default; override only what you need.

JavaScriptconst sdk = new X2YSdk( { // API monitoring config rateLimitThreshold: 80, // Percentage before warning predictionWindow: 60000, // Time window in ms apiUrl: 'https://api.example.com' }, { // Refactoring config targetLanguage: 'typescript', rules: ['performance', 'idiom', 'async'] } );

Code refactoring

From strings to files — five ways to improve your code

01

Refactoring code strings

Analyse any code snippet and receive structured improvement suggestions — type, description, original code, suggested replacement, line number and severity.

JavaScriptconst suggestions = await sdk.refactorCode(` for (let i = 0; i < arr.length; i++) { console.log(arr[i]); } `); console.log(suggestions);
/* Output: [ { type: 'idiom', description: 'Use array methods like forEach() for better readability', originalCode: 'for (let i = 0; i < arr.length; i++) { ... }', suggestedCode: 'arr.forEach(item => console.log(item));', line: 2, severity: 'medium' } ] */
02

Refactoring entire files

Point the SDK at a JavaScript or TypeScript file on disk and receive a full list of suggestions across the entire source — ready to feed into a review workflow or CI gate.

JavaScriptconst fileSuggestions = await sdk.refactorFile('./src/example.js'); console.log(`${fileSuggestions.length} suggestions found`);
03

Performance suggestions

Identify performance issues like DOM queries inside loops. The SDK suggests hoisting the query outside the iteration and provides the rewritten code block.

JavaScriptconst performanceCode = ` for (let i = 0; i < items.length; i++) { document.getElementById('myElement').innerHTML += items[i]; } `; const suggestions = await sdk.refactorCode(performanceCode); // Will suggest caching the DOM query outside the loop
04

Idiom suggestions

Get recommendations for modern JavaScript and TypeScript idioms — replacing imperative loops with declarative array methods, eliminating var, and adopting optional chaining where appropriate.

JavaScriptconst oldCode = ` var result = []; for (var i = 0; i < items.length; i++) { if (items[i].active) { result.push(items[i].name); } } `; const suggestions = await sdk.refactorCode(oldCode); // Will suggest: items.filter(item => item.active).map(item => item.name)
05

Async pattern improvements

Modernise legacy promise chains into clean async/await syntax. The SDK detects nested .then() structures and emits the equivalent await-based control flow.

JavaScriptconst oldAsyncCode = ` fetch('/api/data') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error(error)); `; const suggestions = await sdk.refactorCode(oldAsyncCode); // Will suggest using async/await instead of promise chains

Integration

Wrap fetch once, monitor everything

Monkey-patch window.fetch (or the Node equivalent) to automatically record every outbound request, measure its duration, and run a prediction before returning the response. High-risk endpoints surface a console warning without interrupting the call.

Auto-refactoring. Set the environment variable X2Y_AUTO_REFACTOR=true to automatically apply high-severity refactoring suggestions during a build step. Use with caution in production pipelines — review the diff first.
JavaScriptconst originalFetch = window.fetch; window.fetch = async (...args) => { const start = Date.now(); const response = await originalFetch(...args); const duration = Date.now() - start; // Record the traffic sdk.recordAPITraffic({ endpoint: args[0].toString(), method: 'GET', timestamp: Date.now(), responseTime: duration, statusCode: response.status, headers: Object.fromEntries(response.headers.entries()) }); // Predict if next calls might fail const prediction = await sdk.predictAPIIssues(args[0].toString()); if (prediction.riskLevel === 'high') { console.warn('High risk detected for:', args[0]); } return response; };

Specifications

Technical details

x2y SDK specifications
Packagex2y-dev-tools-sdk
Versionv1.0.0
RuntimeNode.js 18+
Module formatsES6 + CommonJS
TypeScriptBundled type definitions
API monitoringTraffic recording, prediction, rate-limit detection
RefactoringStrings, files, performance, idiom, async
ConfigTwo objects — API + refactoring
Auto-refactorX2Y_AUTO_REFACTOR=true
LicenceMIT
Telemetry0 bytes — verified continuously
Account requiredNone — ever
PriceFree & open source
Developerx2y Devs Tools Ltd, Nairobi, Kenya

Support

Need help?

For support and inquiries, contact the team directly. Bug reports and feature requests are welcome on GitHub — the SDK is MIT-licensed and contributions are encouraged.

Downloads

Get x2y SDK v1.0.0

Free and open source. The x2y SDK is published under the MIT licence. Install from npm, clone from GitHub, or vendor the source directly into your project. No account, no key, no telemetry.

Security model

Your code and API data never leave your process

Data policy. Telemetry: 0 bytes collected. Account required: none, ever. API traffic data: held in your process memory or written to paths you control. Source code analysed: read from paths you provide, never transmitted. Refactoring engine: runs locally, no cloud inference. Network connections: only the API calls your own application makes. Licence: MIT.

The x2y SDK is a library that runs inside your application. It does not make any network calls of its own — the only traffic it observes is the traffic your code already generates. Recorded API metrics stay in your process memory unless you explicitly persist them. Source code passed to refactorCode or refactorFile is analysed in-process and never leaves your machine. There is no analytics endpoint, no crash reporter, no licence check, no cloud inference tier. Verify with Wireshark, mitmproxy or your firewall logs — you will observe zero outbound connections attributable to the SDK itself.

Security manifest
Telemetry0 bytes collected
AccountNone required — ever
API traffic dataYour process memory or your filesystem
Source analysisIn-process, never transmitted
Refactoring engineLocal — no cloud inference
NetworkOnly your application's own calls
LicenceMIT — auditable source
VerificationAny network monitor

Ready to build

Install x2y SDK — monitor APIs and refactor code in one import

Free, MIT-licensed, zero telemetry. One npm install gives you predictive API monitoring and intelligent code refactoring — running entirely inside your own process.

Summary
Versionv1.0.0
RuntimeNode.js 18+
LicenceMIT — free & open source
Telemetry0 bytes