# Address Screen

### **Address APIs**

The Address APIs handle the management of user addresses on the e-commerce platform, allowing users to create, update, view, and set default shipping addresses.

<figure><img src="https://3686328336-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd1Iq7THDAagTQzeC9rTN%2Fuploads%2FLQtae344gYNZiorkEl9e%2Fimage.png?alt=media&#x26;token=bd349181-b46c-4898-8e8b-76c723ccc953" alt=""><figcaption><p><strong>Address listing and adding screens</strong></p></figcaption></figure>

### **1. Create Address API**&#x20;

The Create Address API enables users to add a new address to their account.

### **Endpoint**

* `{{baseurl}}/api/v1/customer/create-address`

### **Method:**

* **POST**

### **Request Parameters:**

None

### **Request Body:**

`address`: The complete address details, including street, city, postal code, etc.

* `address_type`: The type of address (e.g., Home, Work, etc.).
* `landmark`: A landmark or notable location near the address.
* `is_default`: A boolean flag indicating whether this address is the default shipping address for the user.
* `level_id`: The unique identifier of the address level.

```json
{
    "address": "123 Main Street",
    "address_type": "Home",
    "landmark": "Near Central Park",
    "is_default": 0,
    "level_id": 1
}
```

### **Authorization:**

The API requires a bearer token in the request header for authentication. Users must include their valid bearer token in the "Authorization" header of the HTTP request to add a new address.

### **Response Format:**

The API responds with a JSON object indicating the status of the address creation request.

```json
{
    "success": true,
    "data": {
        "address": "Test Address",
        "address_type": "1",
        "level_id": "1",
        "landmark": "test landmark",
        "user_id": 17,
        "updated_at": "2023-08-07T08:15:30.000000Z",
        "created_at": "2023-08-07T08:15:30.000000Z",
        "id": 124
    },
    "message": "Success",
    "status_code": 200
}
```

###

###

###

### **2. Update Address API**&#x20;

The Update Address API allows users to modify an existing address in their account.

### **Endpoint**

* `{{baseurl}}/api/v1/customer/update-address`

### **Method**

* **POST**

### **Request Parameters:**

None

### **Request Body:**

The request body should include the following parameters to update an address:

* `address_id`: The unique identifier of the address to be updated.
* `address`: The updated complete address details, including street, city, postal code, etc.
* `address_type`: The updated type of address (e.g., Home, Work, etc.).
* `landmark`: The updated landmark or notable location near the address.
* `is_default`: The updated boolean flag indicating whether this address is the default shipping address for the user.
* `level_id`: The updated unique identifier of the address level.

```json
{
    "address_id": 100,
    "address": "456 New Street",
    "address_type": 1,
    "landmark": "Near Business Center",
    "is_default": 0,
    "level_id": 2
}
```

### **Authorization:**

The API requires a bearer token in the request header for authentication. Users must include their valid bearer token in the "Authorization" header of the HTTP request to update an address.

### **Response Format:**

The API responds with a JSON object indicating the status of the address update request.

```json
{
    "success": true,
    "data": [],
    "message": "Success",
    "status_code": 200
}
```

###

###

###

### **3. List Addresses API**&#x20;

The List Addresses API retrieves a paginated list of all addresses associated with the authenticated user.

### **Endpoint**

* `{{baseurl}}/api/v1/customer/address?page=1`

### **Method:**

* **GET**

### **Request Parameters:**

* `page` (optional): The page number for paginated results. If not specified, the first page of addresses will be returned.

### **Request Body:**

None

### **Authorization:**

The API requires a bearer token in the request header for authentication. Users must include their valid bearer token in the "Authorization" header of the HTTP request to access their addresses.

### **Response Format:**

The API responds with a JSON object containing the paginated list of addresses associated with the user's account.

```json
{
    "success": true,
    "data": {
        "address": [
            {
                "id": 100,
                "name": "i1344",
                "address": "Test Address 123",
                "address_type": 1,
                "address_type_label": "Home",
                "is_default": 0,
                "landmark": "test 113",
                "levels": null
            },
            {
                "id": 99,
                "name": "i1344",
                "address": "test",
                "address_type": 1,
                "address_type_label": "Home",
                "is_default": 0,
                "landmark": "jj",
                "levels": null
            }
        ],
        "pagination": {
            "count": 2
        }
    },
    "message": "Success",
    "status_code": 200
}
```

###

###

###

### **4. Set Default Address API**&#x20;

The Set Default Address API allows users to set a specific address as their default shipping address.

**Endpoint**

* `{{baseurl}}/api/v1/customer/set-default-address/`:address\_id

### **Method**

* **GET**

### **Request Parameters:**

* `address_id`: The unique identifier of the address to be set as the default shipping address.

### **Request Body:**

None

### **Authorization:**

The API requires a bearer token in the request header for authentication. Users must include their valid bearer token in the "Authorization" header of the HTTP request to set a default address.

### **Response Format:**

The API responds with a JSON object indicating the status of the default address update request.

```json
{
    "success": true,
    "data": [],
    "message": "Success",
    "status_code": 200
}
```

###

###

###

### **5. Shipping Level API**&#x20;

The Shipping Level API retrieves a list of shipping levels available on the e-commerce platform.

### **Endpoint**

* `{{baseurl}}/api/v1/shipping?lang_code=en`

### **Method**

* **GET**

### **Request Parameters:**

* `lang_code` (optional): The language code used to retrieve shipping level names and descriptions in a specific language. If not provided, the default language will be used.

### **Request Body:**

None

### **Authorization:**

The API requires a bearer token in the request header for authentication. Users must include their valid bearer token in the "Authorization" header of the HTTP request to access their addresses

### **Response Format:**

The API responds with a JSON object containing the list of available shipping levels.

```json
{
    "success": true,
    "data": {
        "shippingData": [
            {
                "id": 58,
                "name": "Kerala",
                "children": [
                    {
                        "id": 61,
                        "name": "Trivandrum",
                        "children": [
                            {
                                "id": 65,
                                "name": "6955584"
                            },
                            {
                                "id": 68,
                                "name": "695588"
                            }
                        ]
                    },
                    {
                        "id": 62,
                        "name": "Kollam",
                        "children": [
                            {
                                "id": 67,
                                "name": "65656"
                            }
                        ]
                    }
                ]
            },
            {
                "id": 59,
                "name": "Tamilnadu",
                "children": [
                    {
                        "id": 63,
                        "name": "Chennai",
                        "children": [
                            {
                                "id": 66,
                                "name": "695555"
                            }
                        ]
                    }
                ]
            },
            {
                "id": 60,
                "name": "Karnataka",
                "children": [
                    {
                        "id": 64,
                        "name": "Bangalore",
                        "children": [
                            {
                                "id": 69,
                                "name": "6516516"
                            }
                        ]
                    }
                ]
            }
        ],
        "shippingLevelId": 3,
        "label1": "State",
        "label2": "District",
        "label3": "Zip Code"
    },
    "message": "Success",
    "status_code": 200
}
```

###

###

###

### **6. Delete Address API**&#x20;

The Delete Address API allows users to remove a specific address from their account.

### **Endpoint**

* `{{baseurl}}/api/v1/customer/delete-address/:address_id`

### **Method**

* GET

### **Request Parameters:**

* `address_id`: The unique identifier of the address to be deleted.&#x20;

### **Request Body:**

None

### **Authorization:**

The API requires a bearer token in the request header for authentication. Users must include their valid bearer token in the "Authorization" header of the HTTP request to delete an address.

### **Response Format:**

The API responds with a JSON object indicating the status of the address deletion request.

```json
{
    "success": true,
    "data": [],
    "message": "Success",
    "status_code": 200
}
```

### **Features:**

* The Create Address API allows users to add a new address to their account.
* The Update Address API enables users to modify an existing address in their account.
* The List Addresses API provides users with a paginated view of all addresses associated with their account.
* The Set Default Address API allows users to set a specific address as their default shipping address.
* The Shipping Level API retrieves a list of available shipping levels.

### **Usage:**

* The Create Address API is used when users want to add a new address to their profile, such as a new home or work address.
* The Update Address API is called when users need to update an existing address due to changes in location or other details.
* The List Addresses API is used to display all the addresses associated with the user's account, allowing them to manage and view their address book.
* The Set Default Address API is called when users want to set a specific address as their default shipping address for convenient checkout.
* The Shipping Level API is used to fetch available shipping options during the checkout process, giving users choices for delivery.
