API Address

From Spiffy Stores Knowledge Base

The Address resource stores the addresses that a customer has entered. Each customer can have multiple addresses associated with their account.

Address Properties

id
{ "id" : 123456789 }

A unique numeric identifier for the address.

title
{ "title": "Mr" }

The salutation or title for the customer.

first_name
{ "first_name": "Bilbo" }

The customer's first name.

last_name
{ "last_name": "Baggins" }

The customer's last name.

name
{ "name": "Mr Bilbo Baggins" }

The customer's full name.

company
{ "company": "The Fellowship of the Ring" }

The customer's company name.

address1
{ "address1": "2 Bag End" }

The customer's first address line.

address2
{ "address2": "" }

The customer's second address line.

city
{ "city": "Hobbiton" }

The customer's city.

province
{ "province": "Waikato" }

The customer's province, state or region.

province_code
{ "province_code": "WKO" }

The customer's province, state or region code.

country
{ "country": "New Zealand" }

The customer's country.

country_code
{ "country_code": "NZ" }

The customer's country code.

zip
{ "zip": "1234" }

The customer's postal code.

phone
{ "phone": "123456789" }

The customer's phone number.

default
{ "default": true }

This is the default address for the customer.

Endpoints

GET /api/customers/CUSTOMER_ID/addresses.json

Retrieve a list of addresses for the customer.

Optional Parameters

limit Number of results returned. The default is 30, with a maximum of 50 in a single request.
page The number of the page to return. The number of results per page is set by the limit parameter. If more results are required, then submit the request again, increasing the page number each time.
fields A comma-separated list of fields to return in the response.

Example Request and Response

GET /api/customers/4123/addresses.json

HTTP/1.1 200 OK

{
  "addressess": [
    {
      "id": 1969,
      "title": "Mr",
      "first_name": "Bilbo",
      "last_name": "Baggins",
      "name": "Mr Bilbo Baggins",
      "company": "The Fellowship of the Ring",
      "address1": "2 Bag End",
      "address2": "",
      "city": "Hobbiton",
      "province": "Waikato",
      "province_code": "WKO",
      "country": "New Zealand",
      "country_code": "NZ",
      "zip": "1234",
      "phone": "123456789",
      "default": true
    }, ...
  ]
}

Examples using filters

GET /api/customers/4123/addresses.json?fields=id,name,country

GET /api/customers/CUSTOMER_ID/addresses/count.json

Return a count of the number of addresses belonging to a customer.

Example Request and Response

GET /api/customers/4123/addresses/count.json

HTTP/1.1 200 OK

{
  "count": 5
}

GET /api/customers/CUSTOMER_ID/addresses/ADDRESS_ID.json

Retrieves a single address by ID.

Optional Parameters

fields A comma-separated list of fields to return in the response.

Example Request and Response

GET /api/customers/4123/addresses/1969.json

HTTP/1.1 200 OK

{
  "address": {
    "id": 1969,
    "title": "Mr",
    "first_name": "Bilbo",
    "last_name": "Baggins",
    "name": "Mr Bilbo Baggins",
    "company": "The Fellowship of the Ring",
    "address1": "2 Bag End",
    "address2": "",
    "city": "Hobbiton",
    "province": "Waikato",
    "province_code": "WKO",
    "country": "New Zealand",
    "country_code": "NZ",
    "zip": "1234",
    "phone": "123456789",
    "default": true
  }
}

POST /api/customers/CUSTOMER_ID/addresses.json

Creates an address for the customer.

Example Request and Response

POST /api/customers/4123/addresses.json

{
  "address": {
    "title": "Mr",
    "first_name": "Gandalf",
    "last_name": "Wizard",
    ...
  }
}

HTTP/1.1 201 Created

PUT /api/customers/CUSTOMER_ID/addresses/ADDRESS_ID.json

Updates an address for the customer.

Example Request and Response

PUT /api/customers/4123/addresses/1969.json

{
  "address": {
    "id": 1969,
    "phone": "987654321"
  }
}

HTTP/1.1 200 OK

DELETE /api/customers/CUSTOMER_ID/addresses/ADDRESS_ID.json

Deletes a address from the customer.

Example Request and Response

DELETE /api/customers/4123/addresses/1969.json

HTTP/1.1 200 OK

{}

Further Reference