A proxy in NodeJS/Express that make calls to the Flickr API and avoids the complexity of the authentication process.
If you want to call the Flickr API and forget the authentication process, that project will be useful. With this proxy you can call to:
- Flickr API methods that don't need authentication.
- Flickr API methods that need authentication with read privileges.
Note: Methods that need authentication with write privileges are not implemented.
Just:
$ git clone https://github.com/aaronplanell/flickr-backend-example.git
$ cd flickr-backend-example
$ npm install
Obviously, the last line can be replaced by:
$ yarn install
Just open the file src/constants.js
and replace the consumer key/secret:
export const FLICKR_CONSUMER_KEY = 'b7718b2dc66dee760a0f66c56f507434';
export const FLICKR_CONSUMER_SECRET = 'topSecret';
You can obtain the consumer key/secret in the web of Flickr.
NOTE: Never publish your consumer key/secret in Github or other site. I published mine because is a fake account.
First of all run:
$ npm start
Or:
$ yarn start
You will see a message like this:
yarn start v0.21.3
$ babel-node src/index.js --presets es2015,stage-2
Express server listening on port 3000
First of all, you must validate the application opening: http://127.0.0.1:3000/
Open your browser and access to the URL http://127.0.0.1:3000/. The main page will be redirected you to the Flickr API page of authorization. Accept making click into the blue button. After that, you will be redirected to the previous local page and you will see this message:
Well... You're connected. You can work with the API :D
Your Flickr API Proxy will be running.
When the proxy is ready you will see at the console the list of available methods:
Checking available methods:
- Adding method flickr.auth.getToken (no authentication needed).
- Adding method flickr.activity.userComments (authentication needed with read permissions).
- Adding method flickr.auth.getFrob (no authentication needed).
- Adding method flickr.auth.oauth.getAccessToken (no authentication needed).
- Adding method flickr.activity.userPhotos (authentication needed with read permissions).
- Etc.
If, for instance, you want to search the photos of the user 148575064@N08
just call:
http://127.0.0.1:3000/flickr.photos.search?user_id=148575064@N08
The parameters of each method are the same that in the original Flickr API but with an exception: you don't need to pass the parameter api_key
because you are autenthicated.
This proxy implements those methods that:
- Don't need authentication.
- Need authentication with read privileges.
Methods with write privileges are not allowed.
This is the full list:
- flickr.activity.userPhotos.
- flickr.auth.oauth.checkToken.
- flickr.auth.checkToken.
- flickr.auth.getFullToken.
- flickr.cameras.getBrandModels.
- flickr.activity.userComments.
- flickr.blogs.getServices.
- flickr.auth.getToken.
- flickr.blogs.getList.
- flickr.collections.getInfo.
- flickr.cameras.getBrands.
- flickr.collections.getTree.
- flickr.auth.oauth.getAccessToken.
- flickr.commons.getInstitutions.
- flickr.contacts.getList.
- flickr.contacts.getListRecentlyUploaded.
- flickr.auth.getFrob.
- flickr.contacts.getPublicList.
- flickr.contacts.getTaggingSuggestions.
- flickr.favorites.getList.
- flickr.favorites.getContext.
- flickr.favorites.getPublicList.
- flickr.galleries.getInfo.
- flickr.galleries.getPhotos.
- flickr.galleries.getListForPhoto.
- flickr.groups.browse.
- flickr.groups.discuss.replies.getInfo.
- flickr.galleries.getList.
- flickr.groups.discuss.replies.getList.
- flickr.groups.discuss.topics.getInfo.
- flickr.groups.discuss.topics.getList.
- flickr.groups.getInfo.
- flickr.groups.pools.getContext.
- flickr.groups.members.getList.
- flickr.groups.pools.getPhotos.
- flickr.groups.search.
- flickr.interestingness.getList.
- flickr.groups.pools.getGroups.
- flickr.machinetags.getPredicates.
- flickr.machinetags.getNamespaces.
- flickr.machinetags.getRecentValues.
- flickr.machinetags.getPairs.
- flickr.machinetags.getValues.
- flickr.panda.getList.
- flickr.panda.getPhotos.
- flickr.people.findByEmail.
- flickr.people.getLimits.
- flickr.people.findByUsername.
- flickr.people.getInfo.
- flickr.people.getGroups.
- flickr.people.getPhotos.
- flickr.people.getPhotosOf.
- flickr.people.getPublicGroups.
- flickr.people.getPublicPhotos.
- flickr.photos.comments.getList.
- flickr.photos.comments.getRecentForContacts.
- flickr.people.getUploadStatus.
- flickr.photos.geo.getLocation.
- flickr.photos.geo.getPerms.
- flickr.photos.geo.photosForLocation.
- flickr.photos.getAllContexts.
- flickr.photos.getContactsPhotos.
- flickr.photos.getContext.
- flickr.photos.getExif.
- flickr.photos.getCounts.
- flickr.photos.getInfo.
- flickr.photos.getNotInSet.
- flickr.photos.getPerms.
- flickr.photos.getFavorites.
- flickr.photos.getRecent.
- flickr.photos.getPopular.
- flickr.photos.getWithGeoData.
- flickr.photos.getContactsPublicPhotos.
- flickr.photos.getUntagged.
- flickr.photos.getWithoutGeoData.
- flickr.photos.getSizes.
- flickr.photos.licenses.getInfo.
- flickr.photos.people.getList.
- flickr.photos.recentlyUpdated.
- flickr.photos.suggestions.getList.
- flickr.photos.search.
- flickr.photos.upload.checkTickets.
- flickr.photosets.comments.getList.
- flickr.photosets.getContext.
- flickr.photosets.getList.
- flickr.photosets.getPhotos.
- flickr.photosets.getInfo.
- flickr.places.find.
- flickr.places.findByLatLon.
- flickr.places.getChildrenWithPhotosPublic.
- flickr.places.getInfo.
- flickr.places.getInfoByUrl.
- flickr.places.getShapeHistory.
- flickr.places.getTopPlacesList.
- flickr.places.placesForBoundingBox.
- flickr.places.getPlaceTypes.
- flickr.places.placesForTags.
- flickr.places.placesForUser.
- flickr.places.resolvePlaceId.
- flickr.prefs.getContentType.
- flickr.places.tagsForPlace.
- flickr.places.resolvePlaceURL.
- flickr.prefs.getGeoPerms.
- flickr.prefs.getHidden.
- flickr.places.placesForContacts.
- flickr.prefs.getPrivacy.
- flickr.profile.getProfile.
- flickr.prefs.getSafetyLevel.
- flickr.push.getSubscriptions.
- flickr.push.subscribe.
- flickr.push.getTopics.
- flickr.stats.getCollectionReferrers.
- flickr.stats.getCollectionDomains.
- flickr.stats.getCollectionStats.
- flickr.stats.getCSVFiles.
- flickr.stats.getPhotoReferrers.
- flickr.stats.getPhotoDomains.
- flickr.push.unsubscribe.
- flickr.stats.getPhotosetReferrers.
- flickr.reflection.getMethods.
- flickr.stats.getPhotosetDomains.
- flickr.stats.getPhotosetStats.
- flickr.stats.getPhotoStats.
- flickr.stats.getPhotostreamDomains.
- flickr.reflection.getMethodInfo.
- flickr.stats.getPhotostreamReferrers.
- flickr.stats.getPopularPhotos.
- flickr.tags.getClusterPhotos.
- flickr.tags.getClusters.
- flickr.stats.getTotalViews.
- flickr.tags.getListPhoto.
- flickr.tags.getHotList.
- flickr.stats.getPhotostreamStats.
- flickr.tags.getListUser.
- flickr.tags.getListUserPopular.
- flickr.tags.getMostFrequentlyUsed.
- flickr.test.echo.
- flickr.tags.getRelated.
- flickr.test.null.
- flickr.tags.getListUserRaw.
- flickr.test.login.
- flickr.urls.lookupGallery.
- flickr.urls.getUserPhotos.
- flickr.urls.getGroup.
- flickr.urls.getUserProfile.
- flickr.urls.lookupGroup.
- flickr.urls.lookupUser.
Once you have your server running and authorized, because it uses integration tests, open another terminal and just run:
npm run test
Or:
yarn run test
You will find all the tests in the tests folder. For every method its test checks:
- The status returned is OK.
- Its snapshot.
It uses Jest technology :)
This project uses grant-express & purest. Thanks to @simov for both projects.
GPL (GNU GENERAL PUBLIC LICENSE)