The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
Bring data into Shiny on the same port 🚀
Seamlessly integrate POST requests and query parameters into your existing Shiny apps as reactive values. Zero configuration - works with your current UI on the same port.
# Install from CRAN (when available)
install.packages("shinypayload")
# Install development version from GitHub
::install_github("PawanRamaMali/shinypayload")
remotes
# For local development
::load_all() devtools
library(shiny)
library(shinypayload)
# Your regular UI - no changes needed!
<- fluidPage(
base_ui titlePanel("🚀 shinypayload Demo"),
fluidRow(
column(6,
h4("📊 Live Data"),
verbatimTextOutput("live_data")
),column(6,
h4("🔗 URL Parameters"),
verbatimTextOutput("url_params")
)
),
hr(),
h4("📡 POST Endpoint"),
verbatimTextOutput("endpoint_info")
)
# Wrap your UI to handle POST requests
<- payload_ui(
ui
base_ui,path = "/api/data",
token = Sys.getenv("API_TOKEN", "demo-token")
)
<- function(input, output, session) {
server # Get URL parameters
$url_params <- renderPrint({
output<- params_get(session)
params if (length(params) > 0) params else "No URL parameters"
})
# Show endpoint URL
$endpoint_info <- renderText({
output<- payload_endpoint_url(session, "/api/data")
url paste("Send POST requests to:", url, "?token=demo-token")
})
# React to incoming POST data
<- payload_last("/api/data", session, intervalMillis = 200)
live_data
$live_data <- renderPrint({
output<- live_data()
data if (is.null(data)) {
"Waiting for data... 📡"
else {
} list(
timestamp = data$meta$timestamp,
payload = data$payload,
source = data$meta$remote_addr
)
}
})
}
# IMPORTANT: Use uiPattern = ".*" for POST routing
shinyApp(ui, server, uiPattern = ".*")
# Send JSON data
curl -X POST "http://localhost:3838/api/data?token=demo-token" \\
-H "Content-Type: application/json" \\
-d '{"sensor": "temperature", "value": 23.5, "unit": "celsius"}'
# Send form data
curl -X POST "http://localhost:3838/api/data?token=demo-token" \\
-d "name=sensor01&status=active&reading=42"
# Response: {"ok": true}
Function | Purpose | Example |
---|---|---|
payload_ui() |
Wrap UI to handle POST requests | payload_ui(my_ui, "/api", "token") |
payload_last() |
Get reactive with latest POST data | data <- payload_last("/api", session) |
params_get() |
Extract URL query parameters | params <- params_get(session) |
payload_endpoint_url() |
Get full endpoint URL | url <- payload_endpoint_url(session, "/api") |
# Query parameter (recommended)
/api/data?token=your-secret-token
POST
# HTTP Headers
/api/data
POST -Ingress-Token: your-secret-token
X# OR
: your-secret-token Authorization
application/json
- Parsed with
jsonlite::fromJSON()
application/x-www-form-urlencoded
- Parsed with
shiny::parseQueryString()
Explore our comprehensive examples in inst/examples/
:
basic_example.R
- Core functionality demoreal_time_monitor.R
- Live data monitoringform_handler.R
- Form submission processingexisting_app_integration.R
- Add to existing appsEach example includes ready-to-run code and curl commands for testing.
Always use tokens in production
<- payload_ui(base_ui, "/api", Sys.getenv("API_SECRET")) ui
Validate and sanitize input data
observeEvent(payload_last("/api", session), {
<- payload_last("/api", session)()
data if (!is.null(data)) {
# Validate required fields
if (is.null(data$payload$user_id)) return()
# Sanitize inputs before use
<- DBI::dbQuoteString(pool, data$payload$message)
clean_data
} })
Use HTTPS in production
Implement rate limiting if needed
Monitor and log API usage
# Handle different data types on different paths
<- payload_ui(base_ui, "/sensors", "sensor-token")
ui
<- function(input, output, session) {
server # Different reactives for different endpoints
<- payload_last("/sensors", session)
sensor_data <- payload_last("/users", session)
user_data
# Process accordingly...
}
# High-frequency updates (100ms)
<- payload_last("/live", session, intervalMillis = 100)
fast_data
# Low-frequency updates (5 seconds)
<- payload_last("/batch", session, intervalMillis = 5000) slow_data
We welcome contributions! Please see our Contributing Guidelines for details.
# Clone and install dependencies
://github.com/PawanRamaMali/shinypayload.git
git clone https
cd shinypayload
# Install in development mode
::load_all()
devtools
# Run tests
::test()
devtools
# Check package
::check() devtools
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for the R and Shiny community
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.