{"_id":"600px","_rev":"6-82d6ebfae7e0331dfd0de296f36fad5d","name":"600px","description":"A wrapper for the 500px.com API","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"600px","description":"A wrapper for the 500px.com API","version":"0.0.1","keywords":["api","500px"],"repository":{"type":"git","url":"git://github.com/jenius/node-500px.git"},"main":"lib","scripts":{"test":"npm run lint && mocha","lint":"find lib/ -name '*.coffee' | xargs coffeelint","coverage":"make build; istanbul cover _mocha --report html -- -R spec && open coverage/index.html && make unbuild"},"devDependencies":{"chai":"1.x","chai-as-promised":"4.x","coffee-script":"1.9.x","coffeelint":"1.x","istanbul":"0.3.x","mocha-lcov-reporter":"0.0.1","mocha":"1.x"},"dependencies":{"node-uuid":"1.x","purest":"1.x","when":"3.x"},"gitHead":"323b1f8bcba92293894b635e3826923bca3dbe12","bugs":{"url":"https://github.com/jenius/node-500px/issues"},"homepage":"https://github.com/jenius/node-500px","_id":"600px@0.0.1","_shasum":"62c80c122d182cc05522c14d12d82024c16393a0","_from":".","_npmVersion":"2.4.1","_nodeVersion":"0.10.36","_npmUser":{"name":"jenius","email":"hello@jenius.me"},"maintainers":[{"name":"jenius","email":"hello@jenius.me"}],"dist":{"shasum":"62c80c122d182cc05522c14d12d82024c16393a0","tarball":"https://registry.npmjs.org/600px/-/600px-0.0.1.tgz","integrity":"sha512-BMgQsfcC4aIoKhIGELPsEy++Rcvb6O4j9byxW0YZvgYDBPN2lTAoe1uu2KlfFPw8SSS965uaHN5FFZ1UogGFFQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGmgjvJUI6qyOn9SAOyyBcJq+ASZMI3P01pTzcod0xmsAiEAyxqHqOKOFPn2Z+PDFWPdKvMHHRzOtnhy7djJ5TvCHfs="}]}}},"readme":"600px\n=====\n\n[![npm](http://img.shields.io/npm/v/600px.svg?style=flat)](https://badge.fury.io/js/600px) [![dependencies](http://img.shields.io/gemnasium/jenius/600px.svg?style=flat)](https://gemnasium.com/jenius/600px)\n<!-- Need some auth wizardry to get these on travis -->\n<!-- [![tests](http://img.shields.io/travis/jenius/600px/master.svg?style=flat)](https://travis-ci.org/jenius/600px) [![Coverage Status](https://img.shields.io/coveralls/jenius/600px.svg?style=flat)](https://coveralls.io/r/jenius/600px?branch=master) -->\n\nA [500px.com](http://500px.com) wrapper that does a little more than the existing `500px` node module :wink:. Wraps the [500px API](http://developer.500px.com/), exposing a clean, well-tested, promise-based interface with support for authenticated requests.\n\n### Installation\n\n```sh\n$ npm install 600px\n```\n\n### Usage\n\nRequire it into your project as usual. The main module is a class that requires a configuration object to be correctly initialized. You need a `consumer_key` for the public methods, and a bit more information for the authenticated methods, which we'll talk about in the next section.\n\n```js\nvar API = require('600px'),\n    api = new API({ consumer_key: 'xxx' });\n```\n\nNow you have an object available for each API endpoint, as such:\n\n```js\nvar Photos = api.photos;\nvar Users = api.users;\nvar Blogs = api.blogs;\nvar Collections = api.collections;\n```\n\nThere are a number of methods to make specific API requests on each of these endpoints, documented below. At the moment, only `GET` methods are supported, although I plan on adding support for `POST` and `PUT` methods down the line as well, and the architecture is in place for it.\n\n### Authorization\n\nThis library is intended for personal use and therefore does not include a full authorization flow. If you do need to authorize, it has to happen in the browser through OAuth, and you can use the officially maintained [500px client-side js library](https://github.com/500px/500px-js-sdk) for this.\n\nUnfortunately, 500px offers no way for you to easily obtain a personal access token, so you need to go through the whole OAuth thing and make a dummy app in order to get the info you need to make authenticated requests. Here are a set of steps you can take to get personal access tokens fairly painlessly:\n\n- Make a [new 500px application](https://500px.com/settings/applications), make sure to set the callback url to `https://grant-oauth.herokuapp.com/connect/500px/callback`.\n- Head over to the wonderful [grant oauth playground](https://grant-oauth.herokuapp.com/#500px), check the `app` box, and enter in your application's consumer key and secret which you just generated\n- Go through the oauth flow. At the end, you will be redirected to grant's playground where you will get a access token and access secret.\n- In order to make authenticated calls, you need a `consumer_key`, `consumer_secret`, `token`, and `token_secret`, which you now have all of. Initialize this library's class with those four, named appropriately, and you will be able to make authenticated calls.\n\nWith this done, you can hit any endpoint without errors. Without this in place, the endpoints that indicate that they require OAuth in [500px's API docs](https://github.com/500px/api-documentation) will return an error.\n\n### Photos\n\nTo retrieve photos, use `photos` on the instantiated class with any of the methods listed below. A brief example:\n\n```javascript\napi.photos.getPopular({'sort': 'created_at', 'rpp': '100'})\n  .catch(console.error)\n  .then(console.log);\n```\n\nNote that each method returns a A+ compliant promise generated by [when.js](https://github.com/cujojs/when). If you don't know how to use promises, don't worry at all, the basics are super easy. You can just follow the example as above: use `then` to execute a function on success and `catch` on error. Below are all the photo-related functions you can use:\n\n* `getById (photo_id, arguments)`\n* `getByUsername (username, arguments)`\n* `getByUserId (user_id, arguments)`\n* `getFavoritesByUsername (username, arguments)`\n* `getFavoritesByUserId (user_id, arguments)`\n* `getFriendsByUsername (username, arguments)`\n* `getFriendsByUserId (user_id, arguments)`\n* `getPopular (arguments)`\n* `getUpcoming (arguments)`\n* `getEditorsChoice (arguments)`\n* `getFreshToday (arguments)`\n* `getFreshYesterday (arguments)`\n* `getFreshWeek (arguments)`\n* `searchByTag (tag, arguments)`\n* `searchByTerm (term, arguments)`\n\nFor more information on the possible arguments, please check the [500px.com photos API](http://developer.500px.com/docs/photos-index)\n\n### Users\n\nExample:\n\n```javascript\napi.users.getById(1234)\n  .catch(console.error)\n  .then(console.log);\n```\n\nAvailable functions:\n\n* `get (arguments)`\n* `getById (id, arguments)`\n* `getByName (username, arguments)`\n* `getByEmail (email, arguments)`\n* `getFriendsById (id, arguments)`\n\nFor more information on the possible arguments, please check the [500px.com users API](http://developer.500px.com/docs/users-index)\n\n### Blogs\n\nExample:\n\n```javascript\napi.blogs.getFresh()\n  .catch(console.error)\n  .then(console.log);\n```\n\nFunctions:\n\n* `getById (id, arguments)`\n* `getCommentsById (id, arguments)`\n* `getFresh (arguments)`\n* `getByUsername (username, arguments)`\n* `getByUserId (user_id, arguments)`\n\nFor more information on the possible arguments, please check the [500px.com blogs API](http://developer.500px.com/docs/blogs-index)\n\n### Collections\n\nNote that all collections endpoints require full authentication credentials.\n\nExample:\n\n```javascript\napi.collections.get()\n  .catch(console.error)\n  .then(console.log);\n```\n\nFunctions:\n\n* `get (arguments)`\n* `getById (id, arguments)`\n\nFor more information on the possible arguments, please check the [500px.com collections API](http://developer.500px.com/docs/collections-index)\n\n### License\n\nLicensed under MIT ([see license »](LICENSE))\n","maintainers":[{"name":"jescalan","email":"npm.je@mailhero.io"}],"time":{"modified":"2022-06-12T14:08:16.398Z","created":"2015-02-04T03:26:46.898Z","0.0.1":"2015-02-04T03:26:46.898Z"},"homepage":"https://github.com/jenius/node-500px","keywords":["api","500px"],"repository":{"type":"git","url":"git://github.com/jenius/node-500px.git"},"bugs":{"url":"https://github.com/jenius/node-500px/issues"},"readmeFilename":"README.md"}