npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flickrphotos

v0.1.0

Published

A small module for getting image details from the flickr api

Downloads

8

Readme

flickrphotos

Right now this is a simple tool for getting metadata from the flickr API for photo ids. It allows you to request several photos at once and also different flickr API endpoints.

You can install it with npm install flickrphotos. It also comes with a little CLI, so you might also install it with the -g flag.

Note: If you use this somewhere, make sure to add the exact version number in your package.json since I might radically change the API of this module in the future.

Usage

Flickrphotos provides a Transform stream as well as the possibility to get photo information through a callback.

Get with callback

This snippets prints the name of the author of the picture.

var Flickrphotos = require('flickrphotos');
var flickr = new Flickrphotos(api_key);

flickr.get('13402819794', function(err, photoDetails) {
	console.log(photoDetails.getInfo.photo.owner.username);
});

By default only the getInfo endpoint is used. However other photo endpoints that take the photo_id as a parameter can also be enabled. For an overview have a look at the flickr API documentation, there are probably not many endpoints that match that requirement.

flickr.useEndpoints('getInfo', 'getSizes', 'getPerms');

flickr.get('13402819794', function(err, photoDetails) {
	console.log(photoDetails.getInfo.photo.owner.username);
	console.log(photoDetails.getSizes.sizes[0].url);
	console.log(photoDetails.getPerms.perms.ispublic);
});

It also allows to get information for several photos at once and return the json data as an unordered array.

flickr.get(['13402819794', '13715533304', '13659951344'], handlePhotos);

Transform stream

Flickrphotos is also a Transform stream in objectMode, which reads photo ids and writes the response objects.

var Flickrphotos = require('flickrphotos');
var flickr = new Flickrphotos(apiKey);
flickr.write('13402819794');
flickr.write('13402819794');
flickr.end();

If you want to use text streams, I recommend using something like split and JSONStream like this. This is also what the CLI of this module uses.

var split = require('split');
var JSONStream = require('JSONStream');
var Flickrphotos = require('flickrphotos');
var flickr = new Flickrphotos(apiKey);

fs.createWriteStream('photoids.txt')
	.pipe(split())
	.pipe(flickr)
	.pipe(JSONStream.stringify())
	.pipe(process.stdout);

Command line interface

If you install the package with the -g flag or link it, you may use the flickrphotos command by specifying the flickr api key and the photoids. The result will be an array of photo meta data for each photo.

flickrphotos -k <flickr-api-key> 13402819794 13715533304 > imagedata.json

You can also pipe photo ids seperated by newlines into the command.

photoids.txt > flickrphotos -k <flickr-api-key> > photodata.json

To get more information about the options of this command, have a look at

flickrphotos -h