All Projects β†’ modo-studio β†’ Unsplashkit

modo-studio / Unsplashkit

Licence: mit
Swift client for Unsplash

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Unsplashkit

Unsplash Php
πŸ‘» Official PHP wrapper for the Unsplash API
Stars: ✭ 332 (+81.42%)
Mutual labels:  unsplash, photos
google-photos-api-client-go
Google photos api client in go
Stars: ✭ 35 (-80.87%)
Mutual labels:  photos, api-client
Unsplash rb
πŸ’Ž Ruby wrapper for the Unsplash API.
Stars: ✭ 202 (+10.38%)
Mutual labels:  unsplash, photos
Unsplash Js
πŸ€– A server-side JavaScript wrapper for the Unsplash API
Stars: ✭ 1,647 (+800%)
Mutual labels:  unsplash, photos
Splash Cli
A simple, command line tool to download Unsplash wallpapers. It’s not intended to be anything particularly fancy β€” it just works.
Stars: ✭ 432 (+136.07%)
Mutual labels:  unsplash, photos
Natural Language Image Search
Search photos on Unsplash using natural language
Stars: ✭ 359 (+96.17%)
Mutual labels:  unsplash, photos
go-unsplash
Go Client for the Unsplash API
Stars: ✭ 70 (-61.75%)
Mutual labels:  photos, unsplash
Resplash
Unofficial Unsplash Android App
Stars: ✭ 395 (+115.85%)
Mutual labels:  unsplash, photos
Androidunplash
An unofficial Unsplash API library for Android
Stars: ✭ 80 (-56.28%)
Mutual labels:  unsplash, photos
Datasets
🎁 3,000,000+ Unsplash images made available for research and machine learning
Stars: ✭ 1,805 (+886.34%)
Mutual labels:  unsplash, photos
Mobx Rest
REST conventions for Mobx
Stars: ✭ 164 (-10.38%)
Mutual labels:  api-client
Metax
An iOS app that helps you check, edit and delete metadata of photos, including but not limited to EXIF, TIFF...
Stars: ✭ 165 (-9.84%)
Mutual labels:  photos
Alcameraviewcontroller
A camera view controller with custom image picker and image cropping.
Stars: ✭ 2,023 (+1005.46%)
Mutual labels:  photos
Web Client
Cryptee's web client source code for all platforms.
Stars: ✭ 174 (-4.92%)
Mutual labels:  photos
Yelp Python
A Python library for the Yelp API
Stars: ✭ 163 (-10.93%)
Mutual labels:  api-client
Js Client
A Open-API derived JS + Node.js API client for Netlify
Stars: ✭ 170 (-7.1%)
Mutual labels:  api-client
Python Qbittorrent
Python wrapper for qBittorrent Web API (for versions above v3.1.x)
Stars: ✭ 163 (-10.93%)
Mutual labels:  api-client
Bonsai
Self-hosted family wiki engine / photoalbum
Stars: ✭ 162 (-11.48%)
Mutual labels:  photos
Chevereto Free
Self-hosted Image Hosting solution. Start your own Flickr/imgur alternative with your own rules.
Stars: ✭ 2,275 (+1143.17%)
Mutual labels:  photos
Hexo Theme Random
A hexo theme with random fullscreen background image.
Stars: ✭ 179 (-2.19%)
Mutual labels:  unsplash

UnsplashKit: Unsplash API Client in Swift

Build Status CocoaPods Compatible codecov

Unsplash API client written in Swift.

Unsplash offers 2 APIs:

JSON API is in progress and will be available soon in this library.

Requirements

  • iOS 8.0+ / Mac OS X 10.9+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 8.0+

Installation

You can use CocoaPods to integrate the library with your project.

pod "UnsplashKit/API" # Official API
pod "UnsplashKit/Source" # Source API

Usage

import UnsplashKit

Official API

First thing you need is an instance of the client for executing requests and parsing responses from the API:

var token = "xxxx"
var client = UnsplashClient { request -> [String: String] in
    return [ "Authorization": "Bearer \(token)"]
}

Since 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 instead.

Resources

Once 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:

let searchPhotos = Search.photos(query: "mountain")
client.execute(resource: searchPhotos) { (result) in
  print(result)
}

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 [email protected]

Source API

Source API allows you to get an Unsplash image in different ways.

Results

All the calls return the image through a completion block that returns a Result<Image, Error>.

call() { result in
  switch result {
    case .success(let image): //handle image
    case .failure(let error): //handle error
  }
}

You can also ignore the error and get only the result using

call() { result in
  let image = result.value
}

Random photo

UnsplashSource().randomPhoto() { result in
  // handle the result
}

Random from a category

UnsplashSource().randomPhoto(fromCategory: .nature) { result in
    // handle the result
}

Unsplash offers a list of predefined categories. You can ask for a photo from any of these categories.

.buildings
.food
.nature
.people
.technology
.objects

Random from a specific user

UnsplashSource().randomPhoto(fromUser: "carambalabs") { result in
    // handle the result
}

Random from a user's likes

UnsplashSource().randomPhoto(fromUserLikes: "mkwlsn") { result in
    // handle the image
}

Random from a collection

UnsplashSource().randomPhoto(fromCollection: "176316") { result in
    // handle the result
}

Random search term

UnsplashSource().randomPhoto(fromSearch: ["nature", "water"]) { result in
    // handle the result
}

Specific photo

UnsplashSource().photo("WLUHO9A_xik") { result in
    // handle the result
}

Specific image size

If you want to get an image of a specific size you can use the optional size parameter in any call.

UnsplashSource().randomPhoto(fromCategory: .nature, size: CGSize(width: 600, height: 200)) { result in
    // handle the result
}

Fixed daily/weekly photo

The 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.

UnsplashSource().randomPhoto(filter: .daily) { result in
    // handle the result
}

About

This project is funded and maintained by Caramba. We πŸ’› open source software!

Check out our other open source projects, read our blog or say πŸ‘‹ on twitter @carambalabs.

Contribute

Contributions are welcome 🀘 We encourage developers like you to help us improve the projects we've shared with the community. Please see the Contributing Guide and the Code of Conduct.

License

UnsplashKit is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].