This is a convenience wrapper for the GTmetrix API 2.0.
I whipped up a small library to talk to GTmetrix via R. There's some basic sanity checking baked in, but obviously this is still work in progress and there are (potentially critical) bugs. Feel free to check it out, though. If you need help, take a look at the manuals. A good point to start is
If you have feedback and/or points for improvement, feel free to open an issue / PR here on Github. I would love to hear from you!
# Install and load library. devtools::install_github("RomanAbashin/rgtmx") library(rgtmx)
# Returns the final report (after checking for completion roughly every 3 seconds). result <- start_test("google.com", "[API_KEY]")
This will start a test and wait for the report to be generated, returning the result as data.frame. Optionally, you can just simply return the test ID and other meta data via the parameter
wait_for_completion = FALSE.
# Returns just the test ID and some meta data. Does not wait for report completion. result <- start_test("google.com", "[API_KEY]", wait_for_completion = FALSE)
Other optional parameters are:
Please consult the manual via
?start_test or the GTmetrix API documentation for further information.
# Show available locations show_available_locations("[API_KEY]") # Get location details get_location_details(location_id = 1, "[API_KEY]")
# Show available browsers show_available_browsers("[API_KEY]") # Get browser details get_browser_details(browser_id = 3, [API_KEY]")
# Get specific test get_test("[TEST_ID]", "[API_KEY]") # Get specific report get_report("[REPORT_ID]", "[API_KEY]") # Get all tests get_all_tests("[API_KEY]")
# Get account status and available credits get_account_status("[API_KEY]")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.