User Address
The User Address APIs provide a set of endpoints to manage the addresses associated with a user. This includes creating, retrieving, updating, and deleting addresses. Each operation is authenticated through an authorization token, ensuring that only authorized users can manage their address data.
This documentation provides examples of how to use these endpoints with sample requests and responses, making it easier for developers to integrate user address management into their applications.
POST
Create User Address
Creates a new address for the user authenticated by the provided Authorization token.
Path: https://{storefront_url}/address/
Headers:
Authorization: Token <token>
Body Parameters
Property | Data Type | Required | Descriptions |
---|---|---|---|
title | string | true | Title of the address. |
first_name | string | true | The first name of the user. |
last_name | string | true | The last name of the user. |
phone_number | string | true | The phone number of the user. |
country | integer | true | The ID of the selected country. |
city | integer | true | The ID of the selected city. |
township | integer | true | The ID of the selected township. |
district | integer | false | The ID of the selected district. |
postcode | string | false | Postcode of the address. |
line | string | true | Address details. |
notes | string | false | User's notes about the address. |
identity_number | string | false | The user's identity number. |
primary | boolean | false | Indicates if this is the primary address. |
is_corporate | boolean | false | Indicates if this is a corporate address. |
company_name | string | false | Company name if it is a corporate address. |
tax_no | string | false | Tax number if it is a corporate address. |
tax_office | string | false | Tax office if it is a corporate address. |
e_bill_taxpayer | boolean | false | Indicates if it is an e-bill taxpayer address. |
Example Request
import requests
url = "https://{storefront_url}/address/"
payload = {
"country": "1",
"is_corporate": "true",
"type": "company",
"title": "test",
"first_name": "test",
"last_name": "test",
"phone_number": "05555555555",
"city": "5",
"township": "28",
"district": "977",
"line": "test test test test test test",
"postcode": "34100",
"company_name": "test",
"tax_no": "13213213213",
"tax_office": "321321321321",
"e_bill_taxpayer": "true",
"identity_number": "231321321321",
"primary": True,
"notes": "1232321",
}
headers = {"Content-Type": "application/json"}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Example Response (201 Created)
{
"pk": 1,
"email": "akinon@akinon.com",
"phone_number": "05555555555",
"first_name": "test",
"last_name": "test",
"country": 1,
"city": 5,
"line": "test test test test test test",
"title": "test",
"township": 28,
"district": 977,
"postcode": "34100",
"notes": "1232321",
"company_name": "test",
"tax_office": "321321321321",
"tax_no": "13213213213",
"e_bill_taxpayer": true,
"hash_data": "7bbe2ebdd6891cfc7a26d4b9fa2cfff2",
"address_type": "customer",
"retail_store": null,
"remote_id": null,
"identity_number": "231321321321",
"extra_field": null,
"user": 1,
"is_corporate": true,
"primary": true
}
Response Status Codes
201 Created
: The address was successfully created.400 Bad Request
: The request was malformed or missing required parameters.401 Unauthorized
: The user is not authorized to perform this action.429 Too Many Requests
: The request limit has been exceeded.500 Internal Server Error
: An unexpected error occurred on the server.
GET
User Address List
Retrieves a list of all addresses associated with the authenticated user.
Path: https://{storefront_url}/address/detailed/
Headers:
Authorization: Token <token>
Example Request
import requests
url = "https://{storefront_url}/address/detailed/"
headers = {
'Authorization': 'Token <token>'
}
response = requests.get(url, headers=headers)
print(response.text)
Example Response (200 OK)
{
"count": 17,
"next": null,
"previous": null,
"results": [
{
"pk": 1,
"email": "akinon@akinon.com",
"phone_number": "05555555555",
"first_name": "John",
"last_name": "Doe",
"country": {
"pk": 1,
"is_active": true,
"name": "Türkiye",
"code": "tr",
"translations": null
},
"city": {
"pk": 5,
"is_active": true,
"name": "ADIYAMAN",
"country": 1,
"translations": null,
"priority": null,
"postcode": null
},
"line": "test test test test",
"title": "test",
"township": {
"pk": 28,
"is_active": true,
"name": "BESNİ",
"city": 5,
"postcode": null
},
"district": {
"pk": 977,
"is_active": true,
"name": "ABIMISTIK MAH (ÇAKIRHÜYÜK BELDESİ)",
"city": 5,
"township": 28,
"postcode": null
},
"postcode": "34100",
"notes": "1232321",
"company_name": "test",
"tax_office": "321321321321",
"tax_no": "13213213213",
"e_bill_taxpayer": true,
"hash_data": "7bbe2ebdd6891cfc7a26d4b9fa2cfff2",
"address_type": "customer",
"retail_store": null,
"remote_id": null,
"identity_number": "231321321321",
"extra_field": null,
"user": {
"pk": 3138,
"username": "58aae3c747a342ae4684b08b05d750ebe6fb1bfa126056dcf2862db1aa398ff4",
"first_name": "John",
"last_name": "Doe",
"email": "akinon@akinon.com",
"is_active": true,
"date_joined": "2022-07-25T15:06:33.969798Z",
"last_login": "2024-05-26T23:43:04.439476Z",
"email_allowed": false,
"sms_allowed": false,
"call_allowed": null,
"gender": null,
"attributes": {
"register_client_type": "default",
"logged_ip": "127.0.0.1",
"confirm": true
},
"phone": "05555555555",
"date_of_birth": null,
"attributes_kwargs": {},
"user_type": "registered",
"modified_date": "2024-04-30T08:28:19.030191Z"
},
"is_corporate": true,
"primary": true
}
]
}
Response Status Codes
200 OK
: The list of addresses was successfully retrieved.400 Bad Request
: The request was malformed or missing required parameters.401 Unauthorized
: The user is not authorized to perform this action.429 Too Many Requests
: The request limit has been exceeded.500 Internal Server Error
: An unexpected error occurred on the server.
GET
Single User Address
Retrieves information about a specific address associated with the authenticated user.
Path: https://{storefront_url}/address/<address-id>/
Headers:
Authorization: Token <token>
Example Request
import requests
url = "https://{storefront_url}/address/<address-id>/"
headers = {
'Authorization': 'Token <key>'
}
response = requests.get(url, headers=headers)
print(response.text)
Example Response (200 OK)
{
"pk": 1,
"email": "akinon@akinon.com",
"phone_number": "05555555555",
"first_name": "John",
"last_name": "Doe",
"country": 1,
"city": 5,
"line": "test",
"title": "test",
"township": 28,
"district": 977,
"postcode": "34100",
"notes": "test notes",
"company_name": "test",
"tax_office": "321321321321",
"tax_no": "13213213213",
"e_bill_taxpayer": true,
"hash_data": "7bbe2ebdd6891cfc7a26d4b9fa2cfff2",
"address_type": "customer",
"retail_store": null,
"remote_id": null,
"identity_number": "231321321321",
"extra_field": null,
"user": 1,
"is_corporate": true,
"primary": true
}
Response Status Codes
200 OK
: The address details were successfully retrieved.400 Bad Request
: The request was malformed or missing required parameters.401 Unauthorized
: The user is not authorized to perform this action.429 Too Many Requests
: The request limit has been exceeded.500 Internal Server Error
: An unexpected error occurred on the server.
GET
Single User Address Detailed
Retrieves detailed information about a specific address associated with the authenticated user.
Path: https://{storefront_url}/address/<address-id>/detailed/
Headers:
Authorization: Token <token>
Example Request
import requests
url = "https://{storefront_url}/address/<address-id>/detailed/"
headers = {
'Authorization': 'Token <key>'
}
response = requests.get(url, headers=headers)
print(response.text)
Example Response (200 OK)
{
"pk": 1,
"email": "akinon@akinon.com",
"phone_number": "05555555555",
"first_name": "John",
"last_name": "Doe",
"country": {
"pk": 1,
"is_active": true,
"name": "Türkiye",
"code": "tr",
"translations": null
},
"city": {
"pk": 5,
"is_active": true,
"name": "ADIYAMAN",
"country": 1,
"translations": null,
"priority": null,
"postcode": null
},
"line": "test",
"title": "test",
"township": {
"pk": 28,
"is_active": true,
"name": "BESNİ",
"city": 5,
"postcode": null
},
"district": {
"pk": 977,
"is_active": true,
"name": "ABIMISTIK MAH (ÇAKIRHÜYÜK BELDESİ)",
"city": 5,
"township": 28,
"postcode": null
},
"postcode": "34100",
"notes": "1232321",
"company_name": "test",
"tax_office": "321321321321",
"tax_no": "13213213213",
"e_bill_taxpayer": true,
"hash_data": "7bbe2ebdd6891cfc7a26d4b9fa2cfff2",
"address_type": "customer",
"retail_store": null,
"remote_id": null,
"identity_number": "231321321321",
"extra_field": null,
"user": {
"pk": 3138,
"username": "58aae3c747a342ae4684b08b05d750ebe6fb1bfa126056dcf2862db1aa398ff4",
"first_name": "John",
"last_name": "Doe",
"email": "ibrahim.onder@akinon.com",
"is_active": true,
"date_joined": "2022-07-25T15:06:33.969798Z",
"last_login": "2024-05-26T23:43:04.439476Z",
"email_allowed": false,
"sms_allowed": false,
"call_allowed": null,
"gender": null,
"attributes": {
"register_client_type": "default",
"logged_ip": "127.0.0.1",
"confirm": true
},
"phone": "05555555555",
"date_of_birth": null,
"attributes_kwargs": {},
"user_type": "registered",
"modified_date": "2024-04-30T08:28:19.030191Z"
},
"is_corporate": true,
"primary": true
}
Response Status Codes
200 OK
: The address details were successfully retrieved.400 Bad Request
: The request was malformed or missing required parameters.401 Unauthorized
: The user is not authorized to perform this action.429 Too Many Requests
: The request limit has been exceeded.500 Internal Server Error
: An unexpected error occurred on the server.
PUT
Update User Address
Updates a specific address associated with the authenticated user.
Path: https://{storefront_url}/address/<address-id>/
Headers:
Authorization: Token <token>
Body Parameters
Property | Data Type | Required | Descriptions |
---|---|---|---|
title | string | true | Title of the address. |
first_name | string | true | The first name of the user. |
last_name | string | true | The last name of the user. |
phone_number | string | true | The phone number of the user. |
country | integer | true | The ID of the selected country. |
city | integer | true | The ID of the selected city. |
township | integer | true | The ID of the selected township. |
district | integer | false | The ID of the selected district. |
postcode | string | false | Postcode of the address. |
line | string | true | Address details. |
notes | string | false | User's notes about the address. |
identity_number | string | false | The user's identity number. |
primary | boolean | false | Indicates if this is the primary address. |
is_corporate | boolean | false | Indicates if this is a corporate address. |
company_name | string | false | Company name if it is a corporate address. |
tax_no | string | false | Tax number if it is a corporate address. |
tax_office | string | false | Tax office if it is a corporate address. |
e_bill_taxpayer | boolean | false | Indicates if it is an e-bill taxpayer address. |
Example Request
import requests
url = "https://{storefront_url}/address/<address-id>/"
payload = {
"country": "1",
"is_corporate": "true",
"type": "company",
"title": "test",
"first_name": "test",
"last_name": "test",
"phone_number": "05555555555",
"city": "5",
"township": "28",
"district": "977",
"line": "new address line",
"postcode": "34100",
"company_name": "test",
"tax_no": "13213213213",
"tax_office": "321321321321",
"e_bill_taxpayer": "true",
"identity_number": "231321321321",
"primary": True,
"notes": "1232321",
}
headers = {"Content-Type": "application/json"}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
Example Response (200 OK)
{
"pk": 1,
"email": "akinon@akinon.com",
"phone_number": "05555555555",
"first_name": "test",
"last_name": "test",
"country": 1,
"city": 5,
"line": "test test test test test test",
"title": "test",
"township": 28,
"district": 977,
"postcode": "34100",
"notes": "1232321",
"company_name": "test",
"tax_office": "321321321321",
"tax_no": "13213213213",
"e_bill_taxpayer": true,
"hash_data": "7bbe2ebdd6891cfc7a26d4b9fa2cfff2",
"address_type": "customer",
"retail_store": null,
"remote_id": null,
"identity_number": "231321321321",
"extra_field": null,
"user": 1,
"is_corporate": true,
"primary": true
}
Response Status Codes
200 OK
: The address was successfully updated.400 Bad Request
: The request was malformed or missing required parameters.401 Unauthorized
: The user is not authorized to perform this action.429 Too Many Requests
: The request limit has been exceeded.500 Internal Server Error
: An unexpected error occurred on the server.
PATCH
Partial Update User Address
Partially updates a specific address associated with the authenticated user.
Path: https://{storefront_url}/address/<address-id>/
Headers:
Authorization: Token <token>
Body Parameters
Property | Data Type | Required | Descriptions |
---|---|---|---|
title | string | true | Title of the address. |
first_name | string | true | The first name of the user. |
last_name | string | true | The last name of the user. |
phone_number | string | true | The phone number of the user. |
country | integer | true | The ID of the selected country. |
city | integer | true | The ID of the selected city. |
township | integer | true | The ID of the selected township. |
district | integer | false | The ID of the selected district. |
postcode | string | false | Postcode of the address. |
line | string | true | Address details. |
notes | string | false | User's notes about the address. |
identity_number | string | false | The user's identity number. |
primary | boolean | false | Indicates if this is the primary address. |
is_corporate | boolean | false | Indicates if this is a corporate address. |
company_name | string | false | Company name if it is a corporate address. |
tax_no | string | false | Tax number if it is a corporate address. |
tax_office | string | false | Tax office if it is a corporate address. |
e_bill_taxpayer | boolean | false | Indicates if it is an e-bill taxpayer address. |
Example Request
import requests
url = "https://{storefront_url}/address/<address-id>/"
payload = {
"primary": True,
}
headers = {"Content-Type": "application/json"}
response = requests.request("PATCH", url, headers=headers, data=payload)
print(response.text)
Example Response (200 OK)
{
"pk": 1,
"email": "akinon@akinon.com",
"phone_number": "05555555555",
"first_name": "test",
"last_name": "test",
"country": 1,
"city": 5,
"line": "test test test test test test",
"title": "test",
"township": 28,
"district": 977,
"postcode": "34100",
"notes": "1232321",
"company_name": "test",
"tax_office": "321321321321",
"tax_no": "13213213213",
"e_bill_taxpayer": true,
"hash_data": "7bbe2ebdd6891cfc7a26d4b9fa2cfff2",
"address_type": "customer",
"retail_store": null,
"remote_id": null,
"identity_number": "231321321321",
"extra_field": null,
"user": 1,
"is_corporate": true,
"primary": true
}
Response Status Codes
200 OK
: The address was successfully updated.400 Bad Request
: The request was malformed or missing required parameters.401 Unauthorized
: The user is not authorized to perform this action.429 Too Many Requests
: The request limit has been exceeded.500 Internal Server Error
: An unexpected error occurred on the server.
DELETE
Delete User Address
Deletes a specific address associated with the authenticated user.
Path: https://{storefront_url}/address/<address-id>/
Headers:
Authorization: Token <token>
Example Request
import requests
url = "https://{storefront_url}/address/<address-id>/"
headers = {
'Authorization': 'Token <key>'
}
response = requests.request("DELETE", url, headers=headers)
print(response.text)
Example Response (204 No Content)
If the request is processed successfully, the response is shown with code 204 and the address is deleted. If the request fails, an appropriate error code along with an error message is returned.
Response Status Codes
204 No Content
: The address was successfully deleted.400 Bad Request
: The request was malformed or missing required parameters.401 Unauthorized
: The user is not authorized to perform this action.429 Too Many Requests
: The request limit has been exceeded.500 Internal Server Error
: An unexpected error occurred on the server.
GET
Address Country
This endpoint is used to list all available countries.
Path: https://{storefront_url}/address/country/
Example Request
import requests
url = "https://{storefront_url}/address/country/"
response = requests.get(url)
print(response.text)
Example Response (200 OK)
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"pk": 100,
"is_active": true,
"name": "romania",
"code": "RO",
"translations": null
},
{
"pk": 1,
"is_active": true,
"name": "Türkiye",
"code": "tr",
"translations": null
}
]
}
Response Status Codes
200 OK
: The request was successful, and the requested resource is returned in the response.400 Bad Request
: The request was malformed or contained invalid parameters.401 Unauthorized
: The user is not authorized to access the requested resource.429 Too Many Requests
: The request rate limit has been exceeded.500 Internal Server Error
: An unexpected error occurred on the server.
GET
Address City
This endpoint is used to list all cities for a specified country.
Path: https://{storefront_url}/address/address/city/
Request Parameters
Property | Data Type | Descriptions |
---|---|---|
country | id | The ID of the country. |
Example Request
import requests
url = "https://{storefront_url}/address/city/?country=<country-id>"
response = requests.get(url)
print(response.text)
Example Response (200 OK)
{
"count": 83,
"next": null,
"previous": null,
"results": [
{
"pk": 5,
"is_active": true,
"name": "ADIYAMAN",
"country": 1,
"translations": null,
"priority": null,
"postcode": null
}
]
}
Response Status Codes
200 OK
: The request was successful, and the requested resource is returned in the response.400 Bad Request
: The request was malformed or contained invalid parameters.401 Unauthorized
: The user is not authorized to access the requested resource.429 Too Many Requests
: The request rate limit has been exceeded.500 Internal Server Error
: An unexpected error occurred on the server.
GET
Address Township
This endpoint is used to list all townships for a specified city.
Path: https://{storefront_url}/address/address/township/
Request Parameters
Property | Data Type | Descriptions |
---|---|---|
city | id | The ID of the city. |
Example Request
import requests
url = "https://{storefront_url}/address/township/?city=<city-id>"
response = requests.get(url)
print(response.text)
Example Response (200 OK)
{
"count": 9,
"next": null,
"previous": null,
"results": [
{
"pk": 20,
"is_active": true,
"name": "TUT",
"city": 5,
"postcode": null
}
]
}
Response Status Codes
200 OK
: The request was successful, and the requested resource is returned in the response.400 Bad Request
: The request was malformed or contained invalid parameters.401 Unauthorized
: The user is not authorized to access the requested resource.429 Too Many Requests
: The request rate limit has been exceeded.500 Internal Server Error
: An unexpected error occurred on the server.
GET
Address District
This endpoint is used to list all districts for a specified township.
Path: https://{storefront_url}/address/address/district/
Request Parameters
Property | Data Type | Descriptions |
---|---|---|
township | id | The ID of the township. |
Example Request
import requests
url = "https://{storefront_url}/address/district/?township=<township-id>"
response = requests.get(url)
print(response.text)
Example Response (200 OK)
{
"count": 154,
"next": null,
"previous": null,
"results": [
{
"pk": 872,
"is_active": true,
"name": "ZORMAĞARA MAH (YENİKÖY KÖYÜ)",
"city": 5,
"township": 28,
"postcode": null
}
]
}
Response Status Codes
200 OK
: The request was successful, and the requested resource is returned in the response.400 Bad Request
: The request was malformed or contained invalid parameters.401 Unauthorized
: The user is not authorized to access the requested resource.429 Too Many Requests
: The request rate limit has been exceeded.500 Internal Server Error
: An unexpected error occurred on the server.