Skip to content
Ryan Christiani edited this page Apr 29, 2016 · 6 revisions

##Authentication All routes require you to be authorized. Make a GET request to /v1/user/authenticate to get your token. Every authenticated route requires a x-access-token header with your token sent.

####Available fields

{
    _id: String,
    name: String,
    path: String,
    created_at: Number,
}

###/v1/media GET Get all media

Headers Value Description
x-access-token : string token Token received from authentication.
Query Value Description
limit : number defaults to 0(all) A the number of items you want returned
offset : number defaults to 0 Offset number, used for parination

Response

{
    totalCount: 100,
	media: [ 
		{ 
			_id: '565918952bd03ab319518ce5',
			path: 'https://hychalknotes.s3.amazonaws.com/nodeschool.jpg',
			name: 'nodeschool.jpg',
			created_at: 1448679573552 
		},
		{ 
			_id: '56591d45bb8885c51abe3f39',
			path: 'https://hychalknotes.s3.amazonaws.com/unnamed.png',
			name: 'unnamed.png',
			created_at: 1448680773305 
		}
	]
}

###/v1/media POST Upload media

Headers Value Description
x-access-token : string token Token received from authentication.

Request AJAX example.

let data = new FormData();
data.append( 'file', file[0] );
$.ajax({
	url: `api-url/v1/media`,
	method: 'POST',
	data: data,
	processData: false,
	contentType: false
});

Response

{
	media:  { 
		    _id: '565918952bd03ab319518ce5',
		    path: 'https://hychalknotes.s3.amazonaws.com/nodeschool.jpg',
		    name: 'nodeschool.jpg',
		    created_at: 1448679573552 
		}
	]
}

###/v1/media/:name DELETE Delete media

Headers Value Description
x-access-token : string token Token received from authentication.
Params Value Description
name : string image.jpg Name of file from media object

Response

{
    media: []
}
Clone this wiki locally