The Oracle Renamer API provides an intelligent service for renaming variables and functions in Lua scripts. This guide explains how to use the API effectively.
All API requests require authentication using an API key. Include your API key in the request headers:
ApiKey: YOUR_API_KEYPOST http://renamer.mshq.dev/api/renameThe API accepts POST requests with a JSON body containing the following parameters:
| Parameter | Type | Description |
|---|---|---|
| code | string | The Lua script content to be renamed |
| hash | string | SHA-256 hash of the original file |
| filename | string | Original filename |
The API returns a JSON response with the following fields:
| Field | Type | Description |
|---|---|---|
| outputCode | string | The renamed Lua script |
| totalTokens | number | Total tokens used for the operation |
| Status Code | Description |
|---|---|
| 200 | Success - Returns renamed code and token usage |
| 400 | Bad Request - Invalid input format |
| 401 | Unauthorized - Invalid API key |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Server Error - Renaming failed |
const fs = require('fs').promises;
const crypto = require('crypto');
const axios = require('axios');
async function renameScript(filePath) {
try {
// Read the script file
const code = await fs.readFile(filePath, 'utf8');
// Calculate SHA-256 hash
const hash = crypto
.createHash('sha256')
.update(code)
.digest('hex');
// Make API request
const response = await axios.post('https://oracle.mshq.dev/api/rename', {
code,
hash,
filename: filePath.split('/').pop()
}, {
headers: {
'Content-Type': 'application/json',
'ApiKey': 'YOUR_API_KEY'
}
});
// Handle successful response
const { outputCode, totalTokens } = response.data;
console.log(`Renaming completed using ${totalTokens} tokens`);
// Save renamed code
await fs.writeFile(`${filePath}.renamed.lua`, outputCode);
console.log('Renamed code saved successfully');
} catch (error) {
if (error.response) {
// Handle API error response
console.error('API Error:', error.response.status, error.response.data);
} else {
// Handle network or other errors
console.error('Error:', error.message);
}
}
}The API has the following rate limits:
For unlimited rate limits and better pricing, consider upgrading to Enterprise
When handling errors, your code should: