Title: Use 'Aplos NCA API' for Pharmacokinetic Analysis
Version: 1.0.1
Description: Using this package you can interact with the 'Aplos NCA API'https://docs.aplosanalytics.com/ using standard R functions. This will allow you to authenticate with your 'Aplos NCA' account, upload input datasets, initiate analyses, and download results.
License: MIT + file LICENSE
URL: https://github.com/AplosAnalytics/AplosNCA
BugReports: https://github.com/AplosAnalytics/AplosNCA/issues
Encoding: UTF-8
RoxygenNote: 7.3.3
VignetteBuilder: knitr
Imports: AzureAuth, httr, jsonlite, stringr
Suggests: httptest2, testthat (≥ 3.0.0), knitr, rmarkdown, withr, downloader
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-04-02 21:22:51 UTC; nathanteuscher
Author: Nathan Teuscher [aut, cre]
Maintainer: Nathan Teuscher <nathan@aplosanalytics.com>
Repository: CRAN
Date/Publication: 2026-04-09 08:50:24 UTC

Download Results Information from Aplos NCA Analysis

Description

Retrieves download URLs and files from Aplos NCA analysis results.

Usage

aplos_download_results(url, token, execution_id)

Arguments

url

The base API URL.

token

JWT token.

execution_id

The execution ID.

Value

A data frame with download URL and filename.

Examples

## Not run: 
  df <- aplos_download_results("https://api.app.aplos-nca.com", token, "exec_123")

## End(Not run)

Execute NCA Analysis in Aplos

Description

Submits and executes an NCA analysis on uploaded data.

Usage

aplos_execute_analysis(
  result,
  data_cleaning = "{}",
  analysis = "{}",
  calcs = "{}",
  plots = "{}",
  tables = "{}",
  metadata = "{}",
  url,
  token,
  name = "NCA Analysis via R",
  save_body = FALSE
)

Arguments

result

Result from aplos_get_upload_url().

data_cleaning

JSON string for data cleaning (default "").

analysis

JSON string for PK parameter calculation (default "").

calcs

JSON string for custom calculations (default "").

plots

JSON string for custom plots (default "").

tables

JSON string for custom tables (default "").

metadata

JSON string for metadata (default "").

url

The base API URL.

token

JWT token.

name

Analysis name (default "NCA Analysis via R").

save_body

Logical; save body of API POST command to body.txt file? (default FALSE, set to TRUE for debugging).

Value

The execution ID.

Examples

## Not run: 
  exec_id <- aplos_execute_analysis(upload_result,
  url = "https://api.app.aplos-nca.com", token = token)

## End(Not run)

Check Execution Status in Aplos NCA

Description

Polls the status of an NCA analysis execution until complete or failed.

Usage

aplos_execution_status(url, token, execution_id, sleep = 10)

Arguments

url

The base API URL.

token

JWT token.

execution_id

The execution ID from aplos_execute_analysis().

sleep

Numeric value for time (in seconds) between status checks (default 10).

Value

The status result if succeeded, or stops with error if failed.

Examples

## Not run: 
  status <- aplos_execution_status("https://api.app.aplos-nca.com", token, "exec_123")

## End(Not run)

Fetch and Optionally Unzip Aplos NCA Results

Description

Downloads the results file from the provided download information and optionally unzips it.

Usage

aplos_fetch_results(download_info, dest_dir = "", unzip = FALSE)

Arguments

download_info

A data frame from aplos_download_results() containing url and filename.

dest_dir

Directory to save the downloaded file (default: current working directory).

unzip

Logical; if TRUE, unzip the file to dest_dir/unzip (default: FALSE).

Value

The path to the downloaded file (or unzip directory if unzip=TRUE).

Examples

## Not run: 
  # Assuming status is "succeeded"
  download_info <- aplos_download_results(url, token, execution_id)
  file_path <- aplos_fetch_results(download_info, unzip = TRUE)

## End(Not run)

Obtain Aplos NCA API JWT Token

Description

Authenticates with the Aplos NCA API using AWS Cognito. This function sends a POST request to retrieve a JWT token for subsequent API calls. All API calls require a valid JWT. The JWT is only valid for a period of time (~15 minutes). Each time you make an API call with a valid JWT, that token is refreshed and the valid period is extended. Thus during a normal analysis you will only need to authenticate once as you will be making API calls within the valid time window. However, if you walk away from your computer or there is a long delay between API calls you may need to authenticate again.

Note: Store credentials securely; do not hardcode them in scripts. It is recommended that you use a hidden text file (e.g. ".aplos_creds") stored on your local computer. Read that file in and then parse it to update the required information for authentication. An example credential file may look like the following: APLOS_API_URL="https://api.app.aplos-nca.com" COGNITO_CLIENT_KEY="your_cognito_client_id/key" COGNITO_USER_NAME="your_username" COGNITO_PASSWORD="your_password" COGNITO_REGION="your_aws_region" All of this information can be found in your user profile for your Aplos NCA account under "API Settings".

Usage

aplos_get_jwt(client_id, username, password, region)

Arguments

client_id

The Cognito client ID.

username

Your Aplos NCA username.

password

Your Aplos NCA password.

region

The AWS region (e.g., "us-east-1").

Value

A character string containing the JWT token.

Examples

## Not run: 
  token <- aplos_get_jwt(client_id = "your_client_id", username = "user",
                         password = "pass", region = "us-east-1")

## End(Not run)

Get Presigned Upload URL for Aplos NCA

Description

Retrieves a presigned URL for uploading files to Aplos NCA.

Usage

aplos_get_upload_url(input_file, url, token)

Arguments

input_file

Path to the input file.

url

The base API URL.

token

JWT token from aplos_get_jwt().

Value

A list with upload details.

Examples

## Not run: 
  result <- aplos_get_upload_url("path/to/file.csv", "https://api.app.aplos-nca.com", token)

## End(Not run)

Upload File to Aplos NCA

Description

Uploads a file using the presigned URL.

Usage

aplos_upload_file(input_file, result, token)

Arguments

input_file

Path to the input file.

result

Result from aplos_get_upload_url().

token

JWT token.

Value

Invisible NULL. Uploads the file to the API as a side effect; throws an error if the upload fails.

Examples

## Not run: 
  aplos_upload_file("path/to/file.csv", upload_result, token)

## End(Not run)