flickr-sdk
Almost certainly the best Flickr API client in the world for node and the browser
Install
$ npm install flickr-sdk
Usage
flickr-sdk is based on superagent and all methods that make API calls will return a superagent Request instance configured for the request. This means that you can do anything with Flickr requests that you can do with superagent.
The Flickr API is divided into several services:
- The REST API service, which provides access to Flickr data
- The OAuth service, which authenticates users via OAuth 1.0
- The Feeds service, which provides feeds of public Flickr data
- The Upload service, where you can upload photos!
- The Replace service, where you can replace photos you previously uploaded
Example
var Flickr = require('flickr-sdk');
Browser Usage
Since OAuth 1.0 requires your application's key and secret to sign requests, flickr-sdk does not support this authentication method in the browser. Upload, Replace, and REST API calls that require authentication will not work without a valid OAuth signature. You can still use flickr-sdk to call REST API methods that don't require authentication or to get public feeds.
flickr-sdk has been tested with browserify but should work with other client-side module bundlers like webpack and rollup. If you need a standalone browser-ready version of flickr-sdk, each release on npm will contain a browserified version of this module at node_modules/flickr-sdk/flickr-sdk.js
. It is not minified.
Flickr
All of the REST API methods are available on the
Flickr prototype. Each method accepts a single parameter
which is an optional hash of arguments. Refer to the REST API
docs for the full list of methods and their supported arguments.
Method | Permissions | Required Arguments |
---|
flickr.activity.userComments | read :eyes: | |
flickr.activity.userPhotos | read :eyes: | |
flickr.auth.checkToken | none | auth_token |
flickr.auth.getFrob | none | |
flickr.auth.getFullToken | none | mini_token |
flickr.auth.getToken | none | frob |
flickr.auth.oauth.checkToken | none | oauth_token |
flickr.auth.oauth.getAccessToken | none | |
flickr.blogs.getList | read :eyes: | |
flickr.blogs.getServices | none | |
flickr.blogs.postPhoto | write :pencil2: | photo_id , title , description |
flickr.cameras.getBrandModels | none | brand |
flickr.cameras.getBrands | none | |
flickr.collections.getInfo | read :eyes: | collection_id |
flickr.collections.getTree | none | |
flickr.commons.getInstitutions | none | |
flickr.contacts.getList | read :eyes: | |
flickr.contacts.getListRecentlyUploaded | read :eyes: | |
flickr.contacts.getPublicList | none | user_id |
flickr.contacts.getTaggingSuggestions | read :eyes: | |
flickr.favorites.add | write :pencil2: | photo_id |
flickr.favorites.getContext | none | photo_id , user_id |
flickr.favorites.getList | none | |
flickr.favorites.getPublicList | none | user_id |
flickr.favorites.remove | write :pencil2: | photo_id |
flickr.galleries.addPhoto | write :pencil2: | gallery_id , photo_id |
flickr.galleries.create | write :pencil2: | title , description |
flickr.galleries.editMeta | write :pencil2: | gallery_id , title |
flickr.galleries.editPhoto | write :pencil2: | gallery_id , photo_id , comment |
flickr.galleries.editPhotos | write :pencil2: | gallery_id , primary_photo_id , photo_ids |
flickr.galleries.getInfo | none | gallery_id |
flickr.galleries.getList | none | user_id |
flickr.galleries.getListForPhoto | none | photo_id |
flickr.galleries.getPhotos | none | gallery_id |
flickr.groups.browse | read :eyes: | |
flickr.groups.getInfo | none | group_id |
flickr.groups.join | write :pencil2: | group_id |
flickr.groups.joinRequest | write :pencil2: | group_id , message , accept_rules |
flickr.groups.leave | delete :boom: | group_id |
flickr.groups.search | none | text |
flickr.groups.discuss.replies.add | write :pencil2: | group_id , topic_id , message |
flickr.groups.discuss.replies.delete | delete :boom: | group_id , topic_id , reply_id |
flickr.groups.discuss.replies.edit | write :pencil2: | group_id , topic_id , reply_id , message |
flickr.groups.discuss.replies.getInfo | none | group_id , topic_id , reply_id |
flickr.groups.discuss.replies.getList | none | group_id , topic_id , per_page |
flickr.groups.discuss.topics.add | write :pencil2: | group_id , subject , message |
flickr.groups.discuss.topics.getInfo | none | group_id , topic_id |
flickr.groups.discuss.topics.getList | none | group_id |
flickr.groups.members.getList | read :eyes: | group_id |
flickr.groups.pools.add | write :pencil2: | photo_id , group_id |
flickr.groups.pools.getContext | none | photo_id , group_id |
flickr.groups.pools.getGroups | read :eyes: | |
flickr.groups.pools.getPhotos | none | group_id |
flickr.groups.pools.remove | write :pencil2: | photo_id , group_id |
flickr.interestingness.getList | none | |
flickr.machinetags.getNamespaces | none | |
flickr.machinetags.getPairs | none | |
flickr.machinetags.getPredicates | none | |
flickr.machinetags.getRecentValues | none | |
flickr.machinetags.getValues | none | namespace , predicate |
flickr.panda.getList | none | |
flickr.panda.getPhotos | none | panda_name |
flickr.people.findByEmail | none | find_email |
flickr.people.findByUsername | none | username |
flickr.people.getGroups | read :eyes: | user_id |
flickr.people.getInfo | none | user_id |
flickr.people.getLimits | read :eyes: | |
flickr.people.getPhotos | none | user_id |
flickr.people.getPhotosOf | none | user_id |
flickr.people.getPublicGroups | none | user_id |
flickr.people.getPublicPhotos | none | user_id |
flickr.people.getUploadStatus | read :eyes: | |
flickr.photos.addTags | write :pencil2: | photo_id , tags |
flickr.photos.delete | delete :boom: | photo_id |
flickr.photos.getAllContexts | none | photo_id |
flickr.photos.getContactsPhotos | read :eyes: | |
flickr.photos.getContactsPublicPhotos | none | user_id |
flickr.photos.getContext | none | photo_id |
flickr.photos.getCounts | read :eyes: | |
flickr.photos.getExif | none | photo_id |
flickr.photos.getFavorites | none | photo_id |
flickr.photos.getInfo | none | photo_id |
flickr.photos.getNotInSet | read :eyes: | |
flickr.photos.getPerms | read :eyes: | photo_id |
flickr.photos.getPopular | none | |
flickr.photos.getRecent | none | |
flickr.photos.getSizes | none | photo_id |
flickr.photos.getUntagged | read :eyes: | |
flickr.photos.getWithGeoData | read :eyes: | |
flickr.photos.getWithoutGeoData | read :eyes: | |
flickr.photos.recentlyUpdated | read :eyes: | min_date |
flickr.photos.removeTag | write :pencil2: | tag_id |
flickr.photos.search | none | |
flickr.photos.setContentType | write :pencil2: | photo_id , content_type |
flickr.photos.setDates | write :pencil2: | photo_id |
flickr.photos.setMeta | write :pencil2: | photo_id |
flickr.photos.setPerms | write :pencil2: | photo_id , is_public , is_friend , is_family |
flickr.photos.setSafetyLevel | write :pencil2: | photo_id |
flickr.photos.setTags | write :pencil2: | photo_id , tags |
flickr.photos.comments.addComment | write :pencil2: | photo_id , comment_text |
flickr.photos.comments.deleteComment | write :pencil2: | comment_id |
flickr.photos.comments.editComment | write :pencil2: | comment_id , comment_text |
flickr.photos.comments.getList | none | photo_id |
flickr.photos.comments.getRecentForContacts | read :eyes: | |
flickr.photos.geo.batchCorrectLocation | write :pencil2: | lat , lon , accuracy |
flickr.photos.geo.correctLocation | write :pencil2: | photo_id , foursquare_id |
flickr.photos.geo.getLocation | none | photo_id |
flickr.photos.geo.getPerms | read :eyes: | photo_id |
flickr.photos.geo.photosForLocation | read :eyes: | lat , lon |
flickr.photos.geo.removeLocation | write :pencil2: | photo_id |
flickr.photos.geo.setContext | write :pencil2: | photo_id , context |
flickr.photos.geo.setLocation | write :pencil2: | photo_id , lat , lon |
flickr.photos.geo.setPerms | write :pencil2: | is_public , is_contact , is_friend , is_family , photo_id |
flickr.photos.licenses.getInfo | none | |
flickr.photos.licenses.setLicense | write :pencil2: | photo_id , license_id |
flickr.photos.notes.add | write :pencil2: | photo_id , note_x , note_y , note_w , note_h , note_text |
flickr.photos.notes.delete | write :pencil2: | note_id |
flickr.photos.notes.edit | write :pencil2: | note_id , note_x , note_y , note_w , note_h , note_text |
flickr.photos.people.add | write :pencil2: | photo_id , user_id |
flickr.photos.people.delete | write :pencil2: | photo_id , user_id |
flickr.photos.people.deleteCoords | write :pencil2: | photo_id , user_id |
flickr.photos.people.editCoords | write :pencil2: | photo_id , user_id , person_x , person_y , person_w , person_h |
flickr.photos.people.getList | none | photo_id |
flickr.photos.suggestions.approveSuggestion | write :pencil2: | suggestion_id |
flickr.photos.suggestions.getList | read :eyes: | |
flickr.photos.suggestions.rejectSuggestion | write :pencil2: | suggestion_id |
flickr.photos.suggestions.removeSuggestion | write :pencil2: | suggestion_id |
flickr.photos.suggestions.suggestLocation | write :pencil2: | photo_id , lat , lon |
flickr.photos.transform.rotate | write :pencil2: | photo_id , degrees |
flickr.photos.upload.checkTickets | none | tickets |
flickr.photosets.addPhoto | write :pencil2: | photoset_id , photo_id |
flickr.photosets.create | write :pencil2: | title , primary_photo_id |
flickr.photosets.delete | write :pencil2: | photoset_id |
flickr.photosets.editMeta | write :pencil2: | photoset_id , title |
flickr.photosets.editPhotos | write :pencil2: | photoset_id , primary_photo_id , photo_ids |
flickr.photosets.getContext | none | photo_id , photoset_id |
flickr.photosets.getInfo | none | photoset_id , user_id |
flickr.photosets.getList | none | |
flickr.photosets.getPhotos | none | photoset_id , user_id |
flickr.photosets.orderSets | write :pencil2: | photoset_ids |
flickr.photosets.removePhoto | write :pencil2: | photoset_id , photo_id |
flickr.photosets.removePhotos | write :pencil2: | photoset_id , photo_ids |
flickr.photosets.reorderPhotos | write :pencil2: | photoset_id , photo_ids |
flickr.photosets.setPrimaryPhoto | write :pencil2: | photoset_id , photo_id |
flickr.photosets.comments.addComment | write :pencil2: | photoset_id , comment_text |
flickr.photosets.comments.deleteComment | write :pencil2: | comment_id |
flickr.photosets.comments.editComment | write :pencil2: | comment_id , comment_text |
flickr.photosets.comments.getList | none | photoset_id |
flickr.places.find | none | query |
flickr.places.findByLatLon | none | lat , lon |
flickr.places.getChildrenWithPhotosPublic | none | |
flickr.places.getInfo | none | |
flickr.places.getInfoByUrl | none | url |
flickr.places.getPlaceTypes | none | |
flickr.places.getShapeHistory | none | |
flickr.places.getTopPlacesList | none | place_type_id |
flickr.places.placesForBoundingBox | none | bbox |
flickr.places.placesForContacts | read :eyes: | |
flickr.places.placesForTags | none | place_type_id |
flickr.places.placesForUser | read :eyes: | |
flickr.places.resolvePlaceId | none | place_id |
flickr.places.resolvePlaceURL | none | url |
flickr.places.tagsForPlace | none | |
flickr.prefs.getContentType | read :eyes: | |
flickr.prefs.getGeoPerms | read :eyes: | |
flickr.prefs.getHidden | read :eyes: | |
flickr.prefs.getPrivacy | read :eyes: | |
flickr.prefs.getSafetyLevel | read :eyes: | |
flickr.profile.getProfile | none | user_id |
flickr.push.getSubscriptions | read :eyes: | |
flickr.push.getTopics | none | |
flickr.push.subscribe | read :eyes: | topic , callback , verify |
flickr.push.unsubscribe | read :eyes: | topic , callback , verify |
flickr.reflection.getMethodInfo | none | method_name |
flickr.reflection.getMethods | none | |
flickr.stats.getCSVFiles | read :eyes: | |
flickr.stats.getCollectionDomains | read :eyes: | date |
flickr.stats.getCollectionReferrers | read :eyes: | date , domain |
flickr.stats.getCollectionStats | read :eyes: | date , collection_id |
flickr.stats.getPhotoDomains | read :eyes: | date |
flickr.stats.getPhotoReferrers | read :eyes: | date , domain |
flickr.stats.getPhotoStats | read :eyes: | date , photo_id |
flickr.stats.getPhotosetDomains | read :eyes: | date |
flickr.stats.getPhotosetReferrers | read :eyes: | date , domain |
flickr.stats.getPhotosetStats | read :eyes: | date , photoset_id |
flickr.stats.getPhotostreamDomains | read :eyes: | date |
flickr.stats.getPhotostreamReferrers | read :eyes: | date , domain |
flickr.stats.getPhotostreamStats | read :eyes: | date |
flickr.stats.getPopularPhotos | read :eyes: | |
flickr.stats.getTotalViews | read :eyes: | |
flickr.tags.getClusterPhotos | none | tag , cluster_id |
flickr.tags.getClusters | none | tag |
flickr.tags.getHotList | none | |
flickr.tags.getListPhoto | none | photo_id |
flickr.tags.getListUser | none | |
flickr.tags.getListUserPopular | none | |
flickr.tags.getListUserRaw | none | |
flickr.tags.getMostFrequentlyUsed | read :eyes: | |
flickr.tags.getRelated | none | tag |
flickr.test.echo | none | |
flickr.test.login | read :eyes: | |
flickr.test.null | read :eyes: | |
flickr.testimonials.addTestimonial | write :pencil2: | user_id , testimonial_text |
flickr.testimonials.approveTestimonial | write :pencil2: | testimonial_id |
flickr.testimonials.deleteTestimonial | write :pencil2: | testimonial_id |
flickr.testimonials.editTestimonial | write :pencil2: | user_id , testimonial_id , testimonial_text |
flickr.testimonials.getAllTestimonialsAbout | read :eyes: | |
flickr.testimonials.getAllTestimonialsAboutBy | read :eyes: | user_id |
flickr.testimonials.getAllTestimonialsBy | read :eyes: | |
flickr.testimonials.getPendingTestimonialsAbout | read :eyes: | |
flickr.testimonials.getPendingTestimonialsAboutBy | read :eyes: | user_id |
flickr.testimonials.getPendingTestimonialsBy | read :eyes: | |
flickr.testimonials.getTestimonialsAbout | none | user_id |
flickr.testimonials.getTestimonialsAboutBy | read :eyes: | user_id |
flickr.testimonials.getTestimonialsBy | none | user_id |
flickr.urls.getGroup | none | group_id |
flickr.urls.getUserPhotos | none | |
flickr.urls.getUserProfile | none | |
flickr.urls.lookupGallery | none | url |
flickr.urls.lookupGroup | none | url |
flickr.urls.lookupUser | none | url |
Kind: global class
new Flickr(auth)
Creates a new Flickr REST API client.
You must pass a superagent plugin or your API key as the first
parameter. For methods that don't require authentication, you can simply
provide your API key. For methods that do require authentication,
use the OAuth plugin.
Param | Type | Description |
---|
auth | function | String | An authentication plugin function or an API key |
Example (Get info about a public photo with your API key)
var flickr = new Flickr(process.env.FLICKR_API_KEY);
flickr.photos.getInfo({
photo_id: 25825763
}).then(function (res) {
console.log('yay!', res.body);
}).catch(function (err) {
console.error('bonk', err);
});
Example (Searching for public photos with your API key)
var flickr = new Flickr(process.env.FLICKR_API_KEY);
flickr.photos.search({
text: 'doggo'
}).then(function (res) {
console.log('yay!', res.body);
}).catch(function (err) {
console.error('bonk', err);
});
Example (Authenticate as a user with the OAuth plugin)
var flickr = new Flickr(Flickr.OAuth.createPlugin(
process.env.FLICKR_CONSUMER_KEY,
process.env.FLICKR_CONSUMER_SECRET,
process.env.FLICKR_OAUTH_TOKEN,
process.env.FLICKR_OAUTH_TOKEN_SECRET
));
flickr.test.login().then(function (res) {
console.log('yay!', res.body);
}).catch(function (err) {
console.error('bonk', err);
});
Flickr.OAuth
Kind: static class of Flickr
new OAuth(consumerKey, consumerSecret)
Creates a new OAuth service instance. You can use this service to
request and validate OAuth tokens, as well as generate an auth
plugin suitable for use with the REST and Upload services.
You need to register an application
to obtain your consumerKey
and consumerSecret
.
OAuth 1.0 requires your consumer secret to sign calls,
and you should never expose secrets to the browser.
Param | Type | Description |
---|
consumerKey | String | The application's API key |
consumerSecret | String | The application's API secret |
Example
var oauth = new Flickr.OAuth(
process.env.FLICKR_CONSUMER_KEY,
process.env.FLICKR_CONSUMER_SECRET
);
oAuth.request(oauthCallback) ⇒ Request
Get a Request Token using the consumer key.
Kind: instance method of OAuth
See
Param | Type | Description |
---|
oauthCallback | String | Your application's OAuth callback URL |
Example
oauth.request('http://localhost:3000/oauth/callback').then(function (res) {
console.log('yay!', res);
}).catch(function (err) {
console.error('bonk', err);
});
oAuth.authorizeUrl(requestToken, [perms]) ⇒ String
Returns the authorization url for requestToken
. You may also pass
the perms
your app is requesting as read
(the default), write
,
or delete
. Your application should redirect the user here to ask
them to verify your request token.
Kind: instance method of OAuth
See: https://www.flickr.com/services/api/auth.oauth.html#authorization
Param | Type | Default | Description |
---|
requestToken | String | | The OAuth request token |
[perms] | String | read | Permission level, may be "read", "write" or "delete" |
Example
var url = oauth.authorizeUrl(requestToken);
res.setHeader("Location", url);
res.statusCode = 302;
res.end();
oAuth.verify(oauthToken, oauthVerifier, tokenSecret) ⇒ Request
Verify an OAuth token using the verifier and token secret. If your user
has indeed verified your request token, you will receive an OAuth token
and secret back, as well as some very basic profile information. You
can now use this token and secret to make calls to the REST API.
Kind: instance method of OAuth
See
Param | Type | Description |
---|
oauthToken | String | The OAuth token to verify |
oauthVerifier | String | The OAuth token verifier string you received from the callback |
tokenSecret | String | The OAuth token secret |
Example
oauth.verify(oauthToken, oauthVerifier, tokenSecret).then(function (res) {
console.log('oauth token:', res.body.oauth_token);
console.log('oauth token secret:', res.body.oauth_token_secret);
}).catch(function (err) {
console.log('bonk', err);
});
oAuth.plugin(oauthToken, oauthTokenSecret) ⇒ function
Returns an oauth plugin for this consumer key and secret.
Kind: instance method of OAuth
Param | Type | Description |
---|
oauthToken | String | The OAuth token |
oauthTokenSecret | String | The OAuth token secret |
Example
var flickr = new Flickr(oauth.plugin(
oauthToken,
oauthTokenSecret
));
OAuth.createPlugin(consumerKey, consumerSecret, oauthToken, oauthTokenSecret) ⇒ function
Returns an oauth plugin for this consumer key, consumer secret,
oauth token and oauth token secret,
Kind: static method of OAuth
Param | Type | Description |
---|
consumerKey | String | The application's API key |
consumerSecret | String | The application's API secret |
oauthToken | String | The OAuth token |
oauthTokenSecret | String | The OAuth token secret |
Example
var flickr = new Flickr(Flickr.OAuth.createPlugin(
process.env.FLICKR_CONSUMER_KEY,
process.env.FLICKR_CONSUMER_SECRET,
process.env.FLICKR_OAUTH_TOKEN,
process.env.FLICKR_OAUTH_TOKEN_SECRET
));
Flickr.Upload ⇐ Request
Kind: static class of Flickr
Extends: Request
See: https://www.flickr.com/services/api/upload.api.html
new Upload(auth, file, [args])
Creates a new Upload service instance. Since the Upload API only
does one thing (upload files), an Upload instance is simply
a Request subclass.
The Upload endpoint requires authentication. You should pass a configured
instance of the OAuth plugin to upload
photos on behalf of another user.
Param | Type |
---|
auth | function |
file | String | fs.ReadStream | Buffer |
[args] | Object |
Example
var upload = new Flickr.Upload(auth, 'upload.png', {
title: 'Works on MY machine!'
});
upload.then(function (res) {
console.log('yay!', res.body);
}).catch(function (err) {
console.error('bonk', err);
});
Flickr.Replace ⇐ Request
Kind: static class of Flickr
Extends: Request
See: https://www.flickr.com/services/api/replace.api.html
new Replace(auth, photoID, file, [args])
Creates a new Replace service instance. Since the Replace API only
does one thing (replace files), an Replace instance is simply
a Request subclass.
The Replace endpoint requires authentication. You should pass a configured
instance of the OAuth plugin to replace
photos on behalf of another user.
Param | Type | Description |
---|
auth | function | |
photoID | Number | String | The ID of the photo to replace |
file | String | fs.ReadStream | Buffer | |
[args] | Object | |
Example
var replace = new Flickr.Replace(auth, 41234567890, 'replace.png', {
title: 'Now in pink!'
});
replace.then(function (res) {
console.log('yay!', res.body);
}).catch(function (err) {
console.error('bonk', err);
});
Flickr.Feeds
Kind: static class of Flickr
new Feeds([args])
Creates a new Feeds service instance. You can use this instance
to explore and retrieve public Flickr API data.
Param | Type | Default | Description |
---|
[args] | Object | | Arguments that will be passed along with every feed request |
[args.format] | String | json | The feed response format |
[args.lang] | String | en-us | The language to request for the feed |
Example
var feeds = new Flickr.Feeds();
feeds.publicPhotos([args]) ⇒ Request
Returns a list of public content matching some criteria.
Kind: instance method of Feeds
See: https://www.flickr.com/services/feeds/docs/photos_public/
feeds.friendsPhotos(args) ⇒ Request
Returns a list of public content from the contacts, friends & family of a given person.
Kind: instance method of Feeds
See: https://www.flickr.com/services/feeds/docs/photos_friends/
Param | Type | Description |
---|
args | Object | |
args.user_id | Number | String | The user ID of the user to fetch friends' photos and videos for. |
feeds.favePhotos(args) ⇒ Request
Returns a list of public favorites for a given user.
Kind: instance method of Feeds
See: https://www.flickr.com/services/feeds/docs/photos_faves/
Param | Type | Description |
---|
args | Object | |
args.id | Number | String | A single user ID. This specifies a user to fetch for. |
feeds.groupDiscussions(args) ⇒ Request
Returns a list of recent discussions in a given group.
Kind: instance method of Feeds
See: https://www.flickr.com/services/feeds/docs/groups_discuss/
Param | Type | Description |
---|
args | Object | |
args.id | Number | The ID of the group to fetch discussions for. |
feeds.groupPool(args) ⇒ Request
Returns a list of things recently added to the pool of a given group.
Kind: instance method of Feeds
See: https://www.flickr.com/services/feeds/docs/groups_pool/
Param | Type | Description |
---|
args | Object | |
args.id | Number | The ID of the group to fetch for. |
feeds.forum([args]) ⇒ Request
Returns a list of recent topics from the forum.
Kind: instance method of Feeds
See: https://www.flickr.com/services/feeds/docs/forums/
Returns a list of recent comments that have been commented on by a given person.
Kind: instance method of Feeds
See: https://www.flickr.com/services/feeds/docs/photos_comments/
Param | Type | Description |
---|
args | Object | |
args.user_id | Number | String | The user ID to fetch recent comments for. |
License
Code licensed under the MIT license. See LICENSE file for terms.