{"_id":"550ada9e921b7d0d0022887f","__v":12,"user":"550a378e635c660d00527fd7","version":{"_id":"550ada9d921b7d0d00228876","forked_from":"550a3b2542fff40d00ae5ffb","project":"550a379f635c660d00527fd8","__v":3,"createdAt":"2015-03-19T14:18:05.245Z","releaseDate":"2015-03-19T14:18:05.245Z","categories":["550ada9d921b7d0d00228877","550ada9d921b7d0d00228878","550ada9d921b7d0d00228879","550ada9d921b7d0d0022887a","550ada9d921b7d0d0022887b","550ada9d921b7d0d0022887c","550ada9d921b7d0d0022887d","5523e61e71c0542100993493","55246f72ccc28a0d0062c560"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"3.0.0","version":"3.0.0"},"category":{"_id":"550ada9d921b7d0d0022887a","__v":2,"project":"550a379f635c660d00527fd8","version":"550ada9d921b7d0d00228876","pages":["550ada9e921b7d0d0022887f","550ada9e921b7d0d00228880","550ada9e921b7d0d00228881","5526826eb87cef230047be0e"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-03-19T02:55:05.573Z","from_sync":false,"order":4,"slug":"helpers-extras","title":"Helpers & Extras"},"project":"550a379f635c660d00527fd8","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-03-19T02:55:16.719Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"From the reddit documentation:\n\n> Many endpoints on reddit use the same protocol for controlling pagination and filtering. These endpoints are called Listings and share five common parameters: after / before, limit, count, and show.\n\nAlong side the basic HTTP verbs to call the reddit API (See [Basic Usage](doc:basic-usage)), there is a `.listing` helper for endpoints that return listings.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Example Usage\"\n}\n[/block]\nUsing the listing endpoint [`GET [/r/subreddit]/hot` (link)](http://www.reddit.com/dev/api#GET_hot):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"reddit('/hot').listing({ \\n  // Any parameters for the endpoints can be used here as usual.\\n  // In this case, we specify a limit of 10 children per slice\\n  limit: 10\\n}).then(function(slice) {\\n  console.log(slice.children); // The children that are not stickied\\n  console.log(slice.stickied); // The children that are stickied\\n\\n  console.log(slice.before); // null\\n  console.log(slice.after); // String - fullname anchor\\n\\n  console.log(slice.count); // will be 0 (see below)\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\nTo get the next or previous slices in a listing, call `next()` or `previous()` on the current slice:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"reddit('/r/hot').listing({ limit: 10 }).then(function(slice) {\\n  console.log(slice.children);\\n  console.log(slice.count); // 0\\n\\treturn slice.next();\\n}).then(function(slice) { // the next slice\\n\\tconsole.log(slice.children);\\n\\tconsole.log(slice.count); // 10\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nFor full working examples checkout the [examples on GitHub](https://github.com/trevorsenior/snoocore-examples/tree/master).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Slice Attributes\"\n}\n[/block]\n### `slice.children`\n\nThe children in a slice.\n\n### `slice.stickied`\n\nThe stickied children in this slice. This will usually only be populated in the first slice in a listing (e.g. a listing for a subreddit)\n\n### `slice.allChildren`\n\nGives back a list of the stickied children and the non-stickied children (does not separate them out).\n\n### `slice.empty`\n\nBoolean determining if a slice returned no results. The value is true when `slice.allChildren` is empty and false otherwise. Useful for determining the end of a listing.\n\n### `slice.count`\n\nThe count of the number of children that have loaded for this slice. If the listing limit is 25 (the default), the first slice will have a count of `0`, the next slice will have a count of `25` and so on. `slice.count` does _not_ take into consideration stickied children.\n\n### `slice.before`\n\nThe `before` fullname.\n\n### `slice.after`\n\nThe `after` fullname. \n\n### `slice.get`\n\nShould rarely be needed. This is the raw API response from reddit (as if you called `.get` instead of `.listing`) for this slice.\n\n## Slice functions\n\n### `slice.next()`\n\nGet a promise for the next slice in a listing.\n\n### `slice.previous()` \n\nGet a promise for the previous slice in a listing.\n\n### `slice.start()`\n\nGet a promise for the first slice in a listing. Useful for going back to the beginning of a listing.\n\n### `slice.requery()`\n\nGet a promise for the same slice. Useful if you've modified (removed, edited, etc.) some content from a listing and need to requery for the slice of data.\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Multiple Listings\"\n}\n[/block]\nSome endpoints return multiple listings. Use the [Call Context Option](doc:call-context-options) `listingIndex` to specify which listing to actually use in the returned result:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"reddit('duplicates/$article').listing({ \\n  limit: 100, \\n  $article: '13wml3'\\n}, { listingIndex: 1 }).then(function(slice) {\\n\\t// slice is frome the second listing in the given array \\n  // from the duplicates endpoint.\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"listings","type":"basic","title":"Listings"}
From the reddit documentation: > Many endpoints on reddit use the same protocol for controlling pagination and filtering. These endpoints are called Listings and share five common parameters: after / before, limit, count, and show. Along side the basic HTTP verbs to call the reddit API (See [Basic Usage](doc:basic-usage)), there is a `.listing` helper for endpoints that return listings. [block:api-header] { "type": "basic", "title": "Example Usage" } [/block] Using the listing endpoint [`GET [/r/subreddit]/hot` (link)](http://www.reddit.com/dev/api#GET_hot): [block:code] { "codes": [ { "code": "reddit('/hot').listing({ \n // Any parameters for the endpoints can be used here as usual.\n // In this case, we specify a limit of 10 children per slice\n limit: 10\n}).then(function(slice) {\n console.log(slice.children); // The children that are not stickied\n console.log(slice.stickied); // The children that are stickied\n\n console.log(slice.before); // null\n console.log(slice.after); // String - fullname anchor\n\n console.log(slice.count); // will be 0 (see below)\n});", "language": "javascript" } ] } [/block] To get the next or previous slices in a listing, call `next()` or `previous()` on the current slice: [block:code] { "codes": [ { "code": "reddit('/r/hot').listing({ limit: 10 }).then(function(slice) {\n console.log(slice.children);\n console.log(slice.count); // 0\n\treturn slice.next();\n}).then(function(slice) { // the next slice\n\tconsole.log(slice.children);\n\tconsole.log(slice.count); // 10\n});", "language": "javascript" } ] } [/block] For full working examples checkout the [examples on GitHub](https://github.com/trevorsenior/snoocore-examples/tree/master). [block:api-header] { "type": "basic", "title": "Slice Attributes" } [/block] ### `slice.children` The children in a slice. ### `slice.stickied` The stickied children in this slice. This will usually only be populated in the first slice in a listing (e.g. a listing for a subreddit) ### `slice.allChildren` Gives back a list of the stickied children and the non-stickied children (does not separate them out). ### `slice.empty` Boolean determining if a slice returned no results. The value is true when `slice.allChildren` is empty and false otherwise. Useful for determining the end of a listing. ### `slice.count` The count of the number of children that have loaded for this slice. If the listing limit is 25 (the default), the first slice will have a count of `0`, the next slice will have a count of `25` and so on. `slice.count` does _not_ take into consideration stickied children. ### `slice.before` The `before` fullname. ### `slice.after` The `after` fullname. ### `slice.get` Should rarely be needed. This is the raw API response from reddit (as if you called `.get` instead of `.listing`) for this slice. ## Slice functions ### `slice.next()` Get a promise for the next slice in a listing. ### `slice.previous()` Get a promise for the previous slice in a listing. ### `slice.start()` Get a promise for the first slice in a listing. Useful for going back to the beginning of a listing. ### `slice.requery()` Get a promise for the same slice. Useful if you've modified (removed, edited, etc.) some content from a listing and need to requery for the slice of data. [block:api-header] { "type": "basic", "title": "Multiple Listings" } [/block] Some endpoints return multiple listings. Use the [Call Context Option](doc:call-context-options) `listingIndex` to specify which listing to actually use in the returned result: [block:code] { "codes": [ { "code": "reddit('duplicates/$article').listing({ \n limit: 100, \n $article: '13wml3'\n}, { listingIndex: 1 }).then(function(slice) {\n\t// slice is frome the second listing in the given array \n // from the duplicates endpoint.\n});", "language": "javascript" } ] } [/block]