{"id":13401381,"url":"https://github.com/sckott/request","last_synced_at":"2025-10-09T11:11:44.485Z","repository":{"id":28009187,"uuid":"31503745","full_name":"sckott/request","owner":"sckott","description":"http requests DSL for R","archived":false,"fork":false,"pushed_at":"2020-06-16T19:07:06.000Z","size":161,"stargazers_count":36,"open_issues_count":11,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-09-23T15:51:44.099Z","etag":null,"topics":["api","curl","curl-library","http","r","r-stats"],"latest_commit_sha":null,"homepage":"","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/sckott.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-01T17:17:20.000Z","updated_at":"2022-03-23T20:47:15.000Z","dependencies_parsed_at":"2022-09-02T09:28:42.210Z","dependency_job_id":null,"html_url":"https://github.com/sckott/request","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sckott/request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sckott%2Frequest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sckott%2Frequest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sckott%2Frequest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sckott%2Frequest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sckott","download_url":"https://codeload.github.com/sckott/request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sckott%2Frequest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001290,"owners_count":26083058,"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-10-09T02:00:07.460Z","response_time":59,"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":["api","curl","curl-library","http","r","r-stats"],"created_at":"2024-07-30T19:01:02.123Z","updated_at":"2025-10-09T11:11:44.469Z","avatar_url":"https://github.com/sckott.png","language":"R","readme":"request\n=======\n\n```{r echo=FALSE}\nhook_output \u003c- knitr::knit_hooks$get(\"output\")\nknitr::knit_hooks$set(output = function(x, options) {\n   lines \u003c- options$output.lines\n   if (is.null(lines)) {\n     return(hook_output(x, options))  # pass to default hook\n   }\n   x \u003c- unlist(strsplit(x, \"\\n\"))\n   more \u003c- \"...\"\n   if (length(lines) == 1) {        # first n lines\n     if (length(x) \u003e lines) {\n       # truncate the output, but add ....\n       x \u003c- c(head(x, lines), more)\n     }\n   } else {\n     x \u003c- c(if (abs(lines[1])\u003e1) more else NULL,\n            x[lines],\n            if (length(x)\u003elines[abs(length(lines))]) more else NULL\n           )\n   }\n   # paste these lines together\n   x \u003c- paste(c(x, \"\"), collapse = \"\\n\")\n   hook_output(x, options)\n })\n\nknitr::opts_chunk$set(\n  warning = FALSE,\n  message = FALSE,\n  collapse = TRUE,\n  comment = \"#\u003e\"\n)\n```\n\n[![cran checks](https://cranchecks.info/badges/worst/request)](https://cranchecks.info/pkgs/request)\n[![Build Status](https://travis-ci.org/sckott/request.svg)](https://travis-ci.org/sckott/request)\n[![codecov.io](https://codecov.io/github/sckott/request/coverage.svg?branch=master)](https://codecov.io/github/sckott/request?branch=master)\n[![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/request?color=F3B1FF)](https://github.com/metacran/cranlogs.app)\n[![cran version](http://www.r-pkg.org/badges/version/request)](https://cran.r-project.org/package=request)\n\n`request` is DSL for http requests for R, and is inspired by the CLI tool [httpie](https://github.com/jakubroztocil/httpie).\n\n`request` is built on `httr`, though may allow using the R packages `RCurl` or `curl` as optional backends at some point.\n\nI gave a poster at User2016, its in my [talks repo](https://github.com/sckott/talks/blob/gh-pages/user2016/request.pdf)\n\n## Philosophy\n\n* The web is increasingly a JSON world, so we assume `applications/json` by default, but give back other types if not\n* The workflow follows logically, or at least should, from, _hey, I got this url_, to _i need to add some options_, to _execute request_\n* Whenever possible, we transform output to data.frame's - facilitating downstream manipulation via `dplyr`, etc.\n* We do `GET` requests by default. Specify a different type if you don't want `GET`\n* You can use non-standard evaluation to easily pass in query parameters without worrying about `\u0026`'s, URL escaping, etc. (see `api_query()`)\n* Same for body params (see `api_body()`)\n\nAll of the defaults just mentioned can be changed.\n\n## Auto execute http requests with pipes\n\nWhen using pipes, we autodetect that a pipe is being used within the function calls, and automatically do the appropriate http request on the last piped function call. When you call a function without using pipes, you have to use the `http()` function explicitly to make the http request.\n\n## low level http\n\nLow level access is available with `http_client()`, which returns an `R6` class with various methods for inspecting http request results.\n\n## Peek at a request\n\nThe function `peep()` let's you peek at a request without performing the http request.\n\n## Install\n\nFrom CRAN\n\n```{r eval=FALSE}\ninstall.packages(\"request\")\n```\n\nDevelopment version from GitHub\n\n```{r eval=FALSE}\nremotes::install_github(\"sckott/request\")\n```\n\n```{r}\nlibrary(\"request\")\n```\n\n## NSE and SE\n\nNSE is supported\n\n```{r eval=FALSE}\napi('https://api.github.com/') %\u003e%\n  api_path(repos, ropensci, rgbif, issues)\n```\n\nas well as SE\n\n```{r eval=FALSE}\napi('https://api.github.com/') %\u003e%\n  api_path_('repos', 'ropensci', 'rgbif', 'issues')\n```\n\n## Building API routes\n\nWorks with full or partial URLs\n\n```{r}\napi('https://api.github.com/')\napi('http://api.gbif.org/v1')\napi('api.gbif.org/v1')\n```\n\nWorks with ports, full or partial\n\n```{r}\napi('http://localhost:9200')\napi('localhost:9200')\napi(':9200')\napi('9200')\napi('9200/stuff')\n```\n\n## Make HTTP requests\n\nThe above examples with `api()` are not passed through a pipe, so only define a URL, but don't do an HTTP request. To make an HTTP request, you can either pipe a url or partial url to e.g., `api()`, or call `http()` at the end of a string of function calls:\n\n```{r output.lines = 1:10}\n'https://api.github.com/' %\u003e% api()\n```\n\nOr\n\n```{r output.lines = 1:10}\napi('https://api.github.com/') %\u003e% http()\n```\n\n`http()` is called at the end of a chain of piped commands, so no need to invoke it. However, you can if you like.\n\n## Templating\n\n```{r}\nrepo_info \u003c- list(username = 'craigcitro', repo = 'r-travis')\napi('https://api.github.com/') %\u003e%\n  api_template(template = 'repos/{{username}}/{{repo}}/issues', data = repo_info) %\u003e%\n  peep\n```\n\n## Set paths\n\n`api_path()` adds paths to the base URL (see `api_query()`) for query parameters\n\n```{r}\napi('https://api.github.com/') %\u003e%\n  api_path(repos, ropensci, rgbif, issues) %\u003e%\n  peep\n```\n\n## Query\n\n```{r}\napi(\"http://api.plos.org/search\") %\u003e%\n  api_query(q = ecology, wt = json, fl = 'id,journal') %\u003e%\n  peep\n```\n\n## ToDo\n\nSee [the issues](https://github.com/sckott/request/issues) for discussion of these\n\n* Paging\n* Retry\n* Rate limit\n\n## Meta\n\n* Please note that this project is released with a [Contributor Code of Conduct][coc]. By participating in this project you agree to abide by its terms.\n\n[coc]: https://github.com/sckott/request/blob/master/.github/CODE_OF_CONDUCT.md\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsckott%2Frequest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsckott%2Frequest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsckott%2Frequest/lists"}