Get a list of all photo categories.
Retrieve a single category.
Retrieve a single category’s photos.
collections.listCollections(page, perPage, orderBy)
Get a single page from the list of all collections.
Arguments
Argument | Type | Opt/Required | Notes |
---|
page | number | Optional | |
perPage | number | Optional | |
orderBy | string | Optional | latest , popular or oldest |
Example
unsplash.collections.listCollections(1, 10, "popular")
.then(toJson)
.then(json => {
});
collections.listCuratedCollections(page, perPage)
Get a single page from the list of curated collections.
Arguments
Argument | Type | Opt/Required |
---|
page | number | Optional |
perPage | number | Optional |
Example
unsplash.collections.listCuratedCollections(1, 10)
.then(toJson)
.then(json => {
});
collections.listFeaturedCollections(page, perPage)
Get a single page from the list of featured collections.
Arguments
Argument | Type | Opt/Required |
---|
page | number | Optional |
perPage | number | Optional |
Example
unsplash.collections.listFeaturedCollections(1, 10)
.then(toJson)
.then(json => {
});
collections.getCollection(id)
Retrieve a single collection. To view a user’s private collections, the read_collections
scope is required.
Arguments
Argument | Type | Opt/Required |
---|
id | number | Required |
Example
unsplash.collections.getCollection(123456)
.then(toJson)
.then(json => {
});
collections.getCuratedCollection(id)
Or, for a curated collection:
Arguments
Argument | Type | Opt/Required |
---|
id | number | Required |
Example
unsplash.collections.getCuratedCollection(88)
.then(toJson)
.then(json => {
});
collections.getCollectionPhotos(id, orderBy)
Retrieve a collection’s photos.
Arguments
Argument | Type | Opt/Required | Notes |
---|
id | number | Required | |
page | number | Optional | |
perPage | number | Optional | |
orderBy | string | Optional | latest , popular or oldest |
Example
unsplash.collections.getCollectionPhotos(123456, 1, 10, "popular")
.then(toJson)
.then(json => {
});
collections.getCuratedCollectionPhotos(id, orderBy)
Or, for a curated collection:
Arguments
Argument | Type | Opt/Required | Notes |
---|
id | number | Required | |
page | number | Optional | |
perPage | number | Optional | |
orderBy | string | Optional | latest , popular or oldest |
Example
unsplash.collections.getCuratedCollectionPhotos(88, 1, 10, "popular")
.then(toJson)
.then(json => {
});
collections.createCollection(title, description, private)
Create a new collection. This requires the write_collections
scope.
Arguments
Argument | Type | Opt/Required |
---|
title | string | Required |
description | string | Optional |
private | boolean | Optional |
Example
unsplash.collections.createCollection("Birds", "Wild birds from 'round the world", true)
.then(toJson)
.then(json => {
});
collections.updateCollection(id, title, description, private)
Update an existing collection belonging to the logged-in user. This requires the write_collections
scope.
Arguments
Argument | Type | Opt/Required |
---|
id | number | Required |
title | string | Optional |
description | string | Optional |
private | boolean | Optional |
Example
unsplash.collections.updateCollection(12345, "Wild Birds", "Wild birds from around the world", false)
.then(toJson)
.then(json => {
});
collections.deleteCollection(id)
Delete a collection belonging to the logged-in user. This requires the write_collections
scope.
Arguments
Argument | Type | Opt/Required |
---|
id | number | Required |
Example
unsplash.collections.deleteCollection(88)
.then(toJson)
.then(json => {
});
collections.addPhotoToCollection(collectionId, photoId)
Add a photo to one of the logged-in user’s collections. Requires the write_collections
scope.
Arguments
Argument | Type | Opt/Required |
---|
collectionId | number | Required |
photoId | string | Required |
Example
unsplash.collections.addPhotoToCollection(88, 'abc1234')
.then(toJson)
.then(json => {
});
collections.removePhotoFromCollection(collectionId, photoId)
Remove a photo from one of the logged-in user’s collections. Requires the write_collections
scope.
Arguments
Argument | Type | Opt/Required |
---|
collectionId | number | Required |
photoId | string | Required |
Example
unsplash.collections.removePhotoFromCollection(88, 'abc1234')
.then(toJson)
.then(json => {
});
search.all(keyword, page)
Get a list of photos, collections, and users matching the keyword.
Arguments
Argument | Type | Opt/Required | Notes |
---|
keyword | number | Required | |
page | number | Optional | |
Example
unsplash.search.all("dogs", 2)
.then(toJson)
.then(json => {
});
search.users(keyword, page)
Get a list of users matching the keyword.
Arguments
Argument | Type | Opt/Required | Notes |
---|
keyword | number | Required | |
page | number | Optional | |
Example
unsplash.search.users("steve", 1)
.then(toJson)
.then(json => {
});
search.photos(keyword, page)
Get a list of photos matching the keyword.
Arguments
Argument | Type | Opt/Required | Notes |
---|
keyword | number | Required | |
page | number | Optional | |
Example
unsplash.search.photos("dogs", 1)
.then(toJson)
.then(json => {
});
search.collections(keyword, page)
Get a list of collections matching the keyword.
Arguments
Argument | Type | Opt/Required | Notes |
---|
keyword | number | Required | |
page | number | Optional | |
Example
unsplash.search.collections("dogs", 1)
.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";
const unsplash = new Unsplash({
applicationId: "{YOUR_APPLICATION_ID}",
secret: "{YOUR_SECRET_KEY}",
callbackUrl: "{YOUR_CALLBACK_URL}"
});
unsplash.stats.total()
.then(toJson)
.then(json => {
});
Shoutouts
- Shoutout to all the contributors for lending a helping hand.
- Shoutout to BrowserStack for letting us use their service to run automated browser tests.
License
Copyright (c) 2015, Unsplash
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.