# GraphSense API
#
# GraphSense API provides programmatic access to various ledgers' addresses, entities, blocks, transactions and tags for automated and highly efficient forensics tasks.
#
# The version of the OpenAPI document: 1.0.1
# Contact: contact@ikna.io
# Generated by: https://openapi-generator.tech
#' @docType class
#' @title General operations
#' @description graphsense.General
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ GetStatistics } \emph{ Get statistics of supported currencies }
#'
#'
#' \itemize{
#' \item \emph{ @returnType } \link{Stats} \cr
#'
#'
#' \item status code : 200 | OK
#'
#' \item return type : Stats
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ Search } \emph{ Returns matching addresses, transactions and labels }
#'
#'
#' \itemize{
#' \item \emph{ @param } q character
#' \item \emph{ @param } currency character
#' \item \emph{ @param } limit integer
#' \item \emph{ @returnType } \link{SearchResult} \cr
#'
#'
#' \item status code : 200 | OK
#'
#' \item return type : SearchResult
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' #################### GetStatistics ####################
#'
#' library(graphsense)
#'
#' #Get statistics of supported currencies
#' api.instance <- GeneralApi$new()
#'
#' result <- api.instance$GetStatistics()
#'
#'
#' #################### Search ####################
#'
#' library(graphsense)
#' var.q <- 'foo' # character | It can be (the beginning of) an address, a transaction or a label
#' var.currency <- 'btc' # character | The cryptocurrency (e.g., btc)
#' var.limit <- 10 # integer | Maximum number of search results
#'
#' #Returns matching addresses, transactions and labels
#' api.instance <- GeneralApi$new()
#'
#' #Configure API key authorization: api_key
#' api.instance$apiClient$apiKeys['Authorization'] <- 'WRITE_YOUR_API_KEY_HERE';
#'
#' result <- api.instance$Search(var.q, currency=var.currency, limit=var.limit)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
GeneralApi <- R6::R6Class(
'GeneralApi',
public = list(
apiClient = NULL,
initialize = function(apiClient){
if (!missing(apiClient)) {
self$apiClient <- apiClient
}
else {
self$apiClient <- ApiClient$new()
}
},
GetStatistics = function(...){
apiResponse <- self$GetStatisticsWithHttpInfo(...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
GetStatisticsWithHttpInfo = function(...){
args <- list(...)
queryParams <- list()
headerParams <- c()
body <- NULL
urlPath <- "/stats"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "Stats", loadNamespace("graphsense")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
Search = function(q, currency=NULL, limit=10, ...){
apiResponse <- self$SearchWithHttpInfo(q, currency, limit, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
SearchWithHttpInfo = function(q, currency=NULL, limit=10, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`q`)) {
stop("Missing required parameter `q`.")
}
queryParams['currency'] <- currency
queryParams['q'] <- q
queryParams['limit'] <- limit
body <- NULL
urlPath <- "/search"
# API key authentication
if ("Authorization" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["Authorization"]) > 0) {
headerParams['Authorization'] <- paste(unlist(self$apiClient$apiKeys["Authorization"]), collapse='')
}
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "SearchResult", loadNamespace("graphsense")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.