Code Monkey home page Code Monkey logo

flickr-sdk

Almost certainly the best Flickr API client in the world for node and the browser

This SDK provides methods and type definitions for all methods listed on https://www.flickr.com/services/api/

To use this SDK, sign up for an API key here

install

$ npm install flickr-sdk

quickstart

Make a Flickr API call

import { createFlickr } from "flickr-sdk"

const { flickr } = createFlickr("<your Flickr API key>")

const res = await flickr("flickr.photos.getInfo", {
    photo_id: '12345',
})

Upload a photo

import { createFlickr } from "flickr-sdk"
import { resolve } from "node:path"

const { upload } = createFlickr({
    consumerKey: "<your API key>",
    consumerSecret: "<your API secret>",
    oauthToken: "<the oauth token>",
    oauthTokenSecret: "<the oauth token secret>",
})

const id = await upload(resolve("example.png"), {
    title: "Works on MY machine!",
})

auth

The Flickr SDK currently supports the following auth methods:

API Key

This is the simplest way to use the SDK. Just provide your API key as a string:

const { flickr } = createFlickr("<your API key>")

OAuth 1.0

OAuth lets users grant your application access and then you may act on their behalf. The OAuth flow is described here.

const { upload } = createFlickr({
    consumerKey: "<your API key>",
    consumerSecret: "<your API secret>",
    oauthToken: "<the oauth token>",
    oauthTokenSecret: "<the oauth token secret>",
})

💡 Use examples/oauth.mjs to quickly set up an OAuth flow and obtain a set of credentials

migrating from previous versions

Previous versions of this SDK depended on superagent for http requests. This version of the SDK uses node's native fetch instead, so you now only receive the response body back from an API call. This means the return value of an API call will only be the response body, not a superagent Request

Migrating existing code looks like this:

//  old
const res = await flickr.test.login()
console.log(res.body)

// new
const body = await flickr('flickr.test.login')
console.log(body)

advanced

configuring fetch

import { createFlickr, FetchTransport } from 'flickr-sdk'

const transport = new FetchTransport({
    headers: {
        'user-agent': 'foo',
    }
})

const { flickr } = createFlickr('<your API key>', transport)

testing

import { createFlickr, MockTransport, NullAuth } from 'flickr-sdk'
import * as assert from 'node:assert'

// mock transport returns the response you pass in the constructor
const transport = new MockTransport({
    stat: 'ok',
})

// null auth does nothing
const auth = NullAuth()

const { flickr } = createFlickr(auth, transport)

// makes no network request
const res = await flickr('flickr.photos.getInfo', {
    photo_id: '12345',
})

assert.deepStrictEqual(res, { stat: 'ok', foo: 'bar' })

Flickr's Projects

debezium icon debezium

Change data capture for a variety of databases. https://debezium.io Please log issues in our JIRA at https://issues.jboss.org/projects/DBZ/issues

flconf icon flconf

Simple, pluggable, hierarchical configs

flickr-sdk icon flickr-sdk

Almost certainly the best Flickr API client in the world for node and the browser

justified-layout icon justified-layout

Pass in box sizes and get back sizes and coordinates for a justified layout

mdbm icon mdbm

MDBM a very fast memory-mapped key/value store.

plugin-flickr icon plugin-flickr

Akita CLI plugin for translating Flickr API conventions to a more REST-like format

tagexplodr icon tagexplodr

How to convert a big ol’ string of tags into a big ol’ array of tags

yakbak icon yakbak

Record and playback HTTP responses

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.