{"id":16037289,"url":"https://github.com/stevenroose/dart-reddit","last_synced_at":"2025-07-20T08:36:12.187Z","repository":{"id":29652284,"uuid":"33193982","full_name":"stevenroose/dart-reddit","owner":"stevenroose","description":"A Reddit library for Dart. Not well-maintained, check out draw as well: https://pub.dev/packages/draw","archived":false,"fork":false,"pushed_at":"2019-02-21T09:42:29.000Z","size":39,"stargazers_count":29,"open_issues_count":6,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T01:45:18.086Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stevenroose.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-31T15:42:38.000Z","updated_at":"2025-01-27T02:25:55.000Z","dependencies_parsed_at":"2022-09-12T11:20:16.299Z","dependency_job_id":null,"html_url":"https://github.com/stevenroose/dart-reddit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenroose%2Fdart-reddit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenroose%2Fdart-reddit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenroose%2Fdart-reddit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevenroose%2Fdart-reddit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevenroose","download_url":"https://codeload.github.com/stevenroose/dart-reddit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243871644,"owners_count":20361378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T22:12:07.013Z","updated_at":"2025-03-17T16:31:05.150Z","avatar_url":"https://github.com/stevenroose.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dart-reddit\n\nA Reddit library for Dart, inspired by reddit.js (API) and raw.js (Auth).\n\n## Documentation\n\nSee the [Dart documentation](http://www.dartdocs.org/documentation/reddit/latest/).\n\n## Usage\n\nAdd the following to your `pubspec.yaml`:\n\n```yaml\ndependencies:\n  reddit: any\n```\n\n### Creating a client\n\nThe top class `Reddit` takes a `Client` as parameter.\nThis client can be constructed using the[`http`](https://pub.dartlang.org/packages/http) package.\n\n```dart\n// in Dart VM\nReddit reddit = new Reddit(new Client());\n// in browser\nReddit reddit = new Reddit(new BrowserClient());\n```\n\n### OAuth\n\nOAuth is required for all endpoints. To enable OAuth, you will need an app identifier and a secret. Get them [here](https://www.reddit.com/prefs/apps).\n\nThere are two options: App-only and User authorization.\n\n - App-only auth\n\n```dart\nreddit.authSetup(identifier, secret);\n// with user info\nawait reddit.authFinish(username: \"sroose\", password: \"correct horse battery staple\");\n// or without\nawait reddit.authFinish();\n```\n\nNote that not providing (developer) user info will result in getting 503 Service Unavailable responses after a while.\n\n - User-enabled auth\n\n```dart\nreddit.authSetup(identifier, secret);\nUri authUrl = reddit.authUrl(\"https://myapp.com/auth_redirect\");\n// redirect user to authUrl and gather the response from the auth server\nawait reddit.authFinish(response: authServerResponse);\n// or if you already extracted the auth code from the response\nawait reddit.authFinish(code: authCode);\n```\n\n\n### Queries, filters and listings\n\nMost methods in the API construct a `Query`, which can be fetched to get a future with the results.\n\nMost queries allow filtering. For the supported filters, we refer to the [Reddit API docs](https://www.reddit.com/dev/api/oauth#scope_read) or the [documentation for this library](#documentation).\n\n```dart\n// without filters\nreddit.frontPage.newPosts().fetch().then(print);\n// filtered\nreddit.frontPage.hot().limit(10).fetch().then(print);\n```\n\nA lot of queries also are [listings](https://www.reddit.com/dev/api/oauth#listings).\nListings allow for browsing through content across multiple queries.\n\n```dart\n// using the regular fetch() method (not recommended)\nreddit.sub(\"dartlang\").top(\"day\").fetch().then((result) {\n  print(result);\n  if (notEnough) {\n    result.fetchMore().then((result) {\n      print(result);\n      if (stillNotEnough) {\n        result.fetchmore().then(print);\n      }\n    });\n  }\n});\n\n// or using the dart:async API\nreddit.sub(\"dartlang\").top(\"month\").listen((result) {\n  print(result);\n  if (notEnough) {\n    result.fetchMore();\n  }\n})\n```\n\n\n### Browsing Reddit\n\nYou can use the standard read-only API to browse Reddit.\n\n```dart\n// the front page\nreddit.front.hot().fetch().then(print);\n// or subreddits\nreddit.sub(\"dartlang\").hot().fetch().then(print);\n```\n\nSome examples using filters:\n\n```dart\nreddit.sub(\"dartlang\").top().t(\"day\").limit(10).fetch().then(print);\n```\n\n### Comments\n\nFetching comments for a link:\n\n```dart\nreddit.sub(\"dartlang\").comments(\"2ek93l\").depth(3).fetch().then(print);\n```\n\nOr a single comment:\n\n```dart\nreddit.sub(\"dartlang\").comments(\"2ek93l\").comment(\"ck0mkcy\").context(2).fetch().then(print);\n```\n\n### Search\n\nSearch through reddit:\n\n```dart\nreddit.sub(\"dartlang\").search(\"reddit api\").limit(5).sort(\"hot\").fetch().then(print);\n```\n\n### Subreddits\n\nFind subreddits:\n\n```dart\nreddit.newSubreddits().fetch().then(print);\n\nreddit.popularSubreddits().fetch().then(print);\n\nreddit.recommendedSubreddits([\"dartlang\", \"reddit\"]).fetch().then(print);\n\nreddit.subredditsByTopic(\"programming\").fetch().then(print);\n```\n\nGet information about a subreddit:\n\n```dart\nreddit.sub(\"dartlang\").about().fetch().then(print);\n```\n\n### Users\n\nGet information about a user:\n\n```dart\nreddit.user(\"sroose\").about().fetch().then(print);\n```\n\nGet listings from users:\n\n```dart\nreddit.user(\"sroose\").comments(\"month\").listen(print);\n\nreddit.user(\"sroose\").submitted(\"week\").sort(\"hot\").listen(print);\n```\n\nGet a list of multi's from a user:\n```dart\nreddit.user(\"sroose\").multis().fetch().then(print);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenroose%2Fdart-reddit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevenroose%2Fdart-reddit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevenroose%2Fdart-reddit/lists"}