Description Usage Arguments Details Value Examples
Assembles an arbitrary web API call URL from a base URL and query string terms. Returns a URL as a string.
1 2 |
baseurl |
string. The base URL to which an additional path and additional query terms may be appended. If baseurl does not begin with 'http://' or 'https://', then 'https://' is prepended. |
path |
string (optional). An additional path to be appended to the base URL before the "?" separator and query terms. |
params |
list (optional). A list of query terms in the form
|
queryterms |
character vector (optional). Vector of query terms passed as strings in the
form |
apikey |
string. (optional). An API key. The API key can also be passed with |
format |
string. (optional). A reponse format given as an extension. If none is specified, the API's default reponse format will be requested. Many API's use JSON as the default. Example formats might include "csv", "xlm", etc. The format will be appended to the API call as a file extension. |
A web API call consitst of a base URL with optional additional path, followed by a "?" separator and query terms separated by the "&" separator.
Query terms are in the form [key][operator][value]
, most commonly [key]=[value]
.
apicall()
uses the baseurl
argument, if provided, as the base URL. path
is
appended to baseurl
before the "?" separator. Queries are built from a list of key-value
pairs passed to the param
argument, and/or a character vector of query terms (conditions)
passed to the queryterms
argument. An API Key, if required, can be set via the
apikey
argument, or passed to param
or queryterms
. Any combination of
queryterms
, param
and apikey
can be used.
apicall()
automatically replaces spaces with %20
in the final URL.
string
1 2 3 4 5 6 7 8 9 10 11 12 | ## Not run:
apicall(baseurl="http://foo.com/", path="list")
p <- list(author="Davy Jones",format="book")
apicall(baseurl="http://foo.com/", path="search", params=p)
q <- c("author=Davy Jones","year>=1980")
apicall(baseurl="http://foo.com/", path="search", queryterms=q)
apicall(baseurl="http://foo.com/search", params=p, queryterms="year>=1980", apikey="123abc")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.