unsplash v0.4.0 Unsplash

The Unslpash API in Elixir

Pagination

Those API results that are paginated will return a Stream in which you can resolve by using any Enum function. You can also pass in per_page and page keywords if you would like to do pagination manually. Max per_page is 30.

Summary

Functions

GET /categories

GET /categories/:id

GET /categories/:id/photos

POST /collections/:collection_id/add

POST /collections/:collection_id/add

GET /collections

GET /collections/:id

GET /collections/:id/photos

POST /collections

GET /collections/curated

GET /collections/curated/:id

GET /collections/:id/photos

DELETE /collections/:id

GET /me

GET /photos/:id

GET /stats/total

PUT /collections/:id

POST /photos

GET /users/:username

GET /users/:username/likes

Functions

categories()

GET /categories

categories(id)

GET /categories/:id

Args:

  • id - The category ID
categories(id, atom, opts \\ [])

GET /categories/:id/photos

Args:

  • id - The category ID
collection_add_photo(id, photo_id)

POST /collections/:collection_id/add

Args:

  • collection_id - The collection’s ID. Required.
  • photo_id - The photo’s ID. Required.

Requires write_collections scope

collection_remove_photo(id, photo_id)

POST /collections/:collection_id/add

Args:

  • collection_id - The collection’s ID. Required.
  • photo_id - The photo’s ID. Required.

Requires write_collections scope

collections()

GET /collections

collections(id)

GET /collections/:id

Args:

  • id - The collections ID
collections(id, atom)

GET /collections/:id/photos

Args:

  • id - The collections ID
create_collection(opts \\ [])

POST /collections

Args:

  • opts - Keyword list of options

Options:

  • title - The title of the collection. (Required.)
  • description - The collection’s description. (Optional.)
  • private - Whether to make this collection private. (Optional; default false).

Requires write_collections scope

curated_collections()

GET /collections/curated

curated_collections(id)

GET /collections/curated/:id

Args:

  • id - The collections ID
curated_collections(id, atom)

GET /collections/:id/photos

Args:

  • id - The collections ID
delete_collection(id)

DELETE /collections/:id

Requires write_collections scope

me()

GET /me

Requires read_user scope

photos(id, opts \\ [])

GET /photos/:id

Args:

  • id - the photo id
  • opts - Keyword list of options

Options:

  • w - Image width in pixels.
  • h - Image height in pixels.
  • rect - 4 comma-separated integers representing x, y, width, height of the cropped rectangle.
start(type, args)
stats()

GET /stats/total

update_collection(id, opts \\ [])

PUT /collections/:id

Args:

  • opts - Keyword list of options

Options:

  • title - The title of the collection. (Required.)
  • description - The collection’s description. (Optional.)
  • private - Whether to make this collection private. (Optional; default false).

Requires write_collections scope

update_me(opts \\ [])

PUT /me

Args:

  • opts - Keyword list of options

Options:

  • username - Username.
  • first_name - First name.
  • last_name -Last name.
  • email -Email.
  • url -Portfolio/personal URL.
  • location - Location.
  • bio -About/bio.
  • instagram_username - Instagram username.

Requires write_user scope

upload_photo(photo)

POST /photos

Args:

  • photo - the path of the photo to be uploaded.

Requires the write_photos scope

Thanks to https://stackoverflow.com/q/33557133/ for the solution on how to upload named files.

users(username)

GET /users/:username

Args:

  • username - the username string
users(username, arg2, opts \\ [])

GET /users/:username/likes

Args:

  • username - the username string