diff --git a/404.html b/404.html index c27e39d..ae9ae32 100644 --- a/404.html +++ b/404.html @@ -21,7 +21,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/CODE_OF_CONDUCT.html b/CODE_OF_CONDUCT.html index 7118dc2..c904263 100644 --- a/CODE_OF_CONDUCT.html +++ b/CODE_OF_CONDUCT.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/CONTRIBUTING.html b/CONTRIBUTING.html index 6ffdd6f..725ad6e 100644 --- a/CONTRIBUTING.html +++ b/CONTRIBUTING.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/LICENSE-text.html b/LICENSE-text.html index 3ebad76..7976c39 100644 --- a/LICENSE-text.html +++ b/LICENSE-text.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/LICENSE.html b/LICENSE.html index ee0d583..a57ab0e 100644 --- a/LICENSE.html +++ b/LICENSE.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/SUPPORT.html b/SUPPORT.html index 553ccef..cd37fd7 100644 --- a/SUPPORT.html +++ b/SUPPORT.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/authors.html b/authors.html index a26cd02..914faad 100644 --- a/authors.html +++ b/authors.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -46,15 +46,15 @@ Authors Citation Source: DESCRIPTION - Harmon J (2024). + Harmon J (2025). nectar: A Framework for Web API Packages. -R package version 0.0.0.9003, https://github.com/jonthegeek/nectar, https://nectar.api2r.org. +R package version 0.0.0.9004, https://github.com/jonthegeek/nectar, https://nectar.api2r.org. @Manual{, title = {nectar: A Framework for Web API Packages}, author = {Jon Harmon}, - year = {2024}, - note = {R package version 0.0.0.9003, https://github.com/jonthegeek/nectar}, + year = {2025}, + note = {R package version 0.0.0.9004, https://github.com/jonthegeek/nectar}, url = {https://nectar.api2r.org}, } diff --git a/index.html b/index.html index e7a9147..69ad3fc 100644 --- a/index.html +++ b/index.html @@ -23,7 +23,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/pkgdown.yml b/pkgdown.yml index 57be944..e9e2382 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 3.1.11 pkgdown: 2.1.1 pkgdown_sha: ~ articles: {} -last_built: 2024-12-25T14:08Z +last_built: 2025-01-10T13:50Z urls: reference: https://nectar.api2r.org/reference article: https://nectar.api2r.org/articles diff --git a/principles.html b/principles.html index b87b23a..7cc7e5b 100644 --- a/principles.html +++ b/principles.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -32,15 +32,15 @@ -This is an experiment in making key package design principles explicit, versus only implicit in the code. The goal is to make maintenance easier, when spread out over time and across people. (borrowed from https://github.com/r-lib/usethis/blob/main/principles.md) +This is an experiment in making key package design principles explicit, versus only implicit in the code. The goal is to make maintenance easier, when spread out over time and across people. (borrowed from https://github.com/r-lib/usethis/blob/main/principles.md) naming Function and argument names in this package reflect a tug-of-war between conventions used in {httr2} and conventions used in the OpenAPI Specification (OAS). Use these rules to decide how to name things: Names should be lower_snake_case. Names should be unique. For example, {httr2} uses path in several functions to refer to the URL path, but req_cookie_preserve() has a path argument for an on-disk location. We use file_path for this second argument. -Internal functions should begin with .. This is an older convention, but I find it useful for keeping my mental model of the package clear. If an unexported function is later exported, there will be work required to make sure the function is renamed everywhere, and I consider this a feature, not a bug; it makes it more likely to catch strange circular references and other sticking points. +Internal functions should begin with .. This is an older convention, but I find it useful for keeping my mental model of the package clear. If an unexported function is later exported, there will be work required to make sure the function is renamed everywhere, and I consider this a feature, not a bug; it makes it more likely that I’ll catch strange circular references and other sticking points. If a sub-function (internal) is necessary to keep code clean and readable, but it doesn’t do anything unique other than implementing the function that’s calling it, append _impl (implementation) to the end of the function name. For example, .req_path_append() calls .req_path_append_impl() when a path argument is provided. -Lean toward the {httr2} conventions for names. If a function modifies a request object, it should start with req_, and have an argument req. If a function modifies a response object, it should start with resp_, and have an argument resp. +Lean toward the {httr2} conventions for names. If a function modifies a request object, it should start with req_, and have an argument req. If a function modifies a response object, it should start with resp_, and have an argument resp. Exception: to keep documentation consistent, we use resps for functions that accept lists of resp objects, even if they also accept individual resp objects. In fact, all functions with resps arguments should deal with the case where resp is an individual response object. If an argument name is confusing in {httr2}, it might be acceptable to rename it. But be very careful about this. See above about unique names, though. Names should not overlap with {httr2} function names. A modified req_perform() cannot be named req_perform(). If a function essentially translates from OAS to {httr2}, use OAS names for arguments, and {httr2} names for the function. However… @@ -49,12 +49,20 @@ naming< documentation All exported functions must be documented. -Ideally, internal functions should also be documented, with @keywords internal. They do not need a full description, but include a one-line description in the “Title” area, and document their parameters. Most of the time, parameters will be documented in internal functions, and then inherited in the calling exported function (see below). Exception: _impl() functions do not need their own documentation; the parent function’s documentation covers the details in most or all cases. +Ideally, internal functions should also be documented, with @keywords internal. They do not need a full description, but do include a one-line description in the “Title” area, and document their parameters. Most of the time, parameters will be documented in internal functions, and then inherited in the calling exported function (see below). Exception: _impl() functions do not need their own documentation; the parent function’s documentation covers the details in most or all cases. Use @inheritParams liberally. Every parameter should be defined in exactly one place. This makes it much easier to maintain definitions. If you add a new parameter, globally search (ctrl-shift-F in RStudio) for @param {name} to make sure it isn’t already defined. -If a parameter is reused but doesn’t have a clear “home” (eg, req is used in several unrelated functions), define it in the .shared-params block of aaa-shared.R. -Likewise, if a return value is reused but doesn’t have a clear “home” (eg the httr2::request objects returned by several functions), define it once in aaa-shared.R in a block with @name .shared-{name}, where name concisely describes the return value. +If a parameter is reused but doesn’t have a clear “home” (eg, req is used in several unrelated functions), define it in the .shared-params block of aaa-shared.R. It’s ok to err on the side of definining things there. +Likewise, if a return value is reused but doesn’t have a clear “home” (eg the httr2::request objects returned by several functions), define it once in aaa-shared.R in a block with @name .shared-{name}, where name concisely describes the return value. Use this in function documentation with @inherit .shared-{name} return. If a choice contradicts with the choice in {httr2}, explain and justify it in documentation. Make sure it is extremely clear when a default is different. + +testing +TODO + + +motivation +{nectar} is aimed at package writers who are wrapping APIs, particularly APIs with a clear OpenAPI specification. It is an intentionally opinionated framework, so it will make more assumptions than {httr2} about how you things should work. Let’s solve problems here once, and propogate those solutions out to API-wrapping packages that use nectar. I think that means {nectar} will often have two paths through a function: one when things are set up just-so and we can use information in the request or the class of an object to figure out precisely what to do, and then a fall-through for people who are using {nectar} but haven’t bought into the whole framework. The fall-through might fail in a lot of cases, but we should aim to make sure it works for the most common use case(s). That said, probably start with the fall-through in most new areas, and then refine/perfect. + diff --git a/reference/dot-httr2_default_user_agent.html b/reference/dot-httr2_default_user_agent.html index e0360d9..9fb90c3 100644 --- a/reference/dot-httr2_default_user_agent.html +++ b/reference/dot-httr2_default_user_agent.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/reference/dot-lib_user_agent_append.html b/reference/dot-lib_user_agent_append.html index 66ace20..82a876b 100644 --- a/reference/dot-lib_user_agent_append.html +++ b/reference/dot-lib_user_agent_append.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -70,11 +70,11 @@ Argumentscall -(environment) The environment from which a function was -called, e.g. rlang::caller_env() (the default). The environment will be -mentioned in error messages as the source of the error. This argument is -particularly useful for functions that are intended to be called as -utilities inside other functions. +(environment) The environment from which a function was called, +e.g. rlang::caller_env() (the default). The environment will be mentioned +in error messages as the source of the error. This argument is particularly +useful for functions that are intended to be called as utilities inside +other functions. diff --git a/reference/dot-lib_user_agent_string.html b/reference/dot-lib_user_agent_string.html index 41234b4..614dce9 100644 --- a/reference/dot-lib_user_agent_string.html +++ b/reference/dot-lib_user_agent_string.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -58,11 +58,11 @@ Argumentscall -(environment) The environment from which a function was -called, e.g. rlang::caller_env() (the default). The environment will be -mentioned in error messages as the source of the error. This argument is -particularly useful for functions that are intended to be called as -utilities inside other functions. +(environment) The environment from which a function was called, +e.g. rlang::caller_env() (the default). The environment will be mentioned +in error messages as the source of the error. This argument is particularly +useful for functions that are intended to be called as utilities inside +other functions. diff --git a/reference/dot-nectar_abort.html b/reference/dot-nectar_abort.html new file mode 100644 index 0000000..26a0836 --- /dev/null +++ b/reference/dot-nectar_abort.html @@ -0,0 +1,103 @@ + +Error messaging for this package. — .nectar_abort • nectar + Skip to contents + + + + + nectar + + 0.0.0.9004 + + + + + + + + Reference + + + + + + + + + + + Error messaging for this package. + Source: R/utils-conditions.R + dot-nectar_abort.Rd + + + + Error messaging for this package. + + + + Usage + .nectar_abort( + message, + error_class, + ..., + call = rlang::caller_env(), + .envir = rlang::caller_env() +) + + + + Arguments + + +message +It is formatted via a call to cli_bullets(). + + +error_class +(length-1 character) A short string to identify the +error family. + + +... +These dots are for future extensions and must be empty. + + +call +(environment) The environment from which a function was called, +e.g. rlang::caller_env() (the default). The environment will be mentioned +in error messages as the source of the error. This argument is particularly +useful for functions that are intended to be called as utilities inside +other functions. + + +.envir +Environment to evaluate the glue expressions in. + + + + Value + An error condition with classes "nectar-condition", +"nectar-error", and "nectar-error-{error_class}". + + + + + + + + + + + + + diff --git a/reference/dot-nectar_user_agent_append.html b/reference/dot-nectar_user_agent_append.html index 17555a9..753ca66 100644 --- a/reference/dot-nectar_user_agent_append.html +++ b/reference/dot-nectar_user_agent_append.html @@ -9,7 +9,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -57,11 +57,11 @@ Argumentscall -(environment) The environment from which a function was -called, e.g. rlang::caller_env() (the default). The environment will be -mentioned in error messages as the source of the error. This argument is -particularly useful for functions that are intended to be called as -utilities inside other functions. +(environment) The environment from which a function was called, +e.g. rlang::caller_env() (the default). The environment will be mentioned +in error messages as the source of the error. This argument is particularly +useful for functions that are intended to be called as utilities inside +other functions. diff --git a/reference/dot-next_cursor_finder.html b/reference/dot-next_cursor_finder.html index b9f1e01..f3e3911 100644 --- a/reference/dot-next_cursor_finder.html +++ b/reference/dot-next_cursor_finder.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -37,7 +37,7 @@ Usage - .next_cursor_finder(next_cursor_path, resp_body_fn) + .next_cursor_finder(next_cursor_path, resp_body_fn = resp_body_auto) @@ -46,12 +46,15 @@ Argumentsnext_cursor_path (character) A vector indicating the path to the -next_cursor element in the body of the response. +next_cursor element in the body of the response. For example, for the +Slack API, this value is +c("response_metadata", "next_cursor"), while for the Crossref Unified Resource API, this value +is "next-cursor". resp_body_fn -A function to extract the body of the response, such as -httr2::resp_body_json(). +A function to extract the body of the response. Default: +resp_body_auto(). diff --git a/reference/dot-pkg_user_agent_append.html b/reference/dot-pkg_user_agent_append.html index 6f0ec7c..f0cc759 100644 --- a/reference/dot-pkg_user_agent_append.html +++ b/reference/dot-pkg_user_agent_append.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -66,11 +66,11 @@ Argumentscall -(environment) The environment from which a function was -called, e.g. rlang::caller_env() (the default). The environment will be -mentioned in error messages as the source of the error. This argument is -particularly useful for functions that are intended to be called as -utilities inside other functions. +(environment) The environment from which a function was called, +e.g. rlang::caller_env() (the default). The environment will be mentioned +in error messages as the source of the error. This argument is particularly +useful for functions that are intended to be called as utilities inside +other functions. diff --git a/reference/dot-req_auth_api_key_cookie.html b/reference/dot-req_auth_api_key_cookie.html index 5c0e612..9f46185 100644 --- a/reference/dot-req_auth_api_key_cookie.html +++ b/reference/dot-req_auth_api_key_cookie.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/reference/dot-req_auth_api_key_header.html b/reference/dot-req_auth_api_key_header.html index ab2e146..0f56778 100644 --- a/reference/dot-req_auth_api_key_header.html +++ b/reference/dot-req_auth_api_key_header.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/reference/dot-req_auth_api_key_query.html b/reference/dot-req_auth_api_key_query.html index e4bfeec..e28024a 100644 --- a/reference/dot-req_auth_api_key_query.html +++ b/reference/dot-req_auth_api_key_query.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/reference/dot-req_body_auto.html b/reference/dot-req_body_auto.html index 03a16a2..e5d17e6 100644 --- a/reference/dot-req_body_auto.html +++ b/reference/dot-req_body_auto.html @@ -11,7 +11,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/reference/dot-req_method_apply.html b/reference/dot-req_method_apply.html index 0ffbde4..5d7c50d 100644 --- a/reference/dot-req_method_apply.html +++ b/reference/dot-req_method_apply.html @@ -9,7 +9,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/reference/dot-req_path_append.html b/reference/dot-req_path_append.html index dd16915..db77f6d 100644 --- a/reference/dot-req_path_append.html +++ b/reference/dot-req_path_append.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/reference/dot-req_query_flatten.html b/reference/dot-req_query_flatten.html index 17337f1..c653662 100644 --- a/reference/dot-req_query_flatten.html +++ b/reference/dot-req_query_flatten.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/reference/dot-resp_body_auto_other.html b/reference/dot-resp_body_auto_other.html new file mode 100644 index 0000000..d1c2cef --- /dev/null +++ b/reference/dot-resp_body_auto_other.html @@ -0,0 +1,79 @@ + +Automatically choose more body parsers — .resp_body_auto_other • nectar + Skip to contents + + + + + nectar + + 0.0.0.9004 + + + + + + + + Reference + + + + + + + + + + + Automatically choose more body parsers + Source: R/resp_body_auto.R + dot-resp_body_auto_other.Rd + + + + This helper function exists to find somewhat variable content types and +attempt to send them to the proper body parser. + + + + Usage + .resp_body_auto_other(resp) + + + + Arguments + + +resp +(httr2_response) A single httr2::response() object (as +returned by httr2::req_perform()). + + + + Value + The parsed response body. + + + + + + + + + + + + + diff --git a/reference/dot-shared-params.html b/reference/dot-shared-params.html index 47dd2e6..4538343 100644 --- a/reference/dot-shared-params.html +++ b/reference/dot-shared-params.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -80,11 +80,17 @@ Argumentscall -(environment) The environment from which a function was -called, e.g. rlang::caller_env() (the default). The environment will be -mentioned in error messages as the source of the error. This argument is -particularly useful for functions that are intended to be called as -utilities inside other functions. +(environment) The environment from which a function was called, +e.g. rlang::caller_env() (the default). The environment will be mentioned +in error messages as the source of the error. This argument is particularly +useful for functions that are intended to be called as utilities inside +other functions. + + +check_type +(length-1 logical) Whether to check that the response has +the expected content type. Set to FALSE if the response is not +specifically tagged as the proper type. existing_user_agent @@ -141,9 +147,20 @@ Argumentsresp -(httr2_response or list) A single httr2::response() object -(as returned by httr2::req_perform()) or a list of such objects (as -returned by httr2::req_perform_iterative()). +(httr2_response) A single httr2::response() object (as +returned by httr2::req_perform()). + + +resps +(httr2_response, nectar_responses, or list) A single +httr2::response() object (as returned by httr2::req_perform()) or a +list of such objects (as returned by req_perform_opinionated() or +httr2::req_perform_iterative()). + + +resp_body_fn +A function to extract the body of the response. Default: +resp_body_auto(). response_parser diff --git a/reference/dot-shared-request.html b/reference/dot-shared-request.html index 8fc2218..b5e9076 100644 --- a/reference/dot-shared-request.html +++ b/reference/dot-shared-request.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/reference/dot-user_agent_remove.html b/reference/dot-user_agent_remove.html index aa12e4b..10a0f92 100644 --- a/reference/dot-user_agent_remove.html +++ b/reference/dot-user_agent_remove.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -65,11 +65,11 @@ Argumentscall -(environment) The environment from which a function was -called, e.g. rlang::caller_env() (the default). The environment will be -mentioned in error messages as the source of the error. This argument is -particularly useful for functions that are intended to be called as -utilities inside other functions. +(environment) The environment from which a function was called, +e.g. rlang::caller_env() (the default). The environment will be mentioned +in error messages as the source of the error. This argument is particularly +useful for functions that are intended to be called as utilities inside +other functions. diff --git a/reference/get_pkg_name.html b/reference/get_pkg_name.html index add0461..9fc7ebb 100644 --- a/reference/get_pkg_name.html +++ b/reference/get_pkg_name.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -45,11 +45,11 @@ Argumentscall -(environment) The environment from which a function was -called, e.g. rlang::caller_env() (the default). The environment will be -mentioned in error messages as the source of the error. This argument is -particularly useful for functions that are intended to be called as -utilities inside other functions. +(environment) The environment from which a function was called, +e.g. rlang::caller_env() (the default). The environment will be mentioned +in error messages as the source of the error. This argument is particularly +useful for functions that are intended to be called as utilities inside +other functions. diff --git a/reference/index.html b/reference/index.html index c72c152..b4050c2 100644 --- a/reference/index.html +++ b/reference/index.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -102,12 +102,42 @@ All functionsresp_parse() + resp_body_auto() + + + Automatically choose a body parser + + + resp_body_csv() resp_body_tsv() + + + Extract tabular data from response body + + + resp_body_separate() + + + Extract response body into list + + resp_parse() + questioning Parse one or more responses + resp_tidy() + + + Extract and clean an API response + + + resp_tidy_json() + + + Title + + stabilize_string() diff --git a/reference/iterate_with_json_cursor.html b/reference/iterate_with_json_cursor.html index f52af6f..d11510b 100644 --- a/reference/iterate_with_json_cursor.html +++ b/reference/iterate_with_json_cursor.html @@ -3,12 +3,12 @@ for the common situation where the response body is json, and the cursor can be "empty" in various ways. Even within a single API, some endpoints might return a NULL next_cursor to indicate that there are no more pages of -results, while other endpoints might return "". This function normalized +results, while other endpoints might return "". This function normalizes all such results to NULL.'> Skip to contents @@ -17,7 +17,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -46,13 +46,13 @@ for the common situation where the response body is json, and the cursor can be "empty" in various ways. Even within a single API, some endpoints might return a NULL next_cursor to indicate that there are no more pages of -results, while other endpoints might return "". This function normalized +results, while other endpoints might return "". This function normalizes all such results to NULL. Usage - iterate_with_json_cursor(param_name, next_cursor_path) + iterate_with_json_cursor(param_name = "cursor", next_cursor_path) @@ -66,7 +66,10 @@ Argumentsnext_cursor_path (character) A vector indicating the path to the -next_cursor element in the body of the response. +next_cursor element in the body of the response. For example, for the +Slack API, this value is +c("response_metadata", "next_cursor"), while for the Crossref Unified Resource API, this value +is "next-cursor". diff --git a/reference/nectar-package.html b/reference/nectar-package.html index 4f61c8d..93aace2 100644 --- a/reference/nectar-package.html +++ b/reference/nectar-package.html @@ -7,7 +7,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/reference/req_auth_api_key.html b/reference/req_auth_api_key.html index eb6e54e..3c3916b 100644 --- a/reference/req_auth_api_key.html +++ b/reference/req_auth_api_key.html @@ -11,7 +11,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 diff --git a/reference/req_init.html b/reference/req_init.html index 1321e05..04c3143 100644 --- a/reference/req_init.html +++ b/reference/req_init.html @@ -11,7 +11,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -79,7 +79,7 @@ Examples#> GET https://example.com #> Body: empty #> Options: -#> • useragent: 'httr2/1.0.7 r-curl/6.0.1 libcurl/8.5.0 nectar/0.0.0.9003 +#> • useragent: 'httr2/1.0.7 r-curl/6.1.0 libcurl/8.5.0 nectar/0.0.0.9004 #> (https://nectar.api2r.org)' req_init( "https://example.com", @@ -89,7 +89,7 @@ Examples#> GET https://example.com #> Body: empty #> Options: -#> • useragent: 'my_api_client (https://my.api.client) nectar/0.0.0.9003 +#> • useragent: 'my_api_client (https://my.api.client) nectar/0.0.0.9004 #> (https://nectar.api2r.org)' diff --git a/reference/req_modify.html b/reference/req_modify.html index dea71fb..54ffdc6 100644 --- a/reference/req_modify.html +++ b/reference/req_modify.html @@ -9,7 +9,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -106,14 +106,14 @@ Examples#> GET https://example.com/specific/endpoint #> Body: empty #> Options: -#> • useragent: 'httr2/1.0.7 r-curl/6.0.1 libcurl/8.5.0 nectar/0.0.0.9003 +#> • useragent: 'httr2/1.0.7 r-curl/6.1.0 libcurl/8.5.0 nectar/0.0.0.9004 #> (https://nectar.api2r.org)' req_modify(req_base, query = c("param1" = "value1", "param2" = "value2")) #> <httr2_request> #> GET https://example.com?param1=value1¶m2=value2 #> Body: empty #> Options: -#> • useragent: 'httr2/1.0.7 r-curl/6.0.1 libcurl/8.5.0 nectar/0.0.0.9003 +#> • useragent: 'httr2/1.0.7 r-curl/6.1.0 libcurl/8.5.0 nectar/0.0.0.9004 #> (https://nectar.api2r.org)' diff --git a/reference/req_perform_opinionated.html b/reference/req_perform_opinionated.html index 96d385c..d43777c 100644 --- a/reference/req_perform_opinionated.html +++ b/reference/req_perform_opinionated.html @@ -11,7 +11,7 @@ nectar - 0.0.0.9003 + 0.0.0.9004 @@ -88,7 +88,7 @@ Arguments Value A list of httr2::response() objects, one for each request -performed. +performed. The list has additional class nectar_responses.
Source: DESCRIPTION
DESCRIPTION
Harmon J (2024). +
Harmon J (2025). nectar: A Framework for Web API Packages. -R package version 0.0.0.9003, https://github.com/jonthegeek/nectar, https://nectar.api2r.org. +R package version 0.0.0.9004, https://github.com/jonthegeek/nectar, https://nectar.api2r.org.
@Manual{, title = {nectar: A Framework for Web API Packages}, author = {Jon Harmon}, - year = {2024}, - note = {R package version 0.0.0.9003, https://github.com/jonthegeek/nectar}, + year = {2025}, + note = {R package version 0.0.0.9004, https://github.com/jonthegeek/nectar}, url = {https://nectar.api2r.org}, }
This is an experiment in making key package design principles explicit, versus only implicit in the code. The goal is to make maintenance easier, when spread out over time and across people. (borrowed from https://github.com/r-lib/usethis/blob/main/principles.md)
Function and argument names in this package reflect a tug-of-war between conventions used in {httr2} and conventions used in the OpenAPI Specification (OAS). Use these rules to decide how to name things:
lower_snake_case
path
req_cookie_preserve()
file_path
.
_impl
.req_path_append()
.req_path_append_impl()
req_
req
resp_
resp
resps
req_perform()
@keywords internal
_impl()
@inheritParams
@param {name}
.shared-params
aaa-shared.R
httr2::request
@name .shared-{name}
@inherit .shared-{name} return
TODO
{nectar} is aimed at package writers who are wrapping APIs, particularly APIs with a clear OpenAPI specification. It is an intentionally opinionated framework, so it will make more assumptions than {httr2} about how you things should work. Let’s solve problems here once, and propogate those solutions out to API-wrapping packages that use nectar. I think that means {nectar} will often have two paths through a function: one when things are set up just-so and we can use information in the request or the class of an object to figure out precisely what to do, and then a fall-through for people who are using {nectar} but haven’t bought into the whole framework. The fall-through might fail in a lot of cases, but we should aim to make sure it works for the most common use case(s). That said, probably start with the fall-through in most new areas, and then refine/perfect.
(environment) The environment from which a function was -called, e.g. rlang::caller_env() (the default). The environment will be -mentioned in error messages as the source of the error. This argument is -particularly useful for functions that are intended to be called as -utilities inside other functions.
environment
rlang::caller_env()
(environment) The environment from which a function was called, +e.g. rlang::caller_env() (the default). The environment will be mentioned +in error messages as the source of the error. This argument is particularly +useful for functions that are intended to be called as utilities inside +other functions.
R/utils-conditions.R
dot-nectar_abort.Rd
Error messaging for this package.
.nectar_abort( + message, + error_class, + ..., + call = rlang::caller_env(), + .envir = rlang::caller_env() +)
It is formatted via a call to cli_bullets().
cli_bullets()
(length-1 character) A short string to identify the +error family.
length-1 character
These dots are for future extensions and must be empty.
Environment to evaluate the glue expressions in.
An error condition with classes "nectar-condition", +"nectar-error", and "nectar-error-{error_class}".
"nectar-condition"
"nectar-error"
"nectar-error-{error_class}"
.next_cursor_finder(next_cursor_path, resp_body_fn)
.next_cursor_finder(next_cursor_path, resp_body_fn = resp_body_auto)
(character) A vector indicating the path to the -next_cursor element in the body of the response.
character
next_cursor
c("response_metadata", "next_cursor")
"next-cursor"
A function to extract the body of the response, such as -httr2::resp_body_json().
httr2::resp_body_json()
A function to extract the body of the response. Default: +resp_body_auto().
resp_body_auto()
R/resp_body_auto.R
dot-resp_body_auto_other.Rd
This helper function exists to find somewhat variable content types and +attempt to send them to the proper body parser.
.resp_body_auto_other(resp)
(httr2_response) A single httr2::response() object (as +returned by httr2::req_perform()).
httr2_response
httr2::response()
httr2::req_perform()
The parsed response body.
(length-1 logical) Whether to check that the response has +the expected content type. Set to FALSE if the response is not +specifically tagged as the proper type.
length-1 logical
FALSE
(httr2_response or list) A single httr2::response() object -(as returned by httr2::req_perform()) or a list of such objects (as -returned by httr2::req_perform_iterative()).
list
httr2::req_perform_iterative()
(httr2_response, nectar_responses, or list) A single +httr2::response() object (as returned by httr2::req_perform()) or a +list of such objects (as returned by req_perform_opinionated() or +httr2::req_perform_iterative()).
nectar_responses
req_perform_opinionated()
resp_body_csv()
resp_body_tsv()
resp_body_separate()
resp_parse()
resp_tidy()
resp_tidy_json()
stabilize_string()
NULL
""
iterate_with_json_cursor(param_name, next_cursor_path)
iterate_with_json_cursor(param_name = "cursor", next_cursor_path)
A list of httr2::response() objects, one for each request -performed.