---
title: Preface
slug: aidc/fTnI-preface
createdAt: 2025-12-29T09:52:03.828Z
---

## <font color="#1d50a2">Version Note</font>

:::hint{type="warning"}
**NOTE：**
Please note that this RESTAPI manual only applies to **AsterNOS V3.1-R0500** series software version.
:::

## <font color="#1d50a2">Basic Concept of Resource Construction</font>

RESTAPI is a resource-oriented interface design, and all interface designs are designed for resources. A simple understanding is to locate resources using a URI and describe operations using HTTP (GET, POST, DELETE, PUT, PATCH).

Resources can be grouped into collections. Each set is homogeneous; therefore, it only contains one type of resource and is unordered. Resources can also exist outside any set, and we refer to them as singleton resources. The collection itself is also a resource that can exist globally, located at the top level of the API; It can also be included in a single resource and exist as a subset. Subsets are typically used to express a certain 'contained' relationship.

The following figure illustrates the key concepts in RESTAPI.

![](https://api.archbee.com/api/optimize/zl-MD6bX0o2Ab3p8w66u1/aXsOzpLV-JJzmcDvKCBDu-20251229-092833.png)

The API resource model is used to describe the types of available resources, their behavior, and their relationships, as detailed in: [rest api design concept](https://restful-api-design.readthedocs.io/en/latest/resources.html).

## <font color="#1d50a2">Request</font>

### <font color="#1d50a2">Format of Uniform Resource Locator (URL)</font>

Uniform Resource Identifier: URI, the most common form of a URI is the uniform resource locator (URL), also known as a Web address. For example (SWITCH\_IP represents the switch device IP):
https: //SWITCH\_IP/rest/v1/interfaces.
parameter format:

| **Type** | **Parameter Option**                                                                                                                                                   | **Description**                                                                                                               |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| symbol   | ?                                                                                                                                                                      | Parameter start character                                                                                                     |
| =        | Parameter assignment character                                                                                                                                         |                                                                                                                               |
| &        | Connector between multiple parameters                                                                                                                                  |                                                                                                                               |
| keywords | selector                                                                                                                                                               | A method applied to resource collections/resource elements to filter individual attribute values of related resource elements |
| depth    | Obtain resource depth, default to 1, which only resolve the current resource; If set to 1, its level 1 sub resources can be resolved, and so on, until up to 10 levels |                                                                                                                               |

Detail in:

- [Unified Resource Identifiers(rfc7230)](https://www.rfc-editor.org/rfc/rfc7230#section-2.7)

### <font color="#1d50a2">HTTP Request Methods</font>

Rest API v3 uniformly uses JSON format as the request and response data format.

| **Method** | **Operation** | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ---------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| GET        | obtain        | Retrieves the specified resource or representation. GET is a read-only operation that does not change the engine state or have any side effects.<br />- The HTTP GET operation should not have a request body. If information is passed in a GET request, query parameters should be used instead.<br />- Unless specified, the HTTP GET operation returns the configured state.                                                                                                                                                                                                                                                                                                       |
| POST       | create        | Submits data to be processed to the specified resource. The data to be processed is included in the request body.<br />A POST operation can create a new resource.<br />- The POST operation request contains the details of a new resource that is created in JSON.<br />- Every POST request must include a JSON body.<br />- For all POST operations to create a new resource, the Location header in the HTTP response contains the complete URL to be used for subsequent PUT, GET, and delete commands.<br />- The HTTP POST response to a Create request must have a 201 return code and a Location header containing the URI of the newly created resource in the HTTP header. |
| PATCH      | update        | Updates the specified resource with new information. The data that is included in the PATCH operation replaces the previous data.<br />- The PATCH operation is used to modify an existing resource.<br />- The PATCH operation cannot be used to create a new resource.                                                                                                                                                                                                                                                                                                                                                                                                               |
| PUT        | replace       | Replace the specified resource with new information. The data that is included in the PUT operation replaces the previous data.<br />- The PUT operation is used to replace or modify an existing resource. The PUT operation cannot be used to create a new resource.<br />- The request body of a PUT operation must contain the complete representation of the mandatory attributes of the resource.                                                                                                                                                                                                                                                                                |
| DELETE     | delete        | Deletes a resource. If you delete a resource that has already been deleted, a 404 Not Found response is returned.<br />- The HTTP DELETE operation should not have a request body. If information is passed in a GET request, query parameters should be used instead.                                                                                                                                                                                                                                                                                                                                                                                                                 |

- [Patch Method Standards(rfc6920)](https://datatracker.ietf.org/doc/html/rfc6902)
- [HTTPS request methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods)
- [request methods(rfc7231)](#)

## <font color="#1d50a2">Response</font>

### <font color="#1d50a2">Return Code</font>

The return code is the response code, and the HTTPS response status code indicates whether a specific HTTPS request has been successfully completed. There are five types of responses: information response, successful response, redirection, client error, and server error.

| **Return code** | **Reason**            | **Method**           | **Description**                                                                                                                           |
| --------------- | --------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| 200             | OK                    | GET                  | The server successfully returned the data requested by the user, which is idempotent.                                                     |
| 201             | Created               | POST/PUT             | User successfully created or updated data.                                                                                                |
| 202             | Accepted              | \*                   | Indicates that a request has entered the backend queue (asynchronous task).                                                               |
| 204             | No Content            | DELETE/PATCH         | User successfully deleted or modified data.                                                                                               |
| 400             | InvalidRequest        | POST/PUT/<br />PATCH | The request sent by the user has an error, and the server did not perform a new or modified data operation. This operation is idempotent. |
| 401             | Unauthorized          | \*                   | Indicates that the user does not have permission (token username, incorrect password).                                                    |
| 403             | Forbidden             | \*                   | Indicates that the user is authorized (as opposed to a 401 error), but access is prohibited.                                              |
| 404             | Not Found             | \*                   | The request sent by the user is for a non-existent record, and the server did not perform an operation, which is idempotent.              |
| 406             | Not Acceptable        | GET                  | The format requested by the user is not available (such as JSON format requested by the user, but only XML format).                       |
| 410             | Gone                  | GET                  | The resource requested by the user has been permanently deleted and will no longer be available.                                          |
| 422             | Unprocessable Entity  | POST/PUT/<br />PATCH | When creating an object, a validation error occurred.                                                                                     |
| 500             | Internal Server Error | \*                   | The server encountered an error, and the user will not be able to determine whether the request was successful.                           |

Detail in:

- [HTTPS response code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
- [Status Code Definition(rfc2616)](https://www.rfc-editor.org/rfc/rfc2616#section-10)

### <font color="#1d50a2">Return Value Format</font>

Unified return format in JSON format

- GET operation directly returns query results.
- POSTPUTPATCH DELETE operation.
- Single resource operation return format

```json
{
    status_code

    result

    module

    resource
}
```

The patch operation involves sub resources of the module and requires the addition of a resource field. If successful, the result returns the string OK, and if unsuccessful, the reason for the failure is returned.

- Return format for batch operations:

```json
{
    status_code   // the entire request status code, 200 indicates success for all, 207 partially succeeded, and 400 completely failed.
    results:
        [
             {
                status_code   // single operation status code
                result
                module
                resource   // the patch operation must return.
            }, ......
        ]
}
```

Results is an array structure that contains the operation results of a single resource.

## <font color="#1d50a2">Tree Diagrams Node Representation</font>

Each node in a YANG module is printed as:

```text
  <status>--<flags> <name><opts> <type> <if-features>
    <status> is one of:
      +  for current
    <flags> is one of:
      rw  for configuration data nodes and choice nodes
      ro  for non-configuration data nodes and choice nodes,
          output parameters to rpcs and actions, and
          notification parameters
      -w  for input parameters to rpcs and actions
      -u  for uses of a grouping
      -x  for rpcs and actions
      Case nodes do not have any <flags>.
    <name> is the name of the node
      (<name>) means that the node is a choice node
    :(<name>) means that the node is a case node
      If the node is augmented into the tree from another module,
      its name is printed as <prefix>:<name>, where <prefix> is the
      prefix defined in the module where the node is defined.
      If the node is a case node, there is no space before the <name>.

    <opts> is one of:
      ?  for an optional leaf, choice, anydata, or anyxml
      *  for a leaf-list or list
      [<keys>] for a list's keys
      /  for a top-level data node in a mounted module
      @  for a top-level data node of a module identified in a
        mount point parent reference

    <type> is the name of the type for leafs and leaf-lists

      If the type is a leafref, the type is printed as either
      (1) "-> TARGET", where TARGET is the leafref path,
      with prefixes removed if possible or (2) "leafref".

    <if-features> is the list of features this node depends on,
      printed within curly brackets and a question mark "{...}?"
```

Arbitrary whitespace is allowed between any of the whitespace-
separated fields (e.g., `<opts>` and `<type>`).  Additional whitespace
may, for example, be used to "column align" fields (e.g., within a
list or container) to improve readability.

## <font color="#1d50a2">Properties Description Table Explanation</font>

### <font color="#1d50a2">Required Field</font>

| **Abbreviation** | **Full name**    | **Description**              |
| ---------------- | ---------------- | ---------------------------- |
| P                | Parameter        | Parameter                    |
| M                | Mandatory        | Mandatory option             |
| O                | Option           | Optional                     |
| CM               | Condition        | Conditional mandatory option |
| CO               | Condition Option | Conditional Optional         |
| RO               | Read-Only        | Read-Only Parameter          |

### <font color="#1d50a2">Type / Range Field</font>

The range field specifies constraints on the values of a node. It can use:

- Regular Expressions: For precise constraints, such as `^Ethernet([1-3][0-9]{3})$` to match `Ethernet names`.
- Numeric Ranges: For example, 1..500 indicates a range of values from 1 to 500.
- Natural Language: For simpler explanations, such as "A VLAN ID between 1 and 4094".
- Enumeration Values: such as "true", "false".

### <font color="#1d50a2">Common Data Range Description</font>

| **Range**                           | **Description**                                           |
| ----------------------------------- | --------------------------------------------------------- |
| Ethernet name                       | Ethernet1..3999(Ethernet1..3999:1..7 when after breakout) |
| Ethernet sub-interface name         | Ethernet1..3999.1..4094                                   |
| Link-aggregation name               | Lag1..9999                                                |
| Link-aggregation sub-interface name | Lag1..9999.1..4094                                        |
| Vlan name                           | Vlan1..4094                                               |
| Loopback name                       | Loopback0..199                                            |
| mgmt name                           | Mgmt0                                                     |
| vrf name                            | a word starts with  "Vrf"                                 |

## <font color="#1d50a2">Notes on URL Path Construction</font>

<font color="#1d50a2">**Path Variables**</font>

In RESTful API URLs, variables are denoted by enclosing them in curly braces (e.g., /users/&#x7B;userId}).

 <font color="#1d50a2">**Path Compression**</font>
To simplify RESTful API paths and controller bindings, the following path compression rules apply:
A list node is omitted from both the path and data if the enclosing container meets the following conditions:

1. The list is the *only* subnode within the container.
2. The container’s name is either a *prefix* of or the *plural* form of the list’s name.

<font color="#1d50a2">**Path Omission**</font>

In RESTful API URLs, *case* nodes do not need to be explicitly specified in the URL path or body. Only the relevant child nodes within the selected case must be included.
