RESTful API of Media Files Bounded Context
Headers
As API is working with JSON every request must add the following headers:
Accept: application/json
And for request with body:
Content-Type: application/json
In order to use this API we must authenticate using the user&identity bounded context, and the token must be set in the request header:
Authorization: aa.bb.cc
User Impersonation
It is possible for an admin user (role mediafiles_admin) to make requests on behalf of other users. The request is processed as if the impersonated user did the request himself.
The following headers must be added in order to impersonate a user with the desired roles:
X-Impersonated-User-Id: johndoe@spotahome.com
X-Impersonated-User-Roles: mediafiles_uploader
The X-Impersonated-User-Roles accepts a comma-separated list of roles for the impersonated user.
Albums ¶
Albums ¶
Creation of a new albumPOST/albums
Example URI
Headers
Content-Type: application/json
Authorization: aa.bb.ccBody
{
"title": "Gardening videos",
"categoryId": "listingsMadrid",
"reference": "90942"
}Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"title": {
"type": "string"
},
"categoryId": {
"type": "string"
},
"reference": {
"type": "string"
}
},
"required": [
"title",
"categoryId"
]
}201Headers
Location: /albums/8f2dbe69-b68f-4423-bc93-b8b036727a032Retrieve albums by criteriaGET/albums{?categoryId}{?reference}{?page}{?itemsPerPage}
Example URI
- categoryId
string(optional) Example: listingsMadrid- reference
string(optional) Example: 90987- page
number(optional) Example: 1- itemsPerPage
number(optional) Example: 10
Headers
Content-Type: application/json
Authorization: aa.bb.cc200Headers
Content-Type: application/jsonBody
{
"count": 1,
"total": 28,
"_links": {
"self": {
"href": "/albums?itemsPerPage=1&page=1"
},
"first": {
"href": "/albums?itemsPerPage=1&page=1"
},
"last": {
"href": "/albums?itemsPerPage=1&page=28"
},
"next": {
"href": "/albums?itemsPerPage=1&page=2"
}
},
"_embedded": {
"albums": [
{
"_id": "853d5ee1-dbec-4015-843c-cb55943a1c7b",
"title": "Gardening videos",
"categoryId": "listingsBarcelona",
"reference": "90876",
"status": "complete",
"videoIds": [
"653d5ee1-dbec-4015-843c-cb55943a1c7c",
"153d5ee1-dbec-4015-843c-cb55943a1c7d",
"953d5ee1-dbec-4015-843c-cb55943a1c7e",
"f53d5ee1-dbec-4015-843c-cb55943a1c7f"
],
"photoIds": [],
"video360Ids": [],
"photo360Ids": [],
"creationUser": "maikel@spotahome.com",
"updateUser": "hugo@spotahome.com",
"creationDate": "2017-01-03T09:00:00+01:00",
"updateDate": "2017-01-03T09:00:00+01:00"
},
{
"_id": "38ef38ab-352d-3561-5976-cb55943a1c7b",
"title": "Gardening videos 2",
"categoryId": "listingsBarcelona",
"reference": "90877",
"status": "complete",
"videoIds": [
"653d5ee1-dbec-4015-843c-cb55943a1c7c",
"153d5ee1-dbec-4015-843c-cb55943a1c7d",
"953d5ee1-dbec-4015-843c-cb55943a1c7e",
"f53d5ee1-dbec-4015-843c-cb55943a1c7f"
],
"photoIds": [],
"video360Ids": [],
"photo360Ids": [],
"creationUser": "maikel@spotahome.com",
"updateUser": "hugo@spotahome.com",
"creationDate": "2017-01-03T09:00:00+01:00",
"updateDate": "2017-01-03T09:00:00+01:00"
}
]
}
Album with an ID ¶
Fetch single albumGET/albums/{id}
Example URI
- id
string(required) Example: 853d5ee1-dbec-4015-843c-cb55943a1c7bId of an album.
Headers
Content-Type: application/json
Authorization: aa.bb.cc200Headers
Content-Type: application/jsonBody
{
"_id": "853d5ee1-dbec-4015-843c-cb55943a1c7b",
"title": "Gardening videos",
"categoryId": "listingsMadrid",
"reference": "90876",
"status": "draft",
"videoIds": [
"653d5ee1-dbec-4015-843c-cb55943a1c7c",
"153d5ee1-dbec-4015-843c-cb55943a1c7d",
"953d5ee1-dbec-4015-843c-cb55943a1c7e",
"f53d5ee1-dbec-4015-843c-cb55943a1c7f"
],
"photoIds": [],
"video360Ids": [],
"photo360Ids": [],
"creationUser": "maikel@spotahome.com",
"updateUser": "hugo@spotahome.com",
"creationDate": "2017-01-03T09:00:00+01:00",
"updateDate": "2017-01-03T09:00:00+01:00"
}Update single albumPUT/albums/{id}
Example URI
- id
string(required) Example: 853d5ee1-dbec-4015-843c-cb55943a1c7bId of an album.
Headers
Content-Type: application/json
Authorization: aa.bb.ccBody
{
"title": "Gardening videos",
"reference": "90942"
}Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"title": {
"type": "string"
},
"reference": {
"type": "string"
}
}
}204Headers
Content-Type: application/jsonDelete single albumDELETE/albums/{id}
Example URI
- id
string(required) Example: 853d5ee1-dbec-4015-843c-cb55943a1c7bId of an album.
Headers
Content-Type: application/json
Authorization: aa.bb.cc204Complete Album ¶
Mark an album as completedPUT/albums/{id}/complete
Example URI
- id
string(required) Example: 853d5ee1-dbec-4015-843c-cb55943a1c7bId of an album.
Headers
Content-Type: application/json
Authorization: aa.bb.cc204Album publication ¶
Mark an album as publishedPUT/albums/{id}/publication
Example URI
- id
string(required) Example: 853d5ee1-dbec-4015-843c-cb55943a1c7bId of an album.
Headers
Content-Type: application/json
Authorization: aa.bb.cc204Videos ¶
Video with an ID ¶
Creation of a new videoPOST/videos/
Example URI
Headers
Content-Type: application/json
Authorization: aa.bb.ccBody
{
"title": "Video of Property 1234",
"albumId": "853d5ee1-dbec-4015-843c-cb55943a1c7b"
}Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"title": {
"type": "string"
},
"albumId": {
"type": "string"
}
},
"required": [
"title",
"albumId"
]
}201Headers
Location: /videos/8f2dbe69-b68f-4423-bc93-b8b036727a032Fetch a specific videoGET/videos/{id}
Example URI
- id
string(required) Example: y53d5ee1-dbec-4015-843c-cb55943a1c7bId of a video.
Headers
Content-Type: application/json
Authorization: aa.bb.cc200Body
{
"_id": "y53d5ee1-dbec-4015-843c-cb55943a1c7b",
"name": "Listings Madrid - 123124",
"albumId": "853d5ee1-dbec-4015-843c-cb55943a1c7b"
"platforms": [
{
"name": "youtube",
"videoId": "123124",
"videoURL": "http://youtu.be/123124"
}
]
"creationUser": "maikel@spotahome.com",
"updateUser": "hugo@spotahome.com",
"creationDate": "2017-01-03T09:00:00+01:00",
"updateDate": "2017-01-03T09:00:00+01:00"
}404Headers
Content-Type: application/jsonBody
{
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title": "Not Found",
"status": 404,
"detail": "Video 'y53d5ee1-dbec-4015-843c-cb55943a1c7b' not found"
}Video chunks upload ¶
Upload a video chunkPOST/videos/{id}/chunks
Example URI
- id
string(required) Example: 853d5ee1-dbec-4015-843c-cb55943a1c7bId of a video.
Headers
Content-Type: application/json200Verify a video chunkGET/videos/{id}/chunks
Example URI
- id
string(required) Example: 853d5ee1-dbec-4015-843c-cb55943a1c7bId of a video.
Headers
Content-Type: application/json200404Finish Video chunks upload ¶
Finish the upload of the chunksPUT/albums/{id}/chunks/finish
Example URI
- id
string(required) Example: 853d5ee1-dbec-4015-843c-cb55943a1c7bId of a video.
Headers
Content-Type: application/json
Authorization: aa.bb.cc204