Skip to content

Latest commit

 

History

History
106 lines (69 loc) · 2.97 KB

README.md

File metadata and controls

106 lines (69 loc) · 2.97 KB

node-flickr

A simple node wrapper for the Flickr API that supports oAuth authentication

This is a small library that adds a thin wrapper around the Flickr API to make it easier to call methods, sign them when necessary.

It currently does not support the RSS/Atom feeds, nor does it handle the oAuth login process. It may in the future -- I'd appreciate any patches if you have time.

The library is heavily inspired by the flickrnode library by Ciaran Jessup.

Current Test Status: Build Status

Usage

Install the library into your package.json file or using the following command:

npm install flickr

Once installed, you can interact with the library with something like this:

var Flickr = require('flickr').Flickr;

var client = new Flickr('YOUR_CONSUMER_KEY/API_KEY', 'YOUR_CONSUMER_SECRET', 
                        {"oauth_token": 'optional oauth token', "oauth_token_secret": 'optional oauth token secret'});

Some examples follow.

Examples

var flickr = new Flickr(flickr_api_key, flickr_api_secret);

var flickr_params = {
	text: "soccer",
	media: "photos",
	per_page: 25,
	page: 1,
	extras: "url_q, url_z, url_b, owner_name"
};

flickr.executeAPIRequest("flickr.photos.search", flickr_params, false, function(err, result) {
		// Show the error if we got one
		if(err) {
			console.log("FLICKR ERROR: " + err);

			return;
		}

		// Do something with flicker photos
		doSomething(result.photos)

Development

Contributions are welcome. Please feel free to submit pull requests. I prefer that pull requests come from properly named feature branches (don't dev in master!). This makes it easier for people scanning the Network tab above to see what your fork offers.

Running tests

To setup your local copy for testing, I recommend you run

npm link

in the project directory to install all the dependencies. I found that easiest.

Next, create a .env file in the root of the project directory. The Makefile sets up the testing environment to use those values. Yes, the tests run against the live API (for now).

You should probably start with the following contents:

FLICKR_API_KEY=<Your API Key>
FLICKR_API_SECRET=<Your API Secret>
FLICKR_OA_TOKEN=<A valid access token>
FLICKR_OA_TOKEN_SECRET=<A valid access token secret>

To get the access token and the access token secret, you will need to go through the OAuth dance. You can use something like this OAuth test client to generate those values. Using that tool is beyond the scope of this readme.

Then, whenever you want to run tests:

make test

You should get a nicely formatted output for your tests. You can also override the reporter used by Mocha by setting a REPORTER value in .env. Read the Makefile for details.

License

See the LICENSE file for details.