{"id":16036563,"url":"https://github.com/dgrtwo/stackr","last_synced_at":"2025-03-17T16:30:58.002Z","repository":{"id":26848658,"uuid":"30308379","full_name":"dgrtwo/stackr","owner":"dgrtwo","description":"R package for connecting to the Stack Exchange API","archived":false,"fork":false,"pushed_at":"2015-07-09T19:24:14.000Z","size":144,"stargazers_count":65,"open_issues_count":3,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-28T01:44:10.724Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgrtwo.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-02-04T16:25:12.000Z","updated_at":"2024-05-17T16:43:00.000Z","dependencies_parsed_at":"2022-07-25T16:30:39.475Z","dependency_job_id":null,"html_url":"https://github.com/dgrtwo/stackr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrtwo%2Fstackr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrtwo%2Fstackr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrtwo%2Fstackr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrtwo%2Fstackr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgrtwo","download_url":"https://codeload.github.com/dgrtwo/stackr/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:05:44.224Z","updated_at":"2025-03-17T16:30:57.684Z","avatar_url":"https://github.com/dgrtwo.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"stackr: an R package for connecting to the Stack Exchange API\n----------------------------\n\nThis R package serves as an unofficial wrapper for the read-only features of the [Stack Exchange API](https://api.stackexchange.com/) with the ability to download information on questions, answers, users, tags, and other aspects of the site so that they can be analyzed in R. It is *not* affiliated with Stack Exchange.\n\nThe [documentation](https://api.stackexchange.com/docs/) of the Stack Exchange API is worth reviewing, as the package is built to resemble that interface while remaining true to R's style and syntax.\n\n## Installation\n\nYou can install the package with [devtools](https://github.com/hadley/devtools) as such: \n\n```{r}\n# install.packages(\"devtools\")\ndevtools::install_github(\"dgrtwo/stackr\")\n\n# if you want to access the vignettes from within the package:\ndevtools::install_github(\"dgrtwo/stackr\", build_vignettes = TRUE)\nbrowseVignettes(\"stackr\")\n```\n\n## Basics\n\nMethods for querying objects from the APIare implemented in functions of the form `stack_[object]`. Each of these functions returns a data frame, with one row per object.\n\nFor example, one could query recent questions with:\n\n\n```r\nq \u003c- stack_questions()\n```\n\nAnd recent answers with:\n\n```r\na \u003c- stack_answers()\n```\n\nAlmost all of these functions can take as their first argument one or more IDs. For example, one could query a specific question:\n\n```r\nstack_questions(11227809)\n```\n\nOr one could query multiple answers using a vector:\n\n```r\nstack_answers(c(179147, 2219560, 180085))\n```\n\nOther results you can query include users:\n\n```r\nstack_users(712603)\n```\n\nOr tags, which are queried by name instead of id:\n\n\n```r\nstack_tags(c(\"r\", \"ggplot2\", \"dplyr\"))\n```\n\n## Returned values\n\nEach of these functions returns a `data.frame`. The columns that are included depend on the object being returned, with documentation available on the Stack Exchange API site:\n\n* [answer](https://api.stackexchange.com/docs/types/answer)\n* [badge](https://api.stackexchange.com/docs/types/badge)\n* [comment](https://api.stackexchange.com/docs/types/comment)\n* [info](https://api.stackexchange.com/docs/types/info)\n* [post](https://api.stackexchange.com/docs/types/post)\n* [privilege](https://api.stackexchange.com/docs/types/privilege)\n* [question](https://api.stackexchange.com/docs/types/question)\n* [revision](https://api.stackexchange.com/docs/types/revision)\n* [suggested-edit](https://api.stackexchange.com/docs/types/suggested-edit)\n* [tags](https://api.stackexchange.com/docs/types/tags)\n* [user](https://api.stackexchange.com/docs/types/user)\n\n## Special queries\n\nA function like `stack_questions` does not *necessarily* return questions. By providing a second argument to the query, one can extract objects that are related to that object. For example, one could extract all the answers to a particular question with:\n\n```r\nanswers \u003c- stack_questions(11227809, \"answers\")\n```\n\nSimilarly, one could extract the comments, linked questions, or related questions with:\n\n\n```r\ncomments \u003c- stack_questions(11227809, \"comments\")\nlinked \u003c- stack_questions(11227809, \"linked\")\nrelated \u003c- stack_questions(11227809, \"related\")\n```\n\nThere are many other combinations: one could extract a user's comments:\n\n\n```r\nmy_comments \u003c- stack_users(712603, \"comments\")\n```\n\nThe combinations of methods and actions is best explained in the [documentation](https://api.stackexchange.com/docs/).\n\n## Pagination\n\nYou can set the `pagesize` argument to any method to determine the number of objects to be returned. However, the maximum value of this is 100, which means multiple requests must be made to download a list larger than 100.\n\n`stackr` handles this pagination with the `num_pages` argument, which all methods accept. This gives a maximum number of pages (and therefore requests) that will be iterated through, combining them together at the end.\n\n## API Key\n\nIt's a good idea to set up a registered API key with Stack Exchange, since it increases your daily quota of queries from 300 to 10,000. You can [register an app here](http://stackapps.com/apps/oauth/register). Once you have your Stack Exchange application key, set up an environment variable, by adding the following line to your `.Rprofile`:\n\n\n```r\nSys.setenv(STACK_EXCHANGE_KEY = \"YOUR_KEY_HERE\")\n```\n\nAfter that, queries made from your system will use your key.\n\nFuture plans\n-------------------\n\nCurrently, no methods requiring authentication are implemented. OAuth 2.0 could be implemented through the same httr framework ([see here](http://cran.r-project.org/web/packages/httr/vignettes/api-packages.html)), but my current judgment is that R is likely to be used for data analysis operations rather than actual front-ends for Stack Exchange, which negates the need for most authentication-based operations.\n\nSo far, no network methods (such as \"/sites\", or \"/apps\") have yet been implemented; only per-site methods.\n\nBug reports are very welcome [here](http://github.com/dgrtwo/stackr/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgrtwo%2Fstackr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgrtwo%2Fstackr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgrtwo%2Fstackr/lists"}