Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
flickr-sdk
Advanced tools
Almost certainly the best Flickr API client in the world for node and the browser
Almost certainly the best Flickr API client in the world for node and the browser
$ npm install flickr-sdk
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:
Example
var Flickr = require('flickr-sdk');
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.
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.
Kind: global class
Request
String
Request
function
Request
Request
Request
Request
Request
Request
Request
Request
Request
Request
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 // sorry, @dokas
}).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);
});
Kind: static class of Flickr
Request
String
Request
function
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
);
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);
});
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); // "https://www.flickr.com/services/oauth..."
res.setHeader("Location", url);
res.statusCode = 302;
res.end();
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);
});
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
));
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
));
Request
Kind: static class of Flickr
Extends: Request
See: https://www.flickr.com/services/api/upload.api.html
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);
});
Request
Kind: static class of Flickr
Extends: Request
See: https://www.flickr.com/services/api/replace.api.html
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);
});
Kind: static class of Flickr
Request
Request
Request
Request
Request
Request
Request
Request
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();
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/
Param | Type |
---|---|
[args] | Object |
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. |
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. |
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. |
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. |
Request
Returns a list of recent topics from the forum.
Kind: instance method of Feeds
See: https://www.flickr.com/services/feeds/docs/forums/
Param | Type |
---|---|
[args] | Object |
Request
Returns a list of recent comments on photostream and sets belonging to a given user.
Kind: instance method of Feeds
See: https://www.flickr.com/services/feeds/docs/activity/
Param | Type | Description |
---|---|---|
args | Object | |
args.user_id | Number | String | The user ID to fetch recent activity for. |
Request
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. |
Code licensed under the MIT license. See LICENSE file for terms.
FAQs
Almost certainly the best Flickr API client in the world for node and the browser
The npm package flickr-sdk receives a total of 1,130 weekly downloads. As such, flickr-sdk popularity was classified as popular.
We found that flickr-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.