diff --git a/docusaurus/docs/jaqpot-api/SDKs/java-kotlin-sdk.md b/docusaurus/docs/jaqpot-api/SDKs/java-kotlin-sdk.md new file mode 100644 index 0000000..b751d01 --- /dev/null +++ b/docusaurus/docs/jaqpot-api/SDKs/java-kotlin-sdk.md @@ -0,0 +1,76 @@ +--- +title: Kotlin/Java SDK +sidebar_position: 2 +--- + +# Kotlin/Java SDK + +The SDK lets you use Jaqpot models and predictions in your Java or Kotlin applications. + +## Get your API Keys +You'll need an API key and secret from your Jaqpot account. Create them by following the [API keys guide](../authentication/create-an-api-key). + +**The API keys are valid for 6 months from their generation date. Please store these keys securely, as they cannot be retrieved from Jaqpot after initial generation. If your keys are lost or expired, you will need to generate new ones by following the same steps above.** + +## Add to your project + +Maven central page: https://central.sonatype.com/artifact/org.jaqpot/kotlin-sdk + +For Gradle (Kotlin DSL): +```kotlin +implementation("org.jaqpot:kotlin-sdk:0.4.0") // or the latest version of the SDK +``` +For Maven: +```xml + + org.jaqpot + kotlin-sdk + 0.4.0 + +``` +## Basic usage +Make predictions in Java: +```kotlin +JaqpotApiClient jaqpotApiClient = + new JaqpotApiClient(System.getenv("JAQPOT_API_KEY"), System.getenv("JAQPOT_API_SECRET")); +Dataset dataset = jaqpotApiClient + .predictSync( + modelId, + List.of( + Map.of("X1", "1", "X2", "2", "X3", "3", "X4", "4") + ) + ); +System.out.println(dataset) +``` + +or in Kotlin: +```kotlin +val jaqpotApiClient = + JaqpotApiClient(System.getenv("JAQPOT_API_KEY"), System.getenv("JAQPOT_API_SECRET")) +val dataset = jaqpotApiClient.predictSync( + modelId, + listOf( + mapOf("X1" to "1", "X2" to "2", "X3" to "3", "X4" to "4") + ) +) +println(dataset) +``` +## Setting API Keys +Use environment variables: +```bash +export JAQPOT_API_KEY=your_key_here +export JAQPOT_API_SECRET=your_secret_here +``` +Or pass them directly to the client: +```kotlin +val client = JaqpotApiClient("your-key", "your-secret") +``` + +## Error handling +The SDK throws JaqpotSDKException on errors like: + +- Wrong API credentials +- Model not found +- Failed predictions +- Network issues + diff --git a/docusaurus/docs/jaqpot-api/SDKs/qsartoolbox-python-sdk.md b/docusaurus/docs/jaqpot-api/SDKs/qsartoolbox-python-sdk.md index 5033b1c..c61c06f 100644 --- a/docusaurus/docs/jaqpot-api/SDKs/qsartoolbox-python-sdk.md +++ b/docusaurus/docs/jaqpot-api/SDKs/qsartoolbox-python-sdk.md @@ -1,6 +1,6 @@ --- title: QSAR Toolbox Python SDK -sidebar_position: 2 +sidebar_position: 3 --- The jaqpotpy SDK provides seamless access to QSAR Toolbox, a comprehensive software application designed for filling data gaps in toxicity data. Through the SDK, users can interact with three main components of QSAR Toolbox: diff --git a/docusaurus/docs/jaqpot-api/documentation/prediction-workflow.md b/docusaurus/docs/jaqpot-api/documentation/prediction-workflow.md new file mode 100644 index 0000000..bc42a70 --- /dev/null +++ b/docusaurus/docs/jaqpot-api/documentation/prediction-workflow.md @@ -0,0 +1,71 @@ +--- +title: Prediction Workflow +sidebar_position: 3 +--- + +# Prediction Workflow + +When making predictions with Jaqpot models, the process is asynchronous. Here's how it works: + +## Steps + +1. Send prediction request + ```bash + POST /model/{id}/predict + ``` +2. Get dataset ID from response header +```Location: /dataset/123456``` + +3. Query dataset status until complete +```bash +GET /dataset/123456 +``` +The dataset will be in one of these states: + +- EXECUTING: Waiting to be processed +- SUCCESS: Prediction completed successfully +- FAILURE: Prediction failed + + +## Example Flow +```python +# 1. Make prediction request +response = POST /model/42/predict +dataset_id = get_id_from_location_header(response.headers["Location"]) + +# 2. Poll dataset until complete +retries = 0 +while retries < 10: + dataset = GET /dataset/{dataset_id} + + if dataset.status in ["SUCCESS", "FAILURE"]: + break + + # Wait 2 seconds before next check + sleep(2) + retries += 1 + +# 3. Handle result +if dataset.status == "SUCCESS": + predictions = dataset.predictions +else: + handle_error(dataset.error) +``` +### Notes +- Maximum recommended polling attempts: 10 +- Recommended interval between checks: 2 seconds +- Location header format: /dataset/{id} +I- f polling exceeds maximum attempts, consider the prediction failed + +### Common Errors + +- Dataset not found: Invalid dataset ID +- Maximum retries exceeded: Prediction taking too long +- Dataset in FAILURE state: Check error message in dataset response + +## SDK Implementation +All official Jaqpot SDKs handle this polling mechanism automatically. For example using the Java/Kotlin SDK: +```kotlin +val client = JaqpotApiClient(apiKey, apiSecret) +val result = client.predictSync(modelId, input) // Handles polling internally +``` diff --git a/docusaurus/docs/jaqpot-api/documentation/Swagger.md b/docusaurus/docs/jaqpot-api/documentation/swagger.md similarity index 91% rename from docusaurus/docs/jaqpot-api/documentation/Swagger.md rename to docusaurus/docs/jaqpot-api/documentation/swagger.md index d0c4f12..f2af927 100644 --- a/docusaurus/docs/jaqpot-api/documentation/Swagger.md +++ b/docusaurus/docs/jaqpot-api/documentation/swagger.md @@ -1,4 +1,5 @@ --- +title: Swagger API Documentation sidebar_position: 2 --- Browse our complete API documentation through Swagger UI. Here you'll find all available endpoints, request/response examples, and authentication details. The API follows REST principles and returns JSON responses.