Retrieve public details on a given user.
Get a list of photos uploaded by a user.
Get a list of photos liked by a user.
photos.listPhotos(page, perPage)
Get a single page from the list of all photos.
Arguments
Argument | Type | Opt/Required |
---|
page | number | Optional |
perPage | number | Optional |
Example
unsplash.photos.listPhotos(2, 15)
.then(toJson)
.then(json => {
});
photos.searchPhotos(query, category, page, perPage)
Get a single page from a photo search. Optionally limit your search to a set of categories by supplying the category ID’s.
Arguments
Argument | Type | Opt/Required |
---|
query | string | Optional |
category | Array | Optional |
page | number | Optional |
perPage | number | Optional |
Example
unsplash.photos.searchPhotos("cats", [11, 88], 1, 15)
.then(toJson)
.then(json => {
});
photos.getPhoto(id, width, height, rectangle)
Retrieve a single photo.
Arguments
Argument | Type | Opt/Required |
---|
id | string | Required |
width | number | Optional |
height | number | Optional |
rectangle | Array | Optional |
Example
unsplash.photos.getPhoto("mtNweauBsMQ", 1920, 1080, [0, 0, 1920, 1080])
.then(toJson)
.then(json => {
});
photos.getRandomPhoto(category, featured, username, query, width, height)
Retrieve a single random photo, given optional filters.
Arguments
Argument | Type | Opt/Required |
---|
category | Array | Optional |
featured | boolean | Optional |
username | string | Optional |
query | string | Optional |
width | number | Optional |
height | number | Optional |
Example
unsplash.photos.getRandomPhoto([88], true, "naoufal", "cats", 1920, 1080)
.then(toJson)
.then(json => {
});
photos.uploadPhoto(photo)
Upload a photo on behalf of the logged-in user. This requires the write_photos
scope.
Arguments
Argument | Type | Opt/Required |
---|
photo | Image Binary | Required |
Example
import { createReadStream } from "fs";
unsplash.photos.uploadPhoto(createReadStream(__dirname + "path/to/image"))
.then(toJson)
.then(json => {
});
photos.likePhoto(id)
Like a photo on behalf of the logged-in user. This requires the write_likes
scope.
Arguments
Argument | Type | Opt/Required |
---|
id | string | Required |
Example
unsplash.photos.likePhoto("mtNweauBsMQ")
.then(toJson)
.then(json => {
});
photos.unlikePhoto(id)
Remove a user’s like of a photo.
Arguments
Argument | Type | Opt/Required |
---|
id | string | Required |
Example
unsplash.photos.unlikePhoto("mtNweauBsMQ")
.then(toJson)
.then(json => {
});
categories.listCategories()
Get a list of all photo categories.
Arguments
N/A
Example
unsplash.categories.listCategories()
.then(toJson)
.then(json => {
});
categories.category(id)
Retrieve a single category.
Arguments
Argument | Type | Opt/Required |
---|
id | string | Required |
Example
unsplash.categories.category(4)
.then(toJson)
.then(json => {
});
categories.categoryPhotos(id, page, perPage)
Retrieve a single category’s photos.
Arguments
Argument | Type | Opt/Required |
---|
id | string | Required |
page | number | Optional |
perPage | number | Optional |
Example
unsplash.categories.categoryPhotos(4, 3, 15)
.then(toJson)
.then(json => {
});
curatedBatches.listCuratedBatches()
Get a single page from the list of all curated batches.
Arguments
N/A
Example
unsplash.curatedBatches.listCuratedBatches()
.then(toJson)
.then(json => {
});
curatedBatches.curatedBatch(id)
Retrieve a single batch.
Arguments
Argument | Type | Opt/Required |
---|
id | string | Required |
Example
unsplash.curatedBatches.curatedBatch(88)
.then(toJson)
.then(json => {
});
curatedBatches.curatedBatchPhotos(id)
Retrieve a single batch’s ten photos.
Arguments
Argument | Type | Opt/Required |
---|
id | string | Required |
Example
unsplash.curatedBatches.curatedBatchPhotos(88)
.then(toJson)
.then(json => {
});
stats.total()
Get a list of download counts for all of Unsplash.
Arguments
N/A
Example
unsplash.stats.total()
.then(toJson)
.then(json => {
});
Helpers
toJson(res)
Arguments
Argument | Type | Opt/Required |
---|
res | Object | Required |
Example
import Unsplash, { toJson } from "unsplash-js";
let unsplash = new Unsplash({
applicationId: "{YOUR_APPLICATION_ID}",
secret: "{YOUR_SECRET_KEY}",
callbackUrl: "{YOUR_CALLBACK_URL}"
});
unsplash.stats.total()
.then(toJson)
.then(json => {
});
License
Copyright (c) 2015, Naoufal Kadhom
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.