Class: PhotosResource
Photos Core
.delete(photoId): Promise<BaseOkay>
1.0.0
Deletes a photo
Parameters
| Name | Type | Description |
|---|---|---|
photoId | number | Photo identifier |
Returns
Promise<BaseOkay>
Delete response
Throws
If photo ID is invalid
Example
javascript
await rest.photos.delete(123);.get(photoId): Promise<Photo>
1.0.0
Gets a photo by identifier
Parameters
| Name | Type | Description |
|---|---|---|
photoId | string | Photo identifier |
Returns
Promise<Photo>
Photo object
Throws
If photo ID is invalid
Example
javascript
const photo = await rest.photos.get('123');.getAll(page?, mode?): Promise<Photo[]>
1.0.0
GET /photos
Gets all photos (up to 12 per page)
Parameters
| Name | Type | Description |
|---|---|---|
page? | number | Page number (optional) |
mode? | "private" | Set to 'private' for private photos (optional) |
Returns
Promise<Photo[]>
Array of Photo objects
Throws
If page number is invalid
Example
javascript
const photos = await rest.photos.getAll(2);
const privatePhotos = await rest.photos.getAll(0, 'private');.upload(input, caption, mode, filename?): Promise<Photo>
1.0.0
Uploads a photo
Parameters
| Name | Type | Description |
|---|---|---|
input | string | Blob | Buffer<ArrayBufferLike> | Path to photo file or Buffer |
caption? | string | Photo caption |
mode? | "public" | "private" | Photo visibility mode |
filename? | string | Custom filename (optional) |
Returns
Promise<Photo>
Photo Uploaded photo
Throws
If input is invalid or caption is too long
Example
javascript
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');