Home | Index

Address Book XML/JSON API Developer Guide

Example (JSON)

The most interesting exchange from the above scenario is the last request, where the application submits an update and at the same time it retrieves updates.

The Request follows:

POST http://address.yahooapis.com/v1/synchronize
   ?format=json
   &myrev=43
{ "type": "sync_request",
  "events": [
    { "type": "add_contact",
      "fields": [
        { "type": "add_name",
          "first": "Jane",
          "last": "Bishop",
        },
        { "type": "add_phone",
          "mobile": true,
          "data": "415-205-9999"
        }
      ],
      "categories": [
        { "type": "add_to_category",
          "data": "Mobile_Friends"
        }
      ]
    }
  ]
}

Here is the Response, which includes the confirmation and two change events, the second of which was caused by the Request itself:

{ "type": "sync_response",
  "lmt": 1168961062,
  "rev": 46,
  "categories": [
    { "type": "category",
      "catid": 7,
      "data":  "Messenger_Buddies"
    },
    { "type": "category",
      "catid": 23,
      "data":  "Family"
    },
    { "type": "category",
      "catid": 599,
      "data":  "Mobile_Friends"
    }
  ],
  "results": [
    { "type": "success",
      "add_action": "add",
      "cid": 543
    }
  ],
  "events" : [
    { "type": "update_contact",
      "cid": 511,
      "fields" : [
        { "type": "name",
          "fid": 512,
          "first": "John",
          "last": "Smith"
        }
      ]
    },
    { "type": "update_contact",
      "cid": 543,
      "fields" : [
        { "type": "name",
          "fid": 600,
          "first": "Jane",
          "last": "Bishop",
        },
        { "type": "phone",
          "fid": 523,
          "mobile": true,
          "data": "415-205-9999"
        },
        { "type": "yahooid",
          "fid": 524,
          "data": "jane.bishop"
        }
      ],
      "categories": [
        { "type": "category",
          "catid": 599
        }
      ]
    }
  ]
}