https://github.com/sckott/httping
Ping urls to time requests
https://github.com/sckott/httping
http http-client http-requests httping r rstats
Last synced: 7 months ago
JSON representation
Ping urls to time requests
- Host: GitHub
- URL: https://github.com/sckott/httping
- Owner: sckott
- License: other
- Created: 2014-12-03T07:30:22.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2022-11-04T21:19:56.000Z (about 3 years ago)
- Last Synced: 2025-04-18T04:55:47.964Z (7 months ago)
- Topics: http, http-client, http-requests, httping, r, rstats
- Language: R
- Homepage:
- Size: 56.6 KB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- jimsghstars - sckott/httping - Ping urls to time requests (R)
README
httping
=======
```{r echo=FALSE}
knitr::opts_chunk$set(
warning = FALSE,
message = FALSE,
collapse = TRUE,
comment = "#>"
)
```
[](https://cloud.r-project.org/web/checks/check_results_httping.html)
[](https://github.com/sckott/httping/actions/workflows/R-check.yaml)
[](https://github.com/metacran/cranlogs.app)
[](https://cran.r-project.org/package=httping)
`httping` is a tiny R package to Ping urls to time requests. It's a port of the Ruby gem [httping](https://github.com/jpignata/httping).
## Install
CRAN stable version
```{r eval=FALSE}
install.packages("httping")
```
Development version from Github
```{r eval=FALSE}
install.packages("pak")
pak::pkg_install("sckott/httping")
```
```{r}
library("httping")
library("httr")
```
## Pass any httr request to time
A `GET` request
```{r}
GET("https://google.com") %>% time(count = 3)
```
A `POST` request
```{r}
POST("https://mockbin.com/request", body = "A simple text string") %>% time(count = 3)
```
The return object is a list with slots for all the `httr` response objects, the times for each request, and the average times. The number of requests, and
the delay between requests are included as attributes.
```{r}
res <- GET("http://google.com") %>% time(count = 3)
attributes(res)
```
Or print a summary of a response, gives more detail
```{r}
res %>% summary()
```
Messages are printed using `cat`, so you can suppress those using `verbose=FALSE`, like
```{r}
GET("https://google.com") %>% time(count = 3, verbose = FALSE)
```
## Ping an endpoint
This function is a bit different, accepts a url as first parameter, but can accept any args passed on to `httr` verb functions, like `GET`, `POST`, etc.
```{r}
"https://google.com" %>% ping()
```
Or pass in additional arguments to modify request
```{r}
"https://google.com" %>% ping(config = verbose())
```
## Meta
* Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.