Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 1 | % Generated by roxygen2: do not edit by hand |
| 2 | % Please edit documentation in R/KorAPConnection.R |
| 3 | \docType{class} |
| 4 | \name{KorAPConnection-class} |
| 5 | \alias{KorAPConnection-class} |
| 6 | \alias{KorAPConnection} |
Marc Kupietz | a8c40f4 | 2025-06-24 15:49:52 +0200 | [diff] [blame] | 7 | \title{Connect to KorAP Server} |
Marc Kupietz | f9914bb | 2025-06-25 09:57:55 +0200 | [diff] [blame^] | 8 | \arguments{ |
| 9 | \item{KorAPUrl}{URL of the web user interface of the KorAP server instance you want to access. |
| 10 | Defaults to the environment variable \code{KORAP_URL} if set and to the IDS Mannheim KorAP main instance |
| 11 | to query DeReKo, otherwise.} |
| 12 | |
| 13 | \item{apiVersion}{which version of KorAP's API you want to connect to. Defaults to "v1.0".} |
| 14 | |
| 15 | \item{apiUrl}{URL of the KorAP web service. If not provided, it will be constructed from KorAPUrl and apiVersion.} |
| 16 | |
| 17 | \item{accessToken}{OAuth2 access token. For queries on corpus parts with restricted |
| 18 | access (e.g. textual queries on IPR protected data), you need to authorize |
| 19 | your application with an access token. |
| 20 | You can obtain an access token in the OAuth settings of your KorAP web interface. |
| 21 | |
| 22 | More details are explained in the |
| 23 | \href{https://github.com/KorAP/RKorAPClient#authorization}{authorization section} |
| 24 | of the RKorAPClient Readme on GitHub. |
| 25 | |
| 26 | To use authorization based on an access token |
| 27 | in subsequent queries, initialize your KorAP connection with: |
| 28 | |
| 29 | \if{html}{\out{<div class="sourceCode">}}\preformatted{kco <- KorAPConnection(accessToken="<access token>") |
| 30 | }\if{html}{\out{</div>}} |
| 31 | |
| 32 | In order to make the API |
| 33 | token persistent for the currently used \code{KorAPUrl} (you can have one |
| 34 | token per KorAPUrl / KorAP server instance), use: |
| 35 | |
| 36 | \if{html}{\out{<div class="sourceCode">}}\preformatted{persistAccessToken(kco) |
| 37 | }\if{html}{\out{</div>}} |
| 38 | |
| 39 | This will store it in your keyring using the |
| 40 | \link[keyring:keyring-package]{keyring::keyring-package}. Subsequent KorAPConnection() calls will |
| 41 | then automatically retrieve the token from your keying. To stop using a |
| 42 | persisted token, call \code{clearAccessToken(kco)}. Please note that for |
| 43 | DeReKo, authorized queries will behave differently inside and outside the |
| 44 | IDS, because of the special license situation. This concerns also cached |
| 45 | results which do not take into account from where a request was issued. If |
| 46 | you experience problems or unexpected results, please try \code{kco <- KorAPConnection(cache=FALSE)} or use |
| 47 | \code{\link[=clearCache]{clearCache()}} to clear the cache completely. |
| 48 | |
| 49 | An alternative to using an access token is to use a browser-based oauth2 workflow |
| 50 | to obtain an access token. This can be done with the \code{\link[=auth]{auth()}} method.} |
| 51 | |
| 52 | \item{oauthClient}{OAuth2 client object (advanced users only).} |
| 53 | |
| 54 | \item{oauthScope}{OAuth2 scope. Defaults to "search match_info".} |
| 55 | |
| 56 | \item{authorizationSupported}{logical that indicates if authorization is supported/necessary for the current KorAP instance. Automatically set during initialization.} |
| 57 | |
| 58 | \item{userAgent}{user agent string. Defaults to "R-KorAP-Client".} |
| 59 | |
| 60 | \item{timeout}{timeout in seconds for API requests (this does not influence server internal timeouts). Defaults to 240 seconds.} |
| 61 | |
| 62 | \item{verbose}{logical that decides whether following operations will default to |
| 63 | be verbose. Defaults to FALSE.} |
| 64 | |
| 65 | \item{cache}{logical that decides if API calls are cached locally. You can clear |
| 66 | the cache with \code{\link[=clearCache]{clearCache()}}. Defaults to TRUE.} |
| 67 | } |
| 68 | \value{ |
| 69 | \code{\link[=KorAPConnection]{KorAPConnection()}} object that can be used e.g. with \code{\link[=corpusQuery]{corpusQuery()}} |
| 70 | } |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 71 | \description{ |
Marc Kupietz | a8c40f4 | 2025-06-24 15:49:52 +0200 | [diff] [blame] | 72 | \code{KorAPConnection()} creates a connection to a KorAP server for corpus queries. |
| 73 | This is your starting point for all corpus analysis tasks. |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 74 | } |
Marc Kupietz | a8c40f4 | 2025-06-24 15:49:52 +0200 | [diff] [blame] | 75 | \details{ |
| 76 | Use \code{KorAPConnection()} to connect, then \code{corpusQuery()} to search, and |
| 77 | \code{fetchAll()} to retrieve results. For authorized access to restricted corpora, |
| 78 | use \code{auth()} or provide an \code{accessToken}. |
Marc Kupietz | a81343d | 2022-09-06 12:32:10 +0200 | [diff] [blame] | 79 | |
Marc Kupietz | a8c40f4 | 2025-06-24 15:49:52 +0200 | [diff] [blame] | 80 | The KorAPConnection object contains various configuration slots for advanced users: |
| 81 | KorAPUrl (server URL), apiVersion, accessToken (OAuth2 token), |
| 82 | timeout (request timeout), verbose (logging), cache (local caching), |
| 83 | and other technical parameters. Most users can ignore these implementation details. |
| 84 | } |
| 85 | \section{Basic Workflow}{ |
Marc Kupietz | a81343d | 2022-09-06 12:32:10 +0200 | [diff] [blame] | 86 | |
Marc Kupietz | a81343d | 2022-09-06 12:32:10 +0200 | [diff] [blame] | 87 | |
Marc Kupietz | a8c40f4 | 2025-06-24 15:49:52 +0200 | [diff] [blame] | 88 | \if{html}{\out{<div class="sourceCode r">}}\preformatted{# Connect to KorAP |
| 89 | kcon <- KorAPConnection() |
Marc Kupietz | a81343d | 2022-09-06 12:32:10 +0200 | [diff] [blame] | 90 | |
Marc Kupietz | a8c40f4 | 2025-06-24 15:49:52 +0200 | [diff] [blame] | 91 | # Search for a term |
| 92 | query <- corpusQuery(kcon, "Ameisenplage") |
Marc Kupietz | a81343d | 2022-09-06 12:32:10 +0200 | [diff] [blame] | 93 | |
Marc Kupietz | a8c40f4 | 2025-06-24 15:49:52 +0200 | [diff] [blame] | 94 | # Get all results |
| 95 | results <- fetchAll(query) |
| 96 | }\if{html}{\out{</div>}} |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 97 | } |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 98 | |
Marc Kupietz | a8c40f4 | 2025-06-24 15:49:52 +0200 | [diff] [blame] | 99 | \section{Authorization}{ |
Marc Kupietz | 6ae7605 | 2021-09-21 10:34:00 +0200 | [diff] [blame] | 100 | |
Marc Kupietz | a8c40f4 | 2025-06-24 15:49:52 +0200 | [diff] [blame] | 101 | For access to restricted corpora, authorize your connection: |
| 102 | |
| 103 | \if{html}{\out{<div class="sourceCode r">}}\preformatted{kcon <- KorAPConnection() |> auth() |
| 104 | }\if{html}{\out{</div>}} |
Marc Kupietz | 4862b86 | 2019-11-07 10:13:53 +0100 | [diff] [blame] | 105 | } |
| 106 | |
Marc Kupietz | a8c40f4 | 2025-06-24 15:49:52 +0200 | [diff] [blame] | 107 | \seealso{ |
| 108 | Other initialization functions: |
| 109 | \code{\link{auth,KorAPConnection-method}}, |
| 110 | \code{\link{clearAccessToken,KorAPConnection-method}}, |
| 111 | \code{\link{persistAccessToken,KorAPConnection-method}} |
Marc Kupietz | e95108e | 2019-09-18 13:23:58 +0200 | [diff] [blame] | 112 | } |
Marc Kupietz | a8c40f4 | 2025-06-24 15:49:52 +0200 | [diff] [blame] | 113 | \concept{initialization functions} |