Product Promotion
0x5a.live
for different kinds of informations and explorations.
GitHub - waynehoover/unsplash-elixir: Unsplash API client for Elixir
Unsplash API client for Elixir. Contribute to waynehoover/unsplash-elixir development by creating an account on GitHub.
Visit SiteGitHub - waynehoover/unsplash-elixir: Unsplash API client for Elixir
Unsplash API client for Elixir. Contribute to waynehoover/unsplash-elixir development by creating an account on GitHub.
Powered by 0x5a.live ๐
Unsplash
Unsplash 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 are supported. See the documentation 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
- Add unsplash to your list of dependencies in
mix.exs
:
def deps do
[{:unsplash, "~> 1.1.0"}]
end
- Ensure unsplash is started before your application:
def application do
[applications: [:unsplash]]
end
Elixir Resources
are all listed below.
Made with โค๏ธ
to provide different kinds of informations and resources.