| | JSON-представление
API поддерживает представление ресурсов в JSON-формате. В данном формате можно получить сервисный документ или коллекцию альбомов, создать новый альбом или редактировать отдельный альбом или фотографию (см. примеры Получение данных фотографии в формате JSON и Редактирование фотографии в формате JSON).
В JSON элементы представляются с помощью ассоциативных массивов, содержащих пары "ключ": "значение".

Пример
GET /api/users/alekna/photo/440606/ HTTP/1.1
Host: api-fotki.yandex.ru
Accept: application/json
Authorization: OAuth eb1c55f34...
Ответ сервера: HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Location: http://api-fotki.yandex.ru/api/users/alekna/photo/440606/
Content-Location: http://fotki.yandex.ru/users/alekna/view/440606/
{
"edited": "2011-04-18T11:15:59Z",
"updated": "2011-04-18T11:15:59Z",
"img": {
"XXS": {
"width": 75,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_XXS",
"height": 75
},
"XL": {
"width": 800,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_XL",
"height": 724
},
"M": {
"width": 300,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_M",
"height": 272
},
"L": {
"width": 500,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_L",
"height": 453
},
"XXXS": {
"width": 50,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_XXXS",
"height": 50
},
"S": {
"width": 150,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_S",
"height": 136
},
"XS": {
"width": 100,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_XS",
"height": 91
},
"orig": {
"width": 800,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_orig",
"height": 724
}
},
"links": {
"album": "http://api-fotki.yandex.ru/api/users/alena/album/166472/",
"editMedia": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_orig",
"self": "http://api-fotki.yandex.ru/api/users/alena/photo/440606/",
"alternate": "http://fotki.yandex.ru/users/alena/view/440606/",
"edit": "http://api-fotki.yandex.ru/api/users/alena/photo/440606/"
},
"title": "Путешествие в Германии",
"xxx": false,
"summary": "Дело было прошлым летом",
"access": "private",
"disableComments": false,
"published": "2011-04-18T10:19:08Z",
"hideOriginal": false,
"author": "alekna",
"id": "urn:yandex:fotki:alekna:photo:440606"
}
Пример
В полученном Entry фотографии были изменены ее название, а также уровень доступа: PUT /api/users/alena/photo/440606/ HTTP/1.1
Host: api-fotki.yandex.ru
Content-Type: application/json
Authorization: OAuth eb1c55f34...
{
"edited": "2011-04-18T11:15:59Z",
"updated": "2011-04-18T11:15:59Z",
"img": {
"XXS": {
"width": 75,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_XXS",
"height": 75
},
"XL": {
"width": 800,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_XL",
"height": 724
},
"M": {
"width": 300,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_M",
"height": 272
},
"L": {
"width": 500,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_L",
"height": 453
},
"XXXS": {
"width": 50,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_XXXS",
"height": 50
},
"S": {
"width": 150,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_S",
"height": 136
},
"XS": {
"width": 100,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_XS",
"height": 91
},
"orig": {
"width": 800,
"href": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_orig",
"height": 724
}
},
"links": {
"album": "http://api-fotki.yandex.ru/api/users/alena/album/166472/",
"editMedia": "http://img-fotki.yandex.ru/get/5804/alena.0/0_6b91e_a63b0f23_orig",
"self": "http://api-fotki.yandex.ru/api/users/alena/photo/440606/",
"alternate": "http://fotki.yandex.ru/users/alena/view/440606/",
"edit": "http://api-fotki.yandex.ru/api/users/alena/photo/440606/"
},
"title": "Поездка в Германию",
"xxx": false,
"summary": "Дело было прошлым летом",
"access": "public",
"disableComments": false,
"published": "2011-04-18T10:19:08Z",
"hideOriginal": false,
"author": "alena",
"id": "urn:yandex:fotki:alekna:photo:440606"
}
Пример
Имя функции обратного вызова указывается в query-параметре callback:
http://api-fotki.yandex.ru/api/users/alekna/photo/62107/?format=json&callback=eatme.
| |