🔗 CCP REST APIs

CCP exposes its services through RESTful APIs, allowing users to:

  • List available methods

  • Execute methods programmatically

  • Monitor execution status

  • Download results

This enables automation, integration into pipelines, and reproducibility.


🌍 API Standard

CCP APIs are based on the OGC API - Processes 1.2 specification.
It is a modern replacement for the older WPS (Web Processing Service) standard.

The full API is documented as an OpenAPI 3 spec:

📄 SwaggerHub OpenAPI Docs


🧰 Code Generation in CCP

When using the UI (method execution form or execution monitor), you can:

  • Select a target language (Python, R, Jupyter, Curl, Bash, Julia, etc.)

  • Click the code icon to download a script

  • Use it to:

    • Launch executions via REST

    • Poll for completion

    • Fetch results


📦 Example: Launch and Monitor Execution (in R)

# Dependencies
library(httr)
library(jsonlite)
library(rstudioapi)

# Init
user <- 'your_user'
context <- 'your_vre'
auth_ep <- 'https://auth.d4science.org/token'
client_id <- 'ccp-client-id'
ccp_ep <- 'https://ccp.d4science.org'

# Get token from password
getToken <- function(pwd) {
  login <- POST(auth_ep,
    body = list(
      grant_type = 'password',
      client_id = client_id,
      username = user,
      password = pwd
    ),
    encode = 'form',
    add_headers(`Content-Type` = 'application/x-www-form-urlencoded')
  )
  token <- fromJSON(content(login, 'text'))

  # UMA token for CCP
  uma <- POST(auth_ep,
    body = list(
      grant_type = 'urn:ietf:params:oauth:grant-type:uma-ticket',
      audience = context
    ),
    encode = 'form',
    add_headers(
      `Content-Type` = 'application/x-www-form-urlencoded',
      Authorization = paste('Bearer', token$access_token)
    )
  )
  return(fromJSON(content(uma, 'text'))$access_token)
}

# Prepare JSON request
request <- fromJSON('{
  "inputs": {
    "ccpimage": "bash",
    "ccpreplicas": "1"
  },
  "outputs": {
    "output": { "transmissionMode": "value" }
  },
  "response": "raw"
}')

# Ask password
pwd <- askForPassword("Login password")
jwt <- getToken(pwd)

# Submit execution
url <- paste0(ccp_ep, '/processes/{methodid}/execution')
res <- POST(url, body = request, encode = 'json', add_headers(Authorization = paste('Bearer', jwt)))

if (status_code(res) != 201) stop("Failed to start execution")

job <- fromJSON(content(res, 'text'))

# Poll for status
repeat {
  url <- paste0(ccp_ep, '/jobs/', job$jobID)
  res <- GET(url, add_headers(Authorization = paste('Bearer', jwt)))
  job <- fromJSON(content(res, 'text'))

  cat(paste('[', Sys.time(), ']', job$status, ':', job$message, '\n'))
  if (job$status %in% c("successful", "failed")) break
  Sys.sleep(5)
}

# Download result
GET(
  paste0(ccp_ep, '/executions/', job$jobID, '/outputs/output.zip'),
  add_headers(Authorization = paste('Bearer', jwt)),
  write_disk("output.zip", overwrite = TRUE)
)