API Documentation

File Uploader

Endpoint: POST /upload

Parameter multipart/form-data:

  • elrayyxml: File yang akan diupload (required).
  • duration: Durasi file sebelum dihapus (optional). Format: [value][unit].
    • Units: m (menit), h (jam), d (hari), M (bulan).
    • Contoh: 10m, 1h, 7d, 1M.
JavaScript (axios) Example
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

async function uploadFile(filePath) {
  try {
    const form = new FormData();
    form.append('elrayyxml', fs.createReadStream(filePath));
    form.append('duration', '10m'); // Optional

    const response = await axios.post(
      'https://s.elrayyxml.my.id/upload',
      form,
      { headers: form.getHeaders() }
    );
    return response.data;
  } catch (error) {
    console.error('Upload Error:', error.message);
  }
}

uploadFile('./path/to/your/file.jpg');
cURL Example
curl -X POST -F "elrayyxml=@mypic.jpg" -F "duration=10m" https://s.elrayyxml.my.id/upload

URL Shortener

Endpoint: POST /shorten

Body application/json:

{
  "url": "https://example.com"
}
JavaScript (axios) Example
const axios = require('axios');

async function shortenUrl(longUrl) {
  try {
    const response = await axios.post(
      'http://s.elrayyxml.my.id/shorten',
      { url: longUrl },
      { headers: { 'Content-Type': 'application/json' } }
    );
    return response.data;
  } catch (error) {
    console.error('Shorten Error:', error.message);
  }
}

shortenUrl('https://example.com');
cURL Example
curl -X POST -H "Content-Type: application/json" -d '{"url":"https://example.com"}' https://s.elrayyxml.my.id/shorten