title | layout |
---|---|
Customer's Addresses Requests | Bagisto Web APIs Documentation |
default |
{:.pencil-icon}
edit on github{:class="edit-github" target="_blank"}
You can get all the addresses of the customers in Bagisto Store. To get the address of a customer, that customer must be logged in to the Bagisto Store. You can achieve this job by using addresses
API call resource.
http(s)://example.com/public/api/addresses
Note: In the addresses
resource API call, we used GET HTTP verb
to get all the addresses of the login customer.
http(s)://example.com/public/api/addresses
{
"data": [
{
"id": 3,
"address1": [...],
"country": "IN",
"country_name": "India",
"state": "UT",
"city": "Dehradun",
"postcode": 248001,
"phone": "01345679",
},
{
"id": 2,
"address1": [...],
"country": "IN",
"country_name": "India",
"state": "UP",
"city": "Noida",
"postcode": 201301,
"phone": "012345679",
},
{...}
],
"links": {...},
"meta": {...}
}
{:class="screenshot-dimension center"}
http(s)://example.com/public/api/addresses?page=1
http(s)://example.com/public/api/addresses?limit=5&page=1
Note: If you didn't use the page(?page=x) filter, then it returns the data of the first page by default. You can also provide the limit request parameter in the API url.
{:class="screenshot-dimension center"}
- In the response above, you will find the three Objects with the indexes mentioned below:
- data
- link
- meta
Under the data object, you will find the collection of many objects which will contain the details of address of the logged in customer. You can use the addresses index data by accessing these addresses sub-objects.
Note: Regarding both link and meta objects, we already explained these objects functionality in Category API section.
You can also get all the addresses at once without pagination of a customer from Bagisto Store. To get the addresses of a customer, that customer must be logged in Bagisto Store, for this you have to pass pagination=0
in the query parameter in API URL.
http(s)://example.com/public/api/addresses?pagination=0
{
"data": [
{
"id": 3,
"address1": [...],
"country": "IN",
"country_name": "India",
"state": "UT",
"city": "Dehradun",
"postcode": 248001,
"phone": "01345679",
},
{
"id": 2,
"address1": [...],
"country": "IN",
"country_name": "India",
"state": "UP",
"city": "Noida",
"postcode": 201301,
"phone": "012345679",
},
{...}
]
}
{:class="screenshot-dimension center"}
To get the customer's specific address, you have to pass an address_id as a request payload like addresses/{address_id}
in API url. By using this resource and request payload, you will get only a single object
under data object
in response.
http(s)://example.com/public/api/addresses/{id}
- This
addresses/{id}
API call resource will return the customer's address details, only if the customer has logged in currently into the store.
Note: In the addresses/{id}
resource API call, we used GET HTTP verb
to get the login customer's address.
http(s)://example.com/public/api/addresses/1
{
"data": {
"id": 1,
"address1": [
"Block H-ARP Park, Sector 63 "
],
"country": "IN",
"country_name": "India",
"state": "UP",
"city": "Noida",
"postcode": 201301,
"phone": "0132456789",
"created_at": {...},
"updated_at": {...}
}
}
{:class="screenshot-dimension center"}
To update the customer's specific address, you have to pass an address_id as a request payload like addresses/{address_id}
in API url.
http(s)://example.com/public/api/addresses/{id}
- This
addresses/{id}
API call resource will modify the customer's address details, only if the customer has logged in currently into the store.
Note: In the addresses/{id}
resource API call, we used PUT HTTP verb
to update the login customer's address.
http(s)://example.com/public/api/addresses/1
{
id: 3
address1: [
"Clock Tower"
]
city: "Dehradun"
country: "IN"
country_name: "India"
phone: "0123456798"
postcode: 248001
state: "UT"
created_at: {...}
updated_at: {...}
}
{
"message":"Your address has been updated successfully.",
"data": {...} // Address's detail.
}
{:class="screenshot-dimension center"}
You can also create a new address of a login customer. To add address, you have to use addresses/create
resource in API url and have to pass the address fields in Request Payload.
http(s)://example.com/public/api/addresses/create
- This
addresses/create
API call resource will create a new address of the customer, only if that customer has logged in the store.
Note: In the addresses/create
resource API call, we used POST HTTP verb
to create new customer's address.
http(s)://example.com/public/api/addresses/create
{
address1: [
"Clock Tower"
]
city: "Dehradun"
country: "IN"
country_name: "India"
phone: "0123456798"
postcode: 248001
state: "UT"
}
{
"message":"Address has been created successfully.",
"data": {...} // Address's detail.
}