superdeclarative_unsplash_client 0.0.3 copy "superdeclarative_unsplash_client: ^0.0.3" to clipboard
superdeclarative_unsplash_client: ^0.0.3 copied to clipboard

An Unsplash API client written in Dart

Unsplash Client #

A Dart Client for the Unsplash API.

This is a SuperDeclarative! project, not an official Unsplash package


Unsplash is a service that provides access to royalty free stock photographs. In addition to direct browsing of photographs, Unsplash offers a developer API for accessing photos, collections of photos, users of the platform, and more.

This package is a client for the Unsplash API, built in the Dart language.

Unsplash API documentation: https://unsplash.com/documentation


Quickstart #

Create a client:

final unsplashClient = UnsplashClient(
  accessKey: YOUR_API_KEY,
);

Get a random photo:

final Photo photo = await unsplashClient.getRandomPhoto();

Get a specified photo:

final Photo photo = await unsplashClient.getPhoto(id: 'some_photo_id');

Search photos:

final PhotoSearchPage page = await unsplashClient.searchPhotos(
  query: 'some query or blank for featured photos',
);

Load pages of photos:

final paginator = Paginator.listPhotos(
  client: unsplashClient,
)..loadNextPage();

Run Tests #

To run the tests in this package, define an environment variable called UNSPLASH_KEY and set its value to your unsplash API key.

$ dart test

or

$ flutter test

Support for flutter test will probably be removed as soon as the CI system supports the Dart version. This is because a Dart package should not depend upon Flutter's testing system.


Example Project #

An example project, built with Flutter, is available in the /example directory.


Supported Calls #

API Version 1 #

Authentication

  • ✅ HTTP Basic Authentication
  • ❌ User Authentication Flow
  • ❌ Dynamic Client Registration

Current User

  • ❌ GET /me
  • ❌ PUT /me

Users

  • ❌ GET /users/:username
  • ❌ GET /users/:username/portfolio
  • ❌ GET /users/:username/photos
  • ❌ GET /users/:username/likes
  • ❌ GET /users/:username/collections
  • ❌ GET /users/:username/statistics

Photos

  • ✅ GET /photos
  • ✅ GET /photos/:id
  • ✅ GET /photos/random
  • ✅ GET /photos/:id/statistics
  • ❌ GET /photos/:id/download
  • ❌ PUT /photos/:id
  • ❌ POST /photos/:id/like
  • ❌ DELETE /photos/:id/like
  • ✅ GET /search/photos
  • ✅ GET /search/collections
  • ✅ GET /search/users

Collections

  • ✅ GET /collections
  • ✅ GET /collections/featured
  • ✅ GET /collections/:id
  • ❌ GET /collections/:id/photos
  • ❌ GET /collections/:id/related
  • ❌ POST /collections
  • ❌ PUT /collections/:id
  • ❌ DELETE /collections/:id
  • ❌ POST /collections/:collection_id/add
  • ❌ DELETE /collections/:collection_id/remove

Stats

  • ✅ GET /stats/total
  • ✅ GET /stats/month