unsplash-js
Advanced tools
Changelog
7.0.0
This version includes a total TypeScript rewrite of the library, with many breaking changes. If upgrading from a previous version, read carefully. You will not be able to upgrade to v7 without making the necessary adjustments.
Unsplash
class
with a named createApi
function:// before
import Unsplash from 'unsplash-js';
const unsplash = new Unsplash({ accessKey: 'MY_ACCESS_KEY' });
// after
import { createApi } from 'unsplash-js';
const unsplash = createApi({ accessKey: 'MY_ACCESS_KEY' });
// or
import Unsplash from 'unsplash-js';
const unsplash = Unsplash.createApi({ accessKey: 'MY_ACCESS_KEY' });
createApi
function does not recieve secret
, callbackUrl
or bearerToken
.Removes the following API methods (primarily due to removal of user authentication):
photos
:
likePhoto
unlikePhoto
downloadPhoto
(deprecated in 6.3, replaced with trackDownload
)users
:
statistics
collections
:
createCollection
updateCollection
deleteCollection
addPhotoToCollection
removePhotoFromCollection
auth
:
getAuthenticationUrl
userAuthentication
setBearerToken
currentUser
:
profile
updateProfile
stats
:
total
toJson
(the library now takes care of converting the response to JSON).Renames all of the remaining API methods:
search
:
photos
--> getPhotos
users
--> getUsers
collections
--> getCollections
photos
:
listPhotos
--> list
getPhoto
--> get
getRandomPhoto
--> getRandom
getPhotoStats
--> getStats
users
:
profile
--> get
photos
--> getPhotos
likes
--> getLikes
collections
--> getCollections
collections
:
listCollections
--> list
getCollection
--> get
getCollectionPhotos
--> getPhotos
listRelatedCollections
--> listRelated
toJson
helper. Feeds have the "x-total" header added to the response. The library now also performs error-handling: expected errors are returned instead of thrown, along with a description of their source. Check the TypeScript types and the Response section of the docs for the new response format.