Yurba.js / yurba.js / PhotosResource
Class: PhotosResource
Photos Core
delete()
delete(
photoId):Promise<BaseOkay>
Deletes a photo
Parameters
photoId
number
Photo identifier
Returns
Promise<BaseOkay>
DeletePhotoResponse Delete response
Since
1.0.0
Throws
If photo ID is invalid
Example
await rest.photos.delete(123);get()
get(
photoId):Promise<Photo>
Gets a photo by identifier
Parameters
photoId
string
Photo identifier
Returns
Promise<Photo>
Photo object
Since
1.0.0
Throws
If photo ID is invalid
Example
const photo = await rest.photos.get('123');getAll()
getAll(
page?,mode?):Promise<Photo[]>
Gets all photos (up to 12 per page)
Parameters
page?
number
Page number (optional)
mode?
"private"
Set to 'private' for private photos (optional)
Returns
Promise<Photo[]>
Array of Photo objects
Since
1.0.0
Throws
If page number is invalid
Example
const photos = await rest.photos.getAll(2);
const privatePhotos = await rest.photos.getAll(0, 'private');upload()
upload(
input,caption?,mode?,filename?):Promise<Photo>
Uploads a photo
Parameters
input
Path to photo file or Buffer
string | Buffer<ArrayBufferLike>
caption?
string
Photo caption
mode?
Photo visibility mode
"public" | "private"
filename?
string
Custom filename (optional)
Returns
Promise<Photo>
Photo Uploaded photo
Since
1.0.0
Throws
If input is invalid or caption is too long
Example
const photo = await rest.photos.upload('/path/to/photo.jpg', 'My photo', 'public');
// or with Buffer
const photo = await rest.photos.upload(buffer, 'My photo', 'public', 'image.png');