Morse Code API
This API translates standard text into International Morse Code and vice versa. It handles alphanumeric characters and punctuation, using standard spacing for readability.
Endpoint
Section titled “Endpoint” POST
/api/v1/morse Request Parameters
Section titled “Request Parameters”The following parameters are accepted in the request body:
| Field | Type | Required | Description |
|---|---|---|---|
text | string | Yes | The input string (Text or Morse code). |
mode | string | Optional | encode (Text to Morse) or decode (Morse to Text). Default: encode. |
Request Examples
Section titled “Request Examples”# Encoding to Morsecurl -X POST https://heavstal.com.ng/api/v1/morse \-H "Content-Type: application/json" \-H "x-api-key: <YOUR_API_KEY>" \-d '{"text": "HELLO WORLD", "mode": "encode"}'const response = await fetch('https://heavstal.com.ng/api/v1/morse', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': '<YOUR_API_KEY>' }, body: JSON.stringify({ text: '... --- ...', mode: 'decode' })});
const res = await response.json();console.log(res.data.output);import { tools } from '@heavstal/api';
// Encodeconst encoded = await tools.morse("HELLO", "encode");console.log(encoded.data.output); // Output: .... . .-.. .-.. ---
// Decodeconst decoded = await tools.morse("... --- ...", "decode");console.log(decoded.data.output); // Output: SOSimport requests
url = "https://heavstal.com.ng/api/v1/morse"headers = { "Content-Type": "application/json", "x-api-key": "<YOUR_API_KEY>"}payload = { "text": "HELLO WORLD", "mode": "encode"}
response = requests.post(url, headers=headers, json=payload)print(response.json()["data"]["output"])Response Examples
Section titled “Response Examples”{ "status": "success", "creator": "HEAVSTAL TECH", "data": { "input": "HELLO WORLD", "output": ".... . .-.. .-.. --- / .-- --- .-. .-.. -..", "mode": "encode" }}{ "status": "error", "error": "Invalid Morse code provided."}