Binary Decimal API

Simple REST API by Iván.

About Binary Decimal API

This REST Api is for juniors developers wich getting practice in yours frontend app. Special to developers wich want demostrate your capacity of consume REST Api and your skills for showing data in the frontend.

This REST Api is a simple conversor of binary to decimal numbers and viceverse, follow more bottom to learn use...

How to use Binary Decimal API

Binary to decimal conversion

GET -> https://ivansanmartin.vercel.app/project/api/binary_to_decimal/{binaryNumber}
✅ Response example (OK 202):
GET -> https://ivansanmartin.vercel.app/project/api/binary_to_decimal/11111111

Response:


    {
        ok: true,           
        binary_number: "11111111",  
        decimal_convert: "255", 
        conversion_date: "1/1/2024"    
    }
                    
🔴 Bad request (400):

You get "code 400" for not correctly binary structure of part the client

Response:


    {
        ok: false,        
        NOT_VALID_BINARY: "The binary number is not valid"  
    }
                    

Decimal to binary conversion

GET -> https://ivansanmartin.vercel.app/project/api/decimal_to_binary/{decimalNumber}
✅ Response example (OK 202):
GET -> https://ivansanmartin.vercel.app/project/api/decimal_to_binary/255

Response:


    {
        ok: true,   
        decimal_number: "255",        
        binary_convert: "11111111", 
        conversion_date: "1/1/2024"   
    }
                    
📊 Parameters

?padding_ipv4=true

The parameter "padding_ipv4=true" is used to ensure that when converting decimal numbers to binary for IPv4 addresses, the resulting binary representation maintains a consistent length of 8 bits per octet, adding leading zeros if neededº

Example with the decimal number: "1"

GET -> http://ivansanmartin.vercel.app/project/api/decimal_to_binary/1/?padding_ipv4=true

Response:


    {
        ok: true,   
        decimal_number: "1",        
        binary_convert: "00000001", 
        ipv4: true, 
        conversion_date: "1/1/2024"   
    }
                    
🔴 Bad request (400):

You get "code 400" for not correctly number structure of part the client (negative numbers)

Response:


    {
        ok: false,  
        NOT_VALID_DECIMAL: "The decimal number is not valid"           
    }
                    

Text to binary conversion

POST -> https://ivansanmartin.vercel.app/project/api/text_to_binary/
🔄 Request Payload:

    {
        text: "Hello World!"       
    }
                    
✅ Response example (OK 200):

Response:


    {
        ok: true,   
        text: "Hello World!",        
        text_converted: "010010000110010101101100011011000110111100100000010101110110111101110010011011000110010000100001", 
        conversion_date: "1/1/2024"   
    }
                    
🔴 Bad request (400):

You get "code 400" for the JSON structure in the request body is not valid.

Response:


    {
        ok: false,  
        INCORRECT_STRUCURE: "Follow the correctly json structure. Read the documentation"         
    }