RESTful Binary Sensor template

I’m trying to understand the json template for a RESTful Binary Sensor, the page response is

{“message”: “API running.”}

when recive this message it shoud be on, case othewise off.

This is the message you receive when you go to

http://YOUR_HOME_ASSISTANT/api/
It’s the basic API message.

To get a status for your sensor you should be going to
http://YOUR_HOME_ASSISTANT/aip/states/ENTITY_ID

What is the URL you are using to retrieve your binary sensor?

I’m trying to test my internet connection, sou I’m using as an adress:

http://myduckdns/api/

I want to use this message as a binary sensor, is this possible? there is an easier way to do it?

Yes, if you get that message, the system is up. If you do not get that message the system is down.
However, if the system is down you’re most likely going to get a timeout.
The way to handle this as a sensor would be to create a shell script that handles the timeout and returns a value to Home Assistant.
Here’s an example of one that I use to return a value if a remote switch is down. It could be adapted to do what you want.

TEMP=$(curl -s --connect-timeout 5 -X GET http://IP_OF_SENSOR:8000/temperature)
if [[ -z $TEMP ]]; then
  echo 0
else
  echo "$TEMP"
fi