Plumber API Cheat Sheet
A Plumber reference for turning R functions into callable APIs with routes, parameters, filters and structured responses.
What this reference covers
Plumber connects R functions to HTTP routes. This reference follows the request path from route and method through parameters, filters, business logic, serialization, response codes and errors. It helps a data-analysis script become an explicit interface rather than a collection of session-specific commands.
Define the request contract
Distinguish path parameters, query parameters and request bodies, and document type, required status, defaults and bounds for each. Start with a pure function that accepts ordinary values and returns a predictable object, then add request validation before calling it.
Test success and failure separately
Exercise valid responses, bad parameters and internal errors. Check status code, content type, timeout behavior and logging, and avoid returning internal paths, credentials or complete user records. Production deployment also needs authentication, rate limits and access controls.
Maintenance note
Bind local examples to a local address and fake data first. File, database, system-command and cross-origin behavior require an independent design review. Content review date: 2026-08-23.
Save to your cloud drive
Save the complete collection first so files remain together and are easier to access across devices.
Quark Cloud Drive
RecommendedSave Plumber API Cheat Sheet to this cloud drive
Baidu Netdisk
Save Plumber API Cheat Sheet to this cloud drive
Plumber API study guide
Map the route and request contract first, wrap a stable pure function, validate inputs and verify both responses and errors before deployment.
Before you start
- Know R functions, data frames and package loading.
- Prepare a PDF reader and a local R project that can run a small example.
- Use fake data and no real credentials in the practice endpoint.
Quick start
- 01
Read routes and methods
Record each route, HTTP method, path parameter, query parameter and response type before writing the handler.
- 02
Start with a pure function
Use a function that accepts ordinary values and returns a data frame or list, and confirm its output independently of HTTP.
- 03
Validate requests
Check required parameters, types, defaults and bounds at the boundary instead of passing an unvalidated request object to business code.
- 04
Verify responses and errors
Test success, invalid input and internal failures, checking status, content type and logs for accidental disclosure.
Usage tips
- Develop on a local address with fake data, then add proxy, authentication and access rules for publication.
- Treat response fields as a client contract and version breaking changes.
- Restrict paths, permissions and timeouts before adding caching or concurrency for files, databases or external services.
Troubleshooting and uninstall
Why is a route parameter empty?
Confirm whether it belongs in the path, query string or request body, then inspect the validated value before calling business logic.
How should a 500 response be investigated?
Reproduce with minimal input, separate function, serialization and filter errors, and ensure logs do not contain tokens or full user data.
Frequently asked questions
Who is the Plumber cheat sheet for?
It is for R developers who want to expose analysis functions as HTTP APIs and review routes, parameters and response handling.
Does the sheet replace full API documentation?
No. A real project still needs an interface contract, authentication, error codes, data scope and version policy.
How should API parameters be designed?
Classify path, query and body parameters, and define type, required status, default, bounds and validation at the entry point.
What should be checked before publishing?
Check authentication, permissions, input validation, redacted logs, timeouts and response format, and remove debug endpoints and arbitrary file paths.