{"id":18715453,"url":"https://github.com/rawnly/unsplashapiclient","last_synced_at":"2025-11-10T05:30:22.195Z","repository":{"id":78841611,"uuid":"164322922","full_name":"rawnly/UnsplashAPIClient","owner":"rawnly","description":"Unsplash API wrapper","archived":false,"fork":false,"pushed_at":"2019-01-06T21:44:21.000Z","size":430,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-28T09:43:26.390Z","etag":null,"topics":["ios","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/rawnly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-06T16:03:53.000Z","updated_at":"2020-01-15T21:18:20.000Z","dependencies_parsed_at":"2023-04-16T02:15:02.975Z","dependency_job_id":null,"html_url":"https://github.com/rawnly/UnsplashAPIClient","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawnly%2FUnsplashAPIClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawnly%2FUnsplashAPIClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawnly%2FUnsplashAPIClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rawnly%2FUnsplashAPIClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rawnly","download_url":"https://codeload.github.com/rawnly/UnsplashAPIClient/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239577550,"owners_count":19662247,"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":["ios","swift","unsplash"],"created_at":"2024-11-07T13:08:45.689Z","updated_at":"2025-11-10T05:30:22.151Z","avatar_url":"https://github.com/rawnly.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unsplash API Client\n\u003e Unsplash API wrapper written in Swift\n\n## Description\n**UnsplashAPIClient** (name will change soon... hopefully) it's a library to easy access [Unsplash](https://unsplash.com/)'s API\n\n## Example Usage\nThe following code is an example implementation inside a `ViewController`:\n```swift\nimport UIKit\nimport UnsplashAPIClient\n\nclass ViewController: UIViewController {\n    let api: UnsplashAPIClient = UnsplashAPIClient(\n        accessKey: \"YOUR_ACCESS_KEY\",\n        secretKey: \"YOUR_SECRET_KEY\"\n    )\n    \n    var background: UIImageView = UIImageView()\n    \n    // MARK: - Lifecycle\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        \n        setupBackground()        \n        getBackground()\n        \n        let tap = UITapGestureRecognizer(target: self, action: #selector(self.getBackground))\n        view.addGestureRecognizer(tap)\n    }\n    \n    // MARK: - UI Setup \n    func setupUI() {\n        background.backgroundColor = .red\n        background.contentMode = .scaleAspectFill\n\n        view.addSubview(background)\n        background.translatesAutoresizingMaskIntoConstraints = false\n        NSLayoutConstraint.activate([\n            background.topAnchor.constraint(equalTo: view.topAnchor),\n            background.leadingAnchor.constraint(equalTo: view.leadingAnchor),\n            background.trailingAnchor.constraint(equalTo: view.trailingAnchor),\n            background.bottomAnchor.constraint(equalTo: view.bottomAnchor)\n        ])\n    }\n}\n\nextension ViewController {\n    @objc func getBackground() {\n        api.getRandomPhoto { (photo, statusCode) in\n            guard let photo = photo else { return }\n            \n            if let url = photo.getURL(ofSize: .regular) {\n                 DispatchQueue.global().async {\n                    if let data = try? Data(contentsOf: url) {\n                        DispatchQueue.main.async {\n                            let image = UIImage(data: data)\n                            self.background.image = image\n                            \n                            let alert = UIAlertController(title: \"Background changed\", message: \"Photo changed to #\\(photo.id)\", preferredStyle: .alert)\n                            alert.addAction(UIAlertAction(title: \"Ok\", style: .default))\n                            self.present(alert, animated: true)\n                        }\n                    }\n                } \n            }\n        }\n    }\n}\n```\n\n### ⚠️Note\nSince the latest release is flagged as `pre-release` it's not production-ready.\nPlease report any bug/issue.\n\n## Installation via **Carthage**\nUnsplashAPIClient is available through Carthage. To install just write into your `Cartfile`:\n```\n  github \"rawnly/UnsplashAPIClient\"\n```\nYou also need to add `UnsplashAPIClient.framework` in your copy-frameworks script.\n\n## Installation via **Pods**\n\u003e Coming Soon\n\n## Related\n- [**Splash CLI**](https://github.com/splasg-cli/splash-cli) - Beautiful wallpapers from Unsplash\n\n## Author\n- [Federico Vitale](https://rawnly.com) ([@Rawnly](https://github.com/rawnly))\n\n## Contributing\nI would love you to contribute to **UnsplashAPIClient**, check the [CONTRIBUTING](CONTRIBUTING.md) file for more info.\n\n##  License\n**UnsplashAPIClient** is available under the MIT license. See the [LICENSE](LICENSE.md) file for more info.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frawnly%2Funsplashapiclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frawnly%2Funsplashapiclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frawnly%2Funsplashapiclient/lists"}