Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/waynehoover/unsplash-elixir
Unsplash API client for Elixir
https://github.com/waynehoover/unsplash-elixir
Last synced: 2 months ago
JSON representation
Unsplash API client for Elixir
- Host: GitHub
- URL: https://github.com/waynehoover/unsplash-elixir
- Owner: waynehoover
- Created: 2015-11-16T09:16:51.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-11-16T22:44:51.000Z (about 5 years ago)
- Last Synced: 2024-10-05T09:17:50.655Z (3 months ago)
- Language: Elixir
- Homepage:
- Size: 556 KB
- Stars: 15
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - An Elixir library for Unsplash. (Third Party APIs)
- fucking-awesome-elixir - unsplash-elixir - An Elixir library for Unsplash. (Third Party APIs)
- awesome-elixir - unsplash-elixir - An Elixir library for Unsplash. (Third Party APIs)
README
# Unsplash [![Build Status](https://travis-ci.org/waynehoover/unsplash-elixir.svg?branch=master)](https://travis-ci.org/waynehoover/unsplash-elixir) [![Hex pm](http://img.shields.io/hexpm/v/unsplash.svg?style=flat)](https://hex.pm/packages/unsplash) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/9ecf49d0c73e4b268e77b34e766e149a)](https://www.codacy.com/app/waynehoover/unsplash-elixir?utm_source=github.com&utm_medium=referral&utm_content=waynehoover/unsplash-elixir&utm_campaign=Badge_Grade)
[Unsplash](https://unsplash.com) API wrapper in Elixir.
## Exmaple Usage
* `Unsplash.Photos.search(query: "Austin", catgeroy: "2") |> Enum.take(1)`
* `Unsplash.Collections.all |> Enum.take(1)`
* All [API endpoints](https://unsplash.com/documentation) are supported. See the [documentation](http://hexdocs.pm/unsplash/Unsplash.html) for full list.Each API call that is paginated returns a stream. You can resolve the stream by calling any Enum function, this way you don't have to think about pagination. For example to get one random photo: `Unsplash.Photos.random |> Enum.take(1)` or to get 100 random photos: `Unsplash.Photos.random |> Enum.take(100)`.
## Configuration
See the `secrets.exs` file on what configuration variables need to be configured.
## Authorization
Get an auth code by directing a user to the url generated by this command (replace the scope with what you would like):
`Unsplash.OAuth.authorize_url! scope: "public read_user write_user read_photos write_photos write_likes read_collections write_collections"`After the user grants access, she will be redirected back to your redirect_uri whith a `code` query paramater, which you then set like this:
`Unsplash.OAuth.authorize!(code: auth_code_from_the_callback)`Now every API call will use the access_code gerenated in the above step automatically.
## Installation
1. Add unsplash to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:unsplash, "~> 1.1.0"}]
end
```2. Ensure unsplash is started before your application:
```elixir
def application do
[applications: [:unsplash]]
end
```