- Adds response types to all endpoints.
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.
- Replaces the
Unsplash
class
with a namedcreateApi
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' });
- Removes user authentication features from the library. This means that the
createApi
function does not recievesecret
,callbackUrl
orbearerToken
.
-
Removes the following API methods (primarily due to removal of user authentication):
photos
:- ❌
likePhoto
- ❌
unlikePhoto
- ❌
downloadPhoto
(deprecated in 6.3, replaced withtrackDownload
)
- ❌
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
- Changes the format of the parameters for all API methods. They are now all named parameters within the first argument, instead of multiple arguments. Check the TypeScript types and the Arguments section of the docs for the new parameters format.
- Changes the format of the responses for all API methods. The JSON is now parsed and returned, removing the need for the
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.
- TypeScript support! Everything is now accurately typed (except responses which we plan to add types for soon).
- You can now provide fetch options on a per-call basis using the second parameter. See Arguments.
- Deprecate
photos.downloadPhoto
in favor ofphotos.trackDownload
to better clarify method usage.downloadPhoto
will continue to be supported until version 7.0.
- Adds support for the languages beta on search
unsplash.search.photos('nature', 1, 10, { lang: 'en' });
- Adds support for the new search filters and ordering
unsplash.search.photos('nature', 1, 10, {
orientation: 'landscape',
color: 'green', // new
orderBy: 'relevant', // new
});
- Adds support for content filtering on search
unsplash.search.photos('nature', 1, 10, { contentFilter: 'high' });
- Removes any references to 'popular' ordering (due to deprecation)
Enables Brotli compression by default.
-
To better clarify the use of
accessKey
when initializing,applicationId
has been renamed toaccessKey
:// previously const unsplash = new Unsplash({ applicationId: '{APP_ACCESS_KEY}', }); // now const unsplash = new Unsplash({ accessKey: '{APP_ACCESS_KEY}', });
-
unsplash.photos.getPhotoStats
now uses the/photos/:id/statistics
endpoint (changelog reference) -
To support additional filters, the
unsplash.search.photos
method signature has been changed to support an optionalfilters
object, which currently supportscollections
andorientation
keys.
unsplash.search.photos('nature', 1, 10, { orientation: 'landscape', collections: [1, 2] });
6.0 removes deprecated endpoints and parameters to match the changes from the Unsplash API Changelog. Most of these endpoints have been deprecated on the API and removed from unsplash-js
documentation for 2+ years.
Removed Method | Replacement | Reason |
---|---|---|
unsplash.search.all |
None | This endpoint is undocumented publicly and is highly likely to change in the future. Therefore, we don't recommend anyone use this functionality in their applications. |
unsplash.photos.listCuratedPhotos |
None | Curated photos were deprecated in 2017, removed in 2019 |
unsplash.photos.searchPhotos |
unsplash.search.photos |
Replaced by the new search endpoints in 2017 |
unsplash.photos.uploadPhoto |
None | Removed for legal compatibility |
unsplash.collections.listFeaturedCollections |
unsplash.collections.listCollections |
Redundant endpoint |
unsplash.collections.listCuratedCollections |
None | Curated collections were replaced by collections. Deprecated in 2017, removed in 2019 |
unsplash.collections.getCuratedCollection |
unsplash.collections.getCollection |
Curated collections were replaced by collections. Deprecated in 2017, removed in 2019 |
unsplash.collections.getCuratedCollectionPhotos |
unsplash.collections.getCollectionPhotos |
Curated collections were replaced by collections. Deprecated in 2017, removed in 2019 |
unsplash.categories.* |
None | Categories were deprecated in 2017 and removed from the API in 2017 |
Removed Parameter | Method | Reason |
---|---|---|
category |
unsplash.photos.getRandomPhoto |
Categories were deprecated in 2017 and removed from the API in 2017 |
w |
unsplash.photos.getPhoto , unsplash.photos.getRandomPhoto |
Deprecated in favor of dynamic image URLs |
h |
unsplash.photos.getPhoto , unsplash.photos.getRandomPhoto |
Deprecated in favor of dynamic image URLs |
crop |
unsplash.photos.getPhoto |
Deprecated in favor of dynamic image URLs |