{"id":1908,"url":"https://github.com/modo-studio/UnsplashKit","last_synced_at":"2025-08-02T05:33:10.521Z","repository":{"id":9746478,"uuid":"63196298","full_name":"modo-studio/UnsplashKit","owner":"modo-studio","description":"Swift client for Unsplash","archived":false,"fork":false,"pushed_at":"2023-03-09T23:24:27.000Z","size":218,"stargazers_count":191,"open_issues_count":13,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-21T14:16:41.796Z","etag":null,"topics":["api-client","photos","swift","unsplash"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/modo-studio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.MD","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-07-12T22:22:31.000Z","updated_at":"2024-05-07T12:08:11.000Z","dependencies_parsed_at":"2023-02-14T04:16:30.867Z","dependency_job_id":"d844dc70-8b13-4fc7-bc22-58cbdaa26e08","html_url":"https://github.com/modo-studio/UnsplashKit","commit_stats":null,"previous_names":["carambalabs/unsplashkit"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modo-studio%2FUnsplashKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modo-studio%2FUnsplashKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modo-studio%2FUnsplashKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modo-studio%2FUnsplashKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/modo-studio","download_url":"https://codeload.github.com/modo-studio/UnsplashKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228443746,"owners_count":17920779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","photos","swift","unsplash"],"created_at":"2024-01-05T20:15:58.726Z","updated_at":"2024-12-06T09:30:40.368Z","avatar_url":"https://github.com/modo-studio.png","language":"Swift","funding_links":[],"categories":["SDK"],"sub_categories":["Unofficial"],"readme":"![UnsplashKit: Unsplash API Client in Swift](assets/unsplashkit-header.png)\n\n[![Build Status](https://travis-ci.org/carambalabs/UnsplashKit.svg?branch=master)](https://travis-ci.org/carambalabs/UnsplashKit)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/UnsplashKit.svg)](https://img.shields.io/cocoapods/v/UnsplashKit.svg)\n[![codecov](https://codecov.io/gh/carambalabs/UnsplashKit/branch/master/graph/badge.svg)](https://codecov.io/gh/carambalabs/UnsplashKit)\n\nUnsplash API client written in Swift.\n\n[Unsplash](https://unsplash.com/) offers 2 APIs:\n- [Source API](https://source.unsplash.com/) (unlimited requests)\n- [Official API](https://unsplash.com/documentation)\n- [JSON API](https://unsplash.com/documentation) (5000 requests / hour)\n\nJSON API is in progress and will be available soon in this library.\n\n## Requirements\n\n* iOS 8.0+ / Mac OS X 10.9+ / tvOS 9.0+ / watchOS 2.0+\n* Xcode 8.0+\n\n## Installation\n\nYou can use [CocoaPods](https://cocoapods.org) to integrate the library with your project.\n\n```ruby\npod \"UnsplashKit/API\" # Official API\npod \"UnsplashKit/Source\" # Source API\n```\n\n## Usage\n\n```swift\nimport UnsplashKit\n```\n\n### Official API\n\nFirst thing you need is an instance of the client for executing requests and parsing responses from the API:\n\n```swift\nvar token = \"xxxx\"\nvar client = UnsplashClient { request -\u003e [String: String] in\n    return [ \"Authorization\": \"Bearer \\(token)\"]\n}\n```\n\nSince the client supports providing headers for the requests, we'll use that closure to specify the authenticationt tokent that we want to pass in. UnsplashKit doesn't provide the OAuth2 authentication components, but you can use [Paparajote](https://github.com/carambalabs/paparajote) instead.\n\n\n### Resources\n\nOnce the client is created you can use models' resources that contain the information about the request and about how to parse the JSON response into models whose properties you can access directly to. Here's an example:\n\n```swift\nlet searchPhotos = Search.photos(query: \"mountain\")\nclient.execute(resource: searchPhotos) { (result) in\n  print(result)\n}\n```\n\n\u003e The models that contain resources are, `User`, `Photo`, `Search`, `Collection`.  These resources match the endpoints available from the API. If there's any new endpoint which is not supported, you can either create an issue, open a PR or contact [hello@caramba.io](mailto://hello@caramba.io)\n\n### Source API\n\nSource API allows you to get an Unsplash image in different ways.\n\n#### Results\n\nAll the calls return the image through a completion block that returns a `Result\u003cImage, Error\u003e`.\n```swift\ncall() { result in\n  switch result {\n    case .success(let image): //handle image\n    case .failure(let error): //handle error\n  }\n}\n```\n\nYou can also ignore the error and get only the result using\n```swift\ncall() { result in\n  let image = result.value\n}\n```\n\n#### Random photo\n\n```swift\nUnsplashSource().randomPhoto() { result in\n  // handle the result\n}\n```\n\n#### Random from a category\n\n```swift\nUnsplashSource().randomPhoto(fromCategory: .nature) { result in\n    // handle the result\n}\n```\n\nUnsplash offers a list of predefined categories. You can ask for a photo from any of these categories.\n\n```swift\n.buildings\n.food\n.nature\n.people\n.technology\n.objects\n```\n\n#### Random from a specific user\n\n```swift\nUnsplashSource().randomPhoto(fromUser: \"carambalabs\") { result in\n    // handle the result\n}\n```\n\n#### Random from a user's likes\n\n```swift\nUnsplashSource().randomPhoto(fromUserLikes: \"mkwlsn\") { result in\n    // handle the image\n}\n```\n\n#### Random from a collection\n\n```swift\nUnsplashSource().randomPhoto(fromCollection: \"176316\") { result in\n    // handle the result\n}\n```\n\n#### Random search term\n\n```swift\nUnsplashSource().randomPhoto(fromSearch: [\"nature\", \"water\"]) { result in\n    // handle the result\n}\n```\n\n#### Specific photo\n\n```swift\nUnsplashSource().photo(\"WLUHO9A_xik\") { result in\n    // handle the result\n}\n```\n\n#### Specific image size\n\nIf you want to get an image of a specific size you can use the optional `size` parameter in any call.\n\n```swift\nUnsplashSource().randomPhoto(fromCategory: .nature, size: CGSize(width: 600, height: 200)) { result in\n    // handle the result\n}\n```\n\n#### Fixed daily/weekly photo\n\nThe calls `random`, `search`, `category` and `user` can also be limited to only updating once per day or week. To do so, simply use the optional `filter` parameter.\n\n```swift\nUnsplashSource().randomPhoto(filter: .daily) { result in\n    // handle the result\n}\n```\n\n## About\n\n\u003cimg src=\"https://github.com/carambalabs/Foundation/blob/master/ASSETS/logo-salmon.png?raw=true\" width=\"200\" /\u003e\n\nThis project is funded and maintained by [Caramba](http://caramba.io). We 💛 open source software!\n\nCheck out our other [open source projects](https://github.com/carambalabs/), read our [blog](http://blog.caramba.io) or say :wave: on twitter [@carambalabs](http://twitter.com/carambalabs).\n\n## Contribute\n\nContributions are welcome :metal: We encourage developers like you to help us improve the projects we've shared with the community. Please see the [Contributing Guide](https://github.com/carambalabs/Foundation/blob/master/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/carambalabs/Foundation/blob/master/CONDUCT.md).\n\n## License\n\nUnsplashKit is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodo-studio%2FUnsplashKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodo-studio%2FUnsplashKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodo-studio%2FUnsplashKit/lists"}