In this part of the documentation you can learn more about the API's countries resource. With this resource, it is possible to retrieve, update and delete any country of your shop. We will also have a look at the associated data structures.
This resource supports the following operations:
Access URL | GET | GET (List) | PUT | PUT (Batch) | POST | DELETE | DELETE (Batch) |
---|---|---|---|---|---|---|---|
/api/countries |
If you want to access this resource, simply append your shop URL with
It is required to parametrize this API call. The following parameters are available:
Identifier | Parameter | DB column | Example call |
---|---|---|---|
Country Id | id | s_core_countries.id | /api/countries/2 |
Model | Table |
---|---|
Shopware\Models\Country\Country | s_core_countries |
Field | Type | Original Object |
---|---|---|
id | integer (primary key) | |
name | string | |
iso | string | |
isoName | string | |
position | integer | |
description | string | |
shippingFree | boolean | |
taxFree | boolean | |
taxFreeUstId | boolean | |
taxFreeUstIdChecked | boolean | |
active | boolean | |
iso3 | string | |
displayStateInRegistration | boolean | |
forceStateInRegistration | boolean | |
areaId | integer (foreign key) | Area |
states | object array | State |
For this operation no parameters are required. To get a list of all countries, simply query:
Model | Table |
---|---|
Shopware\Models\Country\Country | s_core_countries |
This API call returns an array of elements, one for each country. Each of these elements has the following structure:
Field | Type | Original Object |
---|---|---|
id | integer (primary key) | |
name | string | |
iso | string | |
isoName | string | |
position | integer | |
description | string | |
shippingFree | boolean | |
taxFree | boolean | |
taxFreeUstId | boolean | |
taxFreeUstIdChecked | boolean | |
active | boolean | |
iso3 | string | |
displayStateInRegistration | boolean | |
forceStateInRegistration | boolean | |
areaId | integer (foreign key) | Area |
states | object array | State | |
Appended to the above mentioned list, you will also find the following data:
Field | Type | Comment |
---|---|---|
total | integer | The total number of country resources |
success | boolean | Indicates if the call was successful or not. |
To POST
or PUT
content, use the same data as provided in the GET operation.
To delete a country, simply call the specified resource with the DELETE
operation, as the following example shows:
Replace the id
with the specific country id.