Number2Words API

Description

Convert an integer to English words. Example 1234 is converted to one thousand two hundred thirty four.

Endpoint

> GET https://api.jsonrepo.com/v1/compute/converter/number2words

Headers

Field Description
api_key Required Your API Key

Parameters

Field Type Description
number Integer Required Number to convert
Accepts: any integer including negative numbers
Maximum Digits: 18

Response

A successful request will result in a populated payload field with the expected output.

A failed request will result in an error output as detailed in Error Rules. If the endpoint validation fails due to missing, badly formatted or invalid parameters, the endpoint will return HTTP code 400 along with a message detailing the error.

See the examples section for more information.

Request

  • Curl
// Convert the number -1234

curl -G \
https://api.jsonrepo.com/v1/compute/converter/number2words \
-H "api_key: {YOUR_API_KEY_HERE}" \
--data-urlencode "number=-1234" 

Success Response

{
    "http_code": 200,
    "http_message": "Ok",
    "message": "Successful execution",
    "payload": {
        "number": {
            "input": "-1234",
            "parsed": "-1234",
            "parsed_digits": 4,
            "words": "minus one thousand two hundred thirty four",
            "words_count": 7,
            "words_length": 42
        }
    }
}

Error Response Examples

// Request was made without the `number` parameter

{
    "http_code": 400,
    "http_message": "Bad Request",
    "message": "Malformed request: `number` must be provided",
    "payload": []
}

// Request was made with a 20 digit number

{
    "http_code": 400,
    "http_message": "Bad Request",
    "message": "Malformed request: `number` cannot be more than 18 digits",
    "payload": []
}