Once your account has been registered for the API, go to your apps. Click “New Application”, and fill in the required details. Show
Initially, your application will be in demo mode and will be rate-limited to 50 requests per hour. This is perfect for demo apps, trying out the API, and for educational purposes. If ready to move to production mode, follow the ‘Apply for Production’ instructions. If approved, your rate limit will be increased to the full amount. All applications must follow the API Guidelines, including properly providing attribution for the photographer and Unsplash. For more on when to apply for rate limits, see our help center. Libraries & SDKsTo make it as easy as possible to integrate the Unsplash API, official libraries and SDKs exist in:
Guidelines & CreditingThe Unsplash API is made available as a free API. To use the API you must abide by the terms and follow the API guidelines. HotlinkingUnlike most APIs, we require the image URLs returned by the API to be directly used or embedded in your applications (generally referred to as hotlinking). By using our CDN and embedding the photo URLs in your application, we can better track photo views and pass those stats on to the photographer, providing them with context for how popular their photo is and how it’s being used. For more:
Deprecation policyWe will announce if we intend to discontinue or make a backwards-incompatible change to the API. For all publicly documented fields and endpoints, we will announce any changes via the changelog with at least 3 weeks of notice. To make sure you receive changes, subscribe to the RSS feed. For endpoints, we will also return a 09 header during the deprecation period.For any non-publicly documented fields or endpoints, we may make changes to these with no warning. Therefore, we suggest only using the fields and endpoints that are identified in the documentation below. SchemaLocationThe API is available at 10. Responses are sent as JSON.VersionAll requests receive the v1 version of the API. We encourage you to specifically request this via the 11 header: 12Summary objectsWhen retrieving a list of objects, an abbreviated or summary version of that object is returned - i.e., a subset of its attributes. To get a full detailed version of that object, fetch it individually. HTTP VerbsThe Unsplash API uses HTTP verbs appropriate to each action. VerbDescriptionGETRetrieving resources.POSTCreating resources.PUTUpdating resources.DELETEDeleting resources.Error messagesIf an error occurs, whether on the server or client side, the error message(s) will be returned in an 13 array. For example:
We use conventional HTTP response codes to indicate the success or failure of an API request. In general, codes in the 14 range indicate success. Codes in the 15 range indicate an error that failed given the information provided (e.g., a required parameter was omitted, etc.). Codes in the 16 range indicate an error with Unsplash’s servers.Common Status CodesDescription200 - OKEverything worked as expected400 - Bad RequestThe request was unacceptable, often due to missing a required parameter401 - UnauthorizedInvalid Access Token403 - ForbiddenMissing permissions to perform request404 - Not FoundThe requested resource doesn’t exist500, 503Something went wrong on our endAuthorizationPublic AuthenticationMost actions can be performed without requiring authentication from a specific user. For example, searching, fetching, or downloading a photo does not require a user to log in. To authenticate requests in this way, pass your application’s access key via the HTTP Authorization header:
You can also pass this value using a 17 query parameter:
💫 Tip Most Unsplash API applications use this form of authentication as it doesn't require users to login or join, and it's generally cacheable by our system, resulting in even faster response times. If only your access key is sent, attempting to perform non-public actions that require user authorization will result in a 18 response.User AuthenticationIf you’re building an API application which requires that responses be customized per user (i.e. have they liked a photo, fetch their private collections, etc.) or requires taking actions on behalf of users, then you’ll need to use the user authentication workflow to create individual user bearer tokens for authentication. For more information, see the user authentication workflow documentation. Dynamic Client RegistrationFollowing the OAuth dynamic client registration protocol, we support a special authorization flow that grants individual API keys to each user with a user-friendly sign up process. This or the use of a proxy is required for applications that are decentralized, like Wordpress or Ghost, where a single API key can’t be shared between all installations. For more information, see the dynamic client registration documentation. PaginationRequests that return multiple items (a list of photos, for example) will be paginated into pages of 10 items by default, up to a maximum of 30. The optional 19 and 20 query parameters can be supplied to define which page and the number of items per page to be returned, respectively.If 19 is not supplied, the first page will be returned.Pagination headersAdditional pagination information is returned in the response headers: Per-page and TotalThe 22 and 23 headers give the number of elements returned on each page and the total number of elements respectively.LinkURL’s for the first, last, next, and previous pages are supplied, if applicable. They are comma-separated and differentiated with a 24 attribute.For example, after requesting page 3 of the photo list:
Rate LimitingFor applications in demo mode, the Unsplash API currently places a limit of 50 requests per hour. After approval for production, this limit is increased to 5000 requests per hour. On each request, your current rate limit status is returned in the response headers:
Note that only the json requests (i.e., those to 25) are counted. Image file requests ( 26) do not count against your rate limit.If you think you’ll need a higher rate limit, contact us. Dynamically resizable imagesEvery image returned by the Unsplash API is a dynamic image URL, which means that it can be manipulated to create new transformations of the image by simply adjusting the query parameters of the image URL. This enables resizing, cropping, compression, and changing the format of the image in realtime client-side, without any API calls. Under the hood, Unsplash uses Imgix, a powerful image manipulation service to provide dynamic image URLs. Supported parametersWe officially support the parameters:
The other parameters offered by Imgix can be used, but we don’t officially support them and may remove support for them at any time in the future. 💫 Tip The API returns image URLs containing an 35 parameter. All resizing and manipulations of image URLs must keep this parameter as it allows for your application to report photo views and be compliant with the API Guidelines.Example image useIf you hit the 36 endpoint, you’ll retrieve a list of photos. For each photo object returned, a list of image URLs are returned under 37:
If your application needs an image with a width of 1500px and DPR of 2, take the 42 URL and add the 45 and 46 parameters to create a new image:
If another part of your application needs that same image, but at half the width, you can easily construct another URL without hitting the API again:
For more, see Imgix’s docs. BlurHash PlaceholdersAll photo objects returned by the Unsplash API include a 47 string. This is a very compact represenation of an image placeholder which can be used to display a blurred preview before the real image loads.Find out more about BlurHash and how to implement it on your application on its official page. Content safetyBy default, endpoints set the 48 to 49, which guarantees that no content violating our submission guidelines (like images containing nudity or violence) will be returned in results.To give you flexibility in filtering content further, set the 48 to 51 (on endpoints that support it) to further remove content that may be unsuitable for younger audiences. Note that we can’t guarantee that all potentially unsuitable content is removed.Supported LanguagesWe’re currently testing support for non-english languages on . To access the beta, email [email protected] with your application ID. ISO 639-1 Language CodeLanguage 52Afrikaans 53Amharic 54Arabic 55Azerbaijani 56Belarusian 57Bulgarian 58Bengali 59Bosnian 60Catalan 61Cebuano 62Corsican 63Czech 64Welsh 65Danish 66German 67Greek 68English 69Esperanto 70Spanish 71Estonian 72Basque 73Persian 74Finnish 75French 76Frisian 77Irish 78Scots Gaelic 79Galician 80Gujarati 81Hausa 82Hawaiian 83Hindi 84Hmong 85Croatian 86Haitian Creole 87Hungarian 88Armenian 89Indonesian 90Igbo 91Icelandic 92Italian 93Hebrew 94Japanese 95Javanese 96Georgian 97Kazakh 98Khmer 99Kannada 00Korean 01Kurdish 02Kyrgyz 03Latin 04Luxembourgish 05Lao 06Lithuanian 07Latvian 08Malagasy 09Maori 10Macedonian 11Malayalam 12Mongolian 13Marathi 14Malay 15Maltese 16Myanmar 17Nepali 18Dutch 19Norwegian 20Nyanja 21Oriya 22Punjabi 23Polish 24Pashto 25Portuguese 26Romanian 27Russian 28Kinyarwanda 29Sindhi 30Sinhala 31Slovak 32Slovenian 33Samoan 34Shona 35Somali 36Albanian 37Serbian 38Sesotho 39Sundanese 40Swedish 41Swahili 42Tamil 43Telugu 44Tajik 45Thai 46Turkmen 47Filipino 48Turkish 49Tatar 50Uighur 51Ukrainian 52Urdu 53Uzbek 54Vietnamese 55Xhosa 56Yiddish 57Yoruba 58Chinese Simplified 59Chinese Traditional 60ZuluCurrent UserGet the user’s profile
Note: To access a user’s private data, the user is required to authorize the 61 scope.Note: Without a Bearer token (i.e. using a Client-ID token) this request will return a 18 response.ParametersNone Response 0 1Update the current user’s profile 2Note: This action requires the 63 scope. Without it, it will return a 64 response.ParametersAll parameters are optional. paramDescription 65Username. 66First name. 67Last name. 68Email. 69Portfolio/personal URL. 70Location. 71About/bio. 72Instagram username.ResponseReturns the updated user profile. 0 1UsersLink relationsUsers have the following link relations: relDescription 73API location of this user. 74HTML location of this user. 75API location of this user’s photos. 76API location of this user’s external portfolio. 77API location of this user’s followers. 78API location of users this user is following.Get a user’s public profileRetrieve public details on a given user. 5ParametersparamDescription 65The user’s username. Required.ResponseThis response includes only the user’s publicly-available information. For private details on the current user, use 80. 0 7Note: The image URLs returned for the user’s profile image are instances of . Get a user’s portfolio linkRetrieve a single user’s portfolio link. 8ParametersparamDescription 65The user’s username. Required.Response 0 0List a user’s photosGet a list of photos uploaded by a user. 1Note: See the note on . ParametersparamDescription 65The user’s username. Required. 19Page number to retrieve. (Optional; default: 1) 20Number of items per page. (Optional; default: 10) 85How to sort the photos. Optional. (Valid values: 86, 87, 88, 89, 90; default: 86) 92Show the stats for each user’s photo. (Optional; default: false) 93The frequency of the stats. (Optional; default: “days”) 94The amount of for each stat. (Optional; default: 30) 95Filter by photo orientation. Optional. (Valid values: 96, 97, 98)ResponseThe photo objects returned here are abbreviated. For full details use 99 0 3Note: If the optional 92 param is set to 01, each photo’s stats are included in the response: 4List a user’s liked photosGet a list of photos liked by a user. 5Note: See the note on . ParametersparamDescription 65The user’s username. Required. 19Page number to retrieve. (Optional; default: 1) 20Number of items per page. (Optional; default: 10) 85How to sort the photos. Optional. (Valid values: 86, 87, 88; default: 86) 95Filter by photo orientation. Optional. (Valid values: 96, 97, 98)ResponseThe photo objects returned here are abbreviated. For full details use 99 6 3List a user’s collectionsGet a list of collections created by the user. 8ParametersparamDescription 65The user’s username. Required. 19Page number to retrieve. (Optional; default: 1) 20Number of items per page. (Optional; default: 10)Response 9 0Get a user’s statisticsRetrieve the consolidated number of downloads, views and likes of all user’s photos, as well as the historical breakdown and average of these stats in a specific timeframe (default is 30 days). 1ParametersparamDescription 65The user’s username. Required. 93The frequency of the stats. (Optional; default: “days”) 94The amount of for each stat. (Optional; default: 30)Currently, the only resolution param supported is “days”. The quantity param can be any number between 1 and 30. Response 0 3PhotosLink relationsPhotos have the following link relations: relDescription 73API location of this photo. 74HTML location of this photo. 23Download location of this photo.List photosGet a single page from the Editorial feed. 4Note: See the note on . ParametersparamDescription 19Page number to retrieve. (Optional; default: 1) 20Number of items per page. (Optional; default: 10) 85How to sort the photos. Optional. (Valid values: 86, 87, 88; default: 86)ResponseThe photo objects returned here are abbreviated. For full details use 99 5 3Get a photoRetrieve a single photo. 7Note: See the note on . ParametersparamDescription 89The photo’s ID. Required.Response 0 9Get a random photoRetrieve a single random photo, given optional filters. 0Note: See the note on . ParametersAll parameters are optional, and can be combined to narrow the pool of photos from which a random one will be chosen. paramDescription 33Public collection ID(‘s) to filter selection. If multiple, comma-separated 34Public topic ID(‘s) to filter selection. If multiple, comma-separated 65Limit selection to a single user. 36Limit selection to photos matching a search term. 95Filter by photo orientation. (Valid values: 96, 97, 98) 48Limit results by . Default: 49. Valid values are 49 and 51. 45The number of photos to return. (Default: 1; max: 30)Note: You can’t use the collections or topics filtering with query parameters in the same request Note: When supplying a 45 parameter - and only then - the response will be an array of photos, even if the value of 45 is 1.Response 0Without the https://api.unsplash.com/photos/?client_id=YOUR_ACCESS_KEY
|