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

@moontai0724/flickr-sdk

v1.1.3

Published

A TypeScript SDK for Flickr API

Downloads

10

Readme

@moontai0724/flickr-sdk

NPM Version NPM Downloads Codecov

[WIP] A TypeScript SDK for Flickr API.

Currently this SDK implements following apis:

  • OAuth.*
  • Upload.*
  • Rest
    • photosets.*
    • photos
      • photos.upload.*
      • photos.getInfo
      • photos.getSizes
      • photos.setMeta

Install

NPM

npm install @moontai0724/flickr-sdk

Yarn

yarn add @moontai0724/flickr-sdk

PNPM

pnpm add @moontai0724/flickr-sdk

API Document

You can see the API documentation to know more about all implementations in this SDK.

Usage

Overview

flickrApis

This includes pure api implementations without additional features but modified the response keys to camelCase. All apis are independent implementations and can be used separately.

It contains the following sub-objects:

  • auth: oauth authorization related apis
  • upload: upload items related apis
  • rest: all other apis

Rest

import { flickrApis } from "@moontai0724/flickr-sdk";

flickrApis.rest.photosets
  .getList({
    credentials: { apiKey: "..." },
    userId: "140551311@N06",
  })
  .then(console.log)
  .catch(console.error);
/*
{
  page: 1,
  pages: 1,
  perpage: 500,
  total: 8,
  photoset: [
    {
      id: '72177720309455960',
      ...
      title: 'SONY IER-M9',
      description: '',
      canComment: 0,
      dateCreate: '1688200478',
      dateUpdate: '1722222710',
      ...
    },
    ...
  ]
}
 */

OAuth

To use apis with authorization, you should follows the guide on Flickr. In order to get the tokens for user, you have to use apis in this collection to request the token.

To request the token and construct the url for user to authorize the app:

import { flickrApis } from "@moontai0724/flickr-sdk";

const oauth = await flickrApis.auth.requestToken(
  apiKey,
  consumerSecret,
  "https://example.com/oauth-callback",
);

console.log("Got 1st oauth token: ", oauth);
/*
Got 1st oauth token: {
  oauthToken: "...",
  oauthTokenSecret: "...",
}
 */

const authorizeUrl = flickrApis.auth.constructAuthUrl(oauthToken, "delete");

console.log("Please click the link and authorize the app: ", authorizeUrl);
// https://www.flickr.com/services/oauth/authorize?oauth_token=abc-123&perms=delete

After user authorized the app, it will have a verifier in the redirected url. Use it to get the permanent user oauth token:

import { flickrApis } from "@moontai0724/flickr-sdk";

const result = await flickrApis.auth.accessToken(
  apiKey,
  consumerSecret,
  oauthToken, // from the 1st step
  oauthTokenSecret, // from the 1st step
  verifier, // from the callback url
);

console.log("Got user oauth token: ", result);
/*
Got user oauth token: {
  oauthToken: "...",
  oauthTokenSecret: "...",
  ...
}
 */

Upload

To upload or replace photos, you can to use this collection.

import { flickrApis } from "@moontai0724/flickr-sdk";

flickrApis.upload
  .upload({
    credentials: {
      apiKey: "...", // application key
      consumerSecret: "...", // application secret
      oauthToken: "...", // user oauth token
      oauthTokenSecret: "...", // user oauth token
    },
    photo: new File(["..."], "..."), // photo file
  })
  .then(console.log)
  .catch(console.error);