AllDID for the RESTful API version used by native clients/servers.
AllDID API depends on AllDID.js and provides external support. Features included are:
- Resolve any DID.
- Caching of parsing results to improve performance.
First, you need to install dependencies using pnpm
pnpm install
Then, you can run the following command:
pnpm dev
- development mode.pnpm lint:fix
- code formatting.pnpm jest
- run unit tests.pnpm build
- build to be available in production.
Using node-config to store all the configs.
There would be a structure like below:
- config
- default.ts #
- production.ts #
- [NODE_CONFIG_ENV].ts #
- local.ts #
The latter config will override the previous config. The override method is recursively, so you only need to pay attention to the really different data.
The NODE_CONFIG_ENV
is the variable defined in env, and can be retrieved with process.env.NODE_CONFIG_ENV
in JS code. We have injected it in ecosystem.config.js
, so the config file [NODE_CONFIG_ENV].ts
will be automatically loaded if
For more information, please refer to its docs.
Be careful, don't store any sensitive parts in repo, please put them on server or in CI secrets.
The basic style of the API is Restful, which will respect the http status, like 4xx, 5xx. A normal response will only contain necessary data, no extra fields like errcode
, or errmsg
.
The HttpStatus and Business Error should be separated. So we use CodedError
instead of general HttpException for known errors.
When it comes to Response
, if it is an error Response, it's format will be like below:
{
"code": 1001,
"msg": "This is a manual exception, with code 1001 and status 401",
"ts": "2022-10-31T16:06:38.532Z",
"url": "/api/demo/coded-error-using-status"
}
TBD
- Check domain availability
- Check domain validity
- Check if the domain name is registered
- Query domain name owner
- Query domain name manager
- Query TokenID
- Query multiple parsing records
- Query multiple resolved addresses
- Query registry address
Check if the name is supported.
GET /api/v1/name/{name}/check/supported
Headers:
Key | Required | Value | Description |
---|---|---|---|
Content-Type | TRUE | application/json | message body encoding |
Path parameters:
Key | Required | Value | Description |
---|---|---|---|
name | TRUE | string | domain name |
// /api/v1/name/leon.eth/check/supported
{
"is_supported": true
}
Check if the name is valid.
GET /api/v1/name/{name}/check/available
Headers:
Key | Required | Value | Description |
---|---|---|---|
Content-Type | TRUE | application/json | message body encoding |
Path parameters:
Key | Required | Value | Description |
---|---|---|---|
name | TRUE | string | domain name |
// /api/v1/name/leon.eth/check/available
{
"is_available": true
}
Check if the name is already registered.
GET /api/v1/name/{name}/check/registered
Headers:
Key | Required | Value | Description |
---|---|---|---|
Content-Type | TRUE | application/json | message body encoding |
Path parameters:
Key | Required | Value | Description |
---|---|---|---|
name | TRUE | string | domain name |
// /api/v1/name/leon.eth/check/registered
{
"is_registered": true
}
Query the address of the domain name owner
GET /api/v1/name/{name}/owner
Headers:
Key | Required | Value | Description |
---|---|---|---|
Content-Type | TRUE | application/json | message body encoding |
Path parameters:
Key | Required | Value | Description |
---|---|---|---|
name | TRUE | string | domain name |
// /api/v1/name/leon.eth/owner
{
"owner": "0xC72B6f66017246d6A7f159F5C2BF358188AD9ECa"
}
Request failed:
// /api/v1/name/owner?name=wererer.eth
{
"code": 4001,
"msg": "Unregistered name",
"ts": "2022-10-31T16:06:38.532Z",
"url": "/api/v1/name/owner?name=wererer.eth"
}
uery the address of the manager of the specified domain name.
GET /api/v1/name/{name}/manager
Headers:
Key | Required | Value | Description |
---|---|---|---|
Content-Type | TRUE | application/json | message body encoding |
Path parameters:
Key | Required | Value | Description |
---|---|---|---|
name | TRUE | string | domain name |
// /api/v1/name/leon.eth/manager
{
"manager": "0xC72B6f66017246d6A7f159F5C2BF358188AD9ECa"
}
Request failed:
// /api/v1/name/wererer.eth/manager
{
"code": 4001,
"msg": "Unregistered name",
"ts": "2022-10-31T16:06:38.532Z",
"url": "/api/v1/name/manager?name=wererer.eth"
}
Query the TokenID of the domain name.
GET /api/v1/name/{name}/manager
Headers:
Key | Required | Value | Description |
---|---|---|---|
Content-Type | TRUE | application/json | message body encoding |
Path parameters:
Key | Required | Value | Description |
---|---|---|---|
name | TRUE | string | domain name |
// /api/v1/name/leon.eth/tokenid
{
"token_id": "0xC72B6f66017246d6A7f159F5C2BF358188AD9ECa"
}
Request failed:
// /api/v1/name/wererer.eth/tokenid
{
"code": 4001,
"msg": "Unregistered name",
"ts": "2022-10-31T16:06:38.532Z",
"url": "/api/v1/name/tokenid?name=wererer.eth"
}
Query multiple resolution records of a domain name.
GET /api/v1/name/{name}/records?keys={keys}
Headers:
Key | Required | Value | Description |
---|---|---|---|
Content-Type | TRUE | application/json | message body encoding |
Path parameters:
Key | Required | Value | Description |
---|---|---|---|
name | TRUE | string | domain name |
keys | FALSE | string | string[] | ["address.eth"] |
// /api/v1/name/leonx.bit/records?keys=%5B%22address.eth%22%5D
[
{
"key": "address.eth",
"label": "",
"subtype": "eth",
"ttl": 300,
"type": "address",
"value": "0xC72B6f66017246d6A7f159F5C2BF358188AD9ECa"
}
]
Request failed:
// /api/v1/name/wererer.eth/records?keys=%5B%22address.eth%22%5D
{
"code": 4001,
"msg": "Unregistered name",
"ts": "2022-10-31T16:06:38.532Z",
"url": "/api/v1/name/records?name=wererer.eth"
}
Query multiple resolution addresses of a domain name.
GET /api/v1/name/{name}/records?keys={keys}
Headers:
Key | Required | Value | Description |
---|---|---|---|
Content-Type | TRUE | application/json | message body encoding |
Path parameters:
Key | Required | Value | Description |
---|---|---|---|
name | TRUE | string | domain name |
keys | FALSE | string | string[] | ["eth"] |
// /api/v1/name/leonx.bit.eth/addrs?keys=%5B%22eth%22%5D
[
{
"key": "address.eth",
"label": "",
"subtype": "eth",
"ttl": 300,
"type": "address",
"value": "0xC72B6f66017246d6A7f159F5C2BF358188AD9ECa",
"symbol": "ETH"
}
]
Request failed:
// /api/v1/name/wererer.eth/records?keys=%5B%22address.eth%22%5D
{
"code": 4001,
"msg": "Unregistered name",
"ts": "2022-10-31T16:06:38.532Z",
"url": "/api/v1/name/records?name=wererer.eth"
}
Query the registry address where the domain name is located.
GET /api/v1/name/{name}/registry
Headers:
Key | Required | Value | Description |
---|---|---|---|
Content-Type | TRUE | application/json | message body encoding |
Path parameters:
Key | Required | Value | Description |
---|---|---|---|
name | TRUE | string | domain name |
// /api/v1/name/leon.eth/registry
{
"registry_address": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
}
Request failed:
// /api/v1/name/wererer.eth/registry
{
"code": 4001,
"msg": "Unregistered name",
"ts": "2022-10-31T16:06:38.532Z",
"url": "/api/v1/name/records?name=wererer.eth"
}