{"id":15008672,"url":"https://github.com/draw-dev/draw","last_synced_at":"2025-09-08T19:34:25.363Z","repository":{"id":46977155,"uuid":"89817717","full_name":"draw-dev/DRAW","owner":"draw-dev","description":"DRAW: The Dart Reddit API Wrapper","archived":false,"fork":false,"pushed_at":"2023-03-13T14:45:53.000Z","size":2499,"stargazers_count":86,"open_issues_count":20,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-08T21:41:56.424Z","etag":null,"topics":["dart","dartlang","draw","flutter","flutter-apps","pub","reddit-api"],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/draw-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS"}},"created_at":"2017-04-29T23:04:07.000Z","updated_at":"2025-05-25T11:55:52.000Z","dependencies_parsed_at":"2024-01-15T15:14:02.183Z","dependency_job_id":"4aedbd30-21e5-426f-9d62-f2079226f8a3","html_url":"https://github.com/draw-dev/DRAW","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/draw-dev/DRAW","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/draw-dev%2FDRAW","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/draw-dev%2FDRAW/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/draw-dev%2FDRAW/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/draw-dev%2FDRAW/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/draw-dev","download_url":"https://codeload.github.com/draw-dev/DRAW/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/draw-dev%2FDRAW/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274231435,"owners_count":25245585,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dart","dartlang","draw","flutter","flutter-apps","pub","reddit-api"],"created_at":"2024-09-24T19:19:58.345Z","updated_at":"2025-09-08T19:34:25.339Z","avatar_url":"https://github.com/draw-dev.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"DRAW: The Dart Reddit API Wrapper\n=================================\n\n[![Build Status](https://api.travis-ci.com/draw-dev/DRAW.svg?branch=master)](https://app.travis-ci.com/github/draw-dev/DRAW) [![Pub Version](https://img.shields.io/pub/v/draw.svg)](https://pub.dartlang.org/packages/draw) [![Coverage Status](https://coveralls.io/repos/github/draw-dev/DRAW/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/draw-dev/DRAW?branch=master\u0026service=github)\n\nDRAW, also known as the Dart Reddit API Wrapper, is a Dart package that\nprovides simple access to the Reddit API. DRAW is inspired by\n[PRAW](https://github.com/praw-dev/praw), the Python Reddit API Wrapper, and\naims to also maintain a similar interface.\n \nWant to get involved? Check out [how to contribute](https://github.com/draw-dev/DRAW/blob/master/CONTRIBUTING.md) to get started!\n\nDisclaimer: This is not an official Google product.\n\n# Installation\nInstalling DRAW is simple using Dart's package management system, [pub](https://pub.dartlang.org). Instructions on how to import DRAW into your project can be found [here](https://pub.dartlang.org/packages/draw#-installing-tab-). If you would prefer to live on the hemorrhaging-edge, methods to depend on a local copy of DRAW or on the Github repository can be found [here](https://www.dartlang.org/tools/pub/dependencies).\n\n# Getting Started\nAssuming you already have your [Reddit OAuth credentials](https://github.com/reddit/reddit/wiki/OAuth2), getting started with DRAW is simple:\n\n```dart\nimport 'dart:async';\nimport 'package:draw/draw.dart';\n\nFuture\u003cvoid\u003e main() async {\n  // Create the `Reddit` instance and authenticated\n  Reddit reddit = await Reddit.createScriptInstance(\n    clientId: CLIENT_ID,\n    clientSecret: SECRET,\n    userAgent: AGENT_NAME,\n    username: \"DRAWApiOfficial\",\n    password: \"hunter12\", // Fake\n  );\n\n  // Retrieve information for the currently authenticated user\n  Redditor currentUser = await reddit.user.me();\n  // Outputs: My name is DRAWApiOfficial\n  print(\"My name is ${currentUser.displayName}\");\n}\n```\n\nThis simple example is a great way to confirm that DRAW is working and that your credentials have been configured correctly.\n\n# Web Authentication\nTo authenticate via the Reddit authentication page, the web authentication flow needs to be used. This requires that a web application is registered with a valid Reddit account, which provides a `client-id` and a `client-secret`. As part of this process, a `redirect URL` is associated with the registered web application. These three values are all that is needed to complete the web authentication flow.\n\nHere is a simple example of how to use web authentication with DRAW:\n\n```dart\nimport 'package:draw/draw.dart';\n\nmain() async {\n  final userAgent = 'foobar';\n  final configUri = Uri.parse('draw.ini');\n\n  // Create a `Reddit` instance using a configuration file in the\n  // current directory.\n  final reddit = Reddit.createWebFlowInstance(userAgent: userAgent,\n                                              configUri: configUri);\n\n  // Build the URL used for authentication. See `WebAuthenticator`\n  // documentation for parameters.\n  final auth_url = reddit.auth.url(['*'], 'foobar');\n\n  // ...\n  // Complete authentication at `auth_url` in the browser and retrieve\n  // the `code` query parameter from the redirect URL.\n  // ...\n\n  // Assuming the `code` query parameter is stored in a variable\n  // `auth_code`, we pass it to the `authorize` method in the\n  // `WebAuthenticator`.\n  await reddit.auth.authorize(auth_code);\n\n  // If everything worked correctly, we should be able to retrieve\n  // information about the authenticated account.\n  print(await reddit.user.me());\n}\n```\n\nIt is also possible to restore cached credentials in order to avoid the need to complete the web authentication flow on each run:\n\n```dart\nimport 'package:draw/draw.dart';\n\n// Provides methods to load and save credentials.\nimport 'credential_loader.dart';\n\nmain() async {\n  final userAgent = 'foobar';\n  final configUri = Uri.parse('draw.ini');\n\n  // Load cached credentials from disk, if available.\n  final credentialsJson = await loadCredentials();\n\n  var reddit;\n\n  if (credentialsJson == null) {\n    reddit =\n        await Reddit.createWebFlowInstance(userAgent: userAgent,\n                                           configUri: configUri);\n\n    // Build the URL used for authentication. See `WebAuthenticator`\n    // documentation for parameters.\n    final auth_url = reddit.auth.url(['*'], 'foobar');\n\n    // ...\n    // Complete authentication at `auth_url` in the browser and retrieve\n    // the `code` query parameter from the redirect URL.\n    // ...\n\n    // Assuming the `code` query parameter is stored in a variable\n    // `auth_code`, we pass it to the `authorize` method in the\n    // `WebAuthenticator`.\n    await reddit.auth.authorize(auth_code);\n\n    // Write credentials to disk.\n    await writeCredentials(reddit.auth.credentials.toJson());\n  } else {\n    // Create a new Reddit instance using previously cached credentials.\n    reddit = Reddit.restoreAuthenticatedInstance(\n        userAgent: userAgent,\n        configUri: configUri,\n        credentialsJson: credentialsJson);\n  }\n\n  // If everything worked correctly, we should be able to retrieve\n  // information about the authenticated account.\n  print(await reddit.user.me());\n}\n```\n# Installed Application Authentication\n\nFor usage in environments where it is impossible to keep a client secret secure, the installed application flow should be used. This requires that an installed application is registered with a valid Reddit account, which provides a `client-id`. As part of this process, a `redirect URL` is associated with the registered installed application. These two values are all that is needed to complete the installed application authentication flow.\n\nThe installed application authentication flow is almost identical to the web authentication flow described above, and it is also possible to save and restore credentials for installed applications in a similar fashion.\n\nRead up more about how to use this authentication flow on [here](https://github.com/draw-dev/DRAW/issues/196#issuecomment-891084560).\n\nHere is a simple example of how to use the installed application authentication flow with DRAW:\n\n```dart\nimport 'package:draw/draw.dart';\n\nmain() async {\n  final userAgent = 'foobar';\n  final configUri = Uri.parse('draw.ini');\n\n  // Create a `Reddit` instance using a configuration file in the current\n  // directory. Unlike the web authentication example, a client secret does\n  // not need to be provided in the configuration file.\n  final reddit = Reddit.createInstalledFlowInstance(userAgent: userAgent,\n                                                    configUri: configUri);\n\n  // Build the URL used for authentication. See `WebAuthenticator`\n  // documentation for parameters.\n  final auth_url = reddit.auth.url(['*'], 'foobar');\n\n  // ...\n  // Complete authentication at `auth_url` in the browser and retrieve\n  // the `code` query parameter from the redirect URL.\n  // ...\n\n  // Assuming the `code` query parameter is stored in a variable\n  // `auth_code`, we pass it to the `authorize` method in the\n  // `WebAuthenticator`.\n  await reddit.auth.authorize(auth_code);\n\n  // If everything worked correctly, we should be able to retrieve\n  // information about the authenticated account.\n  print(await reddit.user.me());\n}\n```\n\n# DRAW Configuration Files (draw.ini)\n\nHere's an example `draw.ini` suitable for web based authentication:\n\n```ini\ndefault=default\nreddit_url='https://www.reddit.com'\noauth_url=https://oauth.reddit.com\nredirect_uri=https://www.google.com\nclient_id=YOUR_CLIENT_ID_HERE\nclient_secret=YOUR_SECRET_HERE\nuserAgent=draw_testing_agent\n```\n\nHere the redirect URI is set to https://www.google.com, but you'll need to replace that with whatever redirect you have registered.\n\nThe format of `draw.ini` configuration files is very similar to that of [praw.ini files used by PRAW](http://praw.readthedocs.io/en/latest/getting_started/configuration/prawini.html), although there may be some minor differences due to the .ini parser used by DRAW.\n\n# Frequently Asked Questions (FAQ)\n\n## Q: \"I'm having trouble authenticating. What's wrong?\"\n\nAssuming the build status of DRAW is passing, there's likely something wrong\nwith your credentials or user-agent. Here's some things to check:\n\n* Ensure your client ID and client secret match those provided by Reddit,\n  applicable for your use case.\n* Try a new value for `userAgent`. Reddit rejects requests with commonly used\n  user-agents like \"foobar\", \"testing\", or \"reddit\", so try using a randomly\n  generated user-agent to make sure this isn't the issue you're seeing.\n\n# License\nDRAW is provided under a [BSD 3-clause license](https://github.com/draw-dev/DRAW/blob/master/LICENSE). Copyright (c), 2017, the DRAW Project Authors and Google LLC.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdraw-dev%2Fdraw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdraw-dev%2Fdraw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdraw-dev%2Fdraw/lists"}