Address Migration
This guide covers the process of migrating address data using an API. Address migration allows users to import address data into their system from a migration file in CSV, XLS, or JSON format. The column names in the migration file must match the field names listed in the table below.
Fields and Descriptions
User Data
Field Names | Data Type | Required | Descriptions |
user | string | true | Customer Code of the user. |
string | true | The email of the user. | |
phone_number | string | false | The phone number of the address |
first_name | string | true | First name of the recipient (max 255 characters) |
last_name | string | true | Last name of the recipient (max 255 characters) |
title | string | false | The address title (max 128 characters) |
line | string | true | The address line (max 255 characters) |
tax_office | string | false | For legal entities |
tax_no | sting | false | For legal entities |
country | sting | true | Must match the name in the database case-insensitively |
city | sting | true | Must match the name in the database case-insensitively |
township | string | true | Must match the name in the database case-insensitively |
district | string | false | Must match the name in the database case-insensitively |
company_name | string | false | For legal entities |
Parameters
Parameter | Data Type | In | Descriptions |
chanel_id | integer | url | The id of the shop channel |
[api_token] | string | header | The API key of the customer account |
[files] | disct | body | The dictionary includes the file descriptor or the migration file |
[migration_key] | string | url | The type of migration (user, address, order, order_item etc.) |
POST
Starting the Migration
Path: /api/v1/remote/{channel_id}/migrations/start/{migration_key}
To start the address migration, send a request to the /api/v1/remote/{channel_id}/migrations/start/{migration_key} endpoint and trigger the migration queue. In this case, set the migration key value to "address".
Request
import requests
import json
url = "https://{customer_api_url}/api/v1/remote/{channel_id}/migrations/start/{migration_type}/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"
headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}
files = {'file': open('/path/to/file/address.csv','rb')}
response = requests.post(url, headers=headers, files=files)
print(response.text)
Response
As a result of the request, a response with a 200 OK status code will be recieved, and it will contain the migration ID.
{
"migration_id":"4d6f7650799f484d875a89adf8d472b8"
}
GET
Checking Migration Progress
Path: /api/v1/remote/{channel_id}/migrations/{migration_id}/progress/
This method is used to check the progress of the migration by sending a request to the /api/v1/remote/{channel_id}/migrations/{migration_id}/progress/ endpoint, providing the parameters mentioned earlier.
Request
import requests
url = "https://{customer_api_url}/api/v1/remote/{channel_id}/migrations/{migration_id}/progress/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"
headers = {
'content-type': 'application/json',
'Authorization': 'Token {}'.format(api_token)
}
response = requests.get(url, headers=headers)
print(response.text)
Response
As a result of the request, a response with a 200 OK status code will be recieved, and it will contain the following values in the response body:
{
"Processed_count": 1000,
"Error_count": 0,
"total_count": 1000
}