Naming API
Method | HATE | meaning |
---|---|---|
POST | /nacos/v1/ns/instance | Register an instance |
DELETE | /nacos/v1/ns/instance | Logout instance |
GET | /nacos/v1/ns/instance/list | Get a list of instances |
PUT | /nacos/v1/ns/instance/beat | Send heartbeat |
GET | / nacos / v1 / ns / api / hello | Nacos server status |
GET | /nacos/v1/ns/service/list | Get all service names |
Register an instance
Request path
# POST
/nacos/v1/ns/instance
Request parameter
name | Types of | Is it mandatory | description |
---|---|---|---|
ip | String | Yes | Service instance IP |
port | int | Yes | Service instance port |
namespaceId | String | no | Namespace ID |
weight | double | no | Weights |
enabled | boolean | no | Is online |
healthy | boolean | no | Is it healthy |
metadata | String | no | Extended Information |
clusterName | String | no | Cluster name |
serviceName | String | Yes | Service Name |
groupName | String | no | Group name |
ephemeral | boolean | no | Is it a temporary instance |
Request example
/nacos/v1/ns/instance?app=unknown&groupName=DEFAULT_GROUP&metadata=%7B%22preserved.register.source%22%3A%22SPRING_CLOUD%22%7D&namespaceId=public&port=8083&enable=true&healthy=true&clusterName=DEFAULT&ip=169.254.10
Example returns
ok
List of examples
# GET
/nacos/v1/ns/instance/list
Request parameter
name | Types of | Is it mandatory | description |
---|---|---|---|
serviceName | String | Yes | Service Name |
groupName | String | no | Group name |
namespaceId | String | no | Namespace ID |
clusters | String, multiple clusters separated by commas | no | Cluster name |
healthyOnly | boolean | No, the default is false | Whether to return only healthy instances |
Request example
/nacos/v1/ns/instance/list?app=unknown&healthyOnly=false&namespaceId=public&clientIP=169.254.168.100&serviceName=DEFAULT_GROUP%40%40nacos-discovery&udpPort=59711&clusters=DEFAULT
Example returns
{
"dom": "nacos.test.1",
"cacheMillis": 1000,
"useSpecifiedURL": false,
"hosts": [{
"valid": true,
"marked": false,
"instanceId": "10.10.10.10-8888-DEFAULT-nacos.test.1",
"port": 8888,
"ip": "10.10.10.10",
"weight": 1.0,
"metadata": {}
}],
"checksum": "3bbcf6dd1175203a8afdade0e77a27cd1528787794594",
"lastRefTime": 1528787794594,
"env": "",
"clusters": ""
}
Send instance heartbeat
# PUT
/nacos/v1/ns/instance/beat
Request parameter
name | Types of | Is it mandatory | description |
---|---|---|---|
serviceName | String | Yes | Service Name |
groupName | String | no | Group name |
ephemeral | boolean | no | Is it a temporary instance |
beat | JSON format string | Yes | Example heartbeat content |
Request example
/nacos/v1/ns/instance/beat?app=unknown&serviceName=DEFAULT_GROUP%40%40nacos-discovery&namespaceId=public&port=8083&clusterName=DEFAULT&ip=169.254.104.253
return