Skip to content

Test the API

Introduction

AnkaSecure provides a robust API for cryptographic operations and key management, supporting symmetric, asymmetric, and post-quantum encryption/signing algorithms like AES, RSA, ECC, ML-KEM, Dilithium, and Falcon.

This page describes multiple ways to test the API:

  • Swagger UI – Interactive API testing.
  • cURL – Quick command-line testing.
  • AnkaSecure CLI – Advanced cryptographic operations via terminal.
  • SDKs – Java.

1. Test with Swagger UI

Access Swagger API Test Console

How to use Swagger UI:

  1. Open the Swagger UI link.
  2. Click Authorize and enter:
    • clientId
    • clientSecret
  3. Select an endpoint, click Try it out, enter parameters, and execute the request.
  4. View the request/response format.

Ideal for: Quick interactive testing of all API endpoints.


2. Test with Postman

AnkaSecure provides a Postman collection for easy testing.

👉 Download Postman Collection

Steps:

  1. Import openapi JSON collection into Postman.
  2. Go to Environment Variables and set:
    • baseUrl: https://demo.ankatech.co
    • clientId: yourClientId
    • clientSecret: yourSecret
  3. Authenticate and store the access token.
  4. Start making requests.

Ideal for: Developers who want to automate testing without writing scripts.


3. Test with cURL

You can also interact with the API using cURL.

Authenticate and Get a Token

curl -X POST https://demo.ankatech.co/api/authenticate/app \
     -H "Content-Type: application/json" \
     -d '{ "clientId": "YOUR_CLIENT_ID", "clientSecret": "YOUR_SECRET" }'

Encrypt Data

curl -X POST https://demo.ankatech.co/api/crypto/encrypt\
     -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
     -H "Content-Type: application/json"\
     -d '{ "kid": "myKeyKid", "data": "SGVsbG8gQW5rYQ==" }'

Decrypt Data

curl -X POST https://demo.ankatech.co/api/crypto/decrypt\
     -H "Authorization: Bearer YOUR_ACCESS_TOKEN"\
     -H "Content-Type: application/json"\
     -d '{ "kid": "myKeyKid", "encryptedData": "QW5rYVNlY3VyZURhdGE=" }'

Ideal for: Quick command-line testing.


4. Test with AnkaSecure CLI

The AnkaSecure CLI enables local cryptographic operations using the API.

Installation

Download the CLI:

  • Windows: https://docs.ankatech.co/installers/AnkaSecureCLI_windows-x64_1_1_0.exe

  • macOS: https://docs.ankatech.co/installers/AnkaSecureCLI_macos_1_1_0.dmg

  • Linux: https://docs.ankatech.co/installers/AnkaSecureCLI_unix_1_1_0.sh

Configure Credentials (cli.properties)

clientId=myAppId
clientSecret=myAppSecret
openapi.scheme=https
openapi.host=demo.ankatech.co
openapi.port=443

Example CLI Commands

Generate a Post-Quantum Key (ML-KEM-768)

java -jar AnkaSecureCLI.jar generate-key --kid myKyberKey --kty ML-KEM --alg ML-KEM-768

Encrypt a File

java -jar AnkaSecureCLI.jar encrypt-file --kid myKyberKey --input-file message.txt --output-file encrypted.dat
Ideal for: Automation, batch processing, and scripting.


5. Test with SDKs

For seamless application integration, SDKs are available.

Available SDKs

Example: Encrypt with Java SDK

import co.ankatech.ankasecure.sdk.AnkaSecureSdk;
import co.ankatech.ankasecure.sdk.exception.AnkaSecureSdkException;

public class ExampleEncryption {
    public static void main(String[] args) {
        AnkaSecureSdk sdk = new AnkaSecureSdk("yourClientId", "yourClientSecret");

        try {
            sdk.authenticateApplication("yourClientId", "yourClientSecret");

            String kid = "myKeyKid";
            String plaintext = "Hello AnkaSecure!";
            String encryptedData = sdk.encryptString(kid, plaintext);

            System.out.println("Encrypted: " + encryptedData);
        } catch (AnkaSecureSdkException e) {
            System.err.println("Error: " + e.getMessage());
        }
    }
}

Ideal for: Developers integrating cryptographic security into applications.


Common API Operations

🔐 Key Management

  • List Keys: GET /api/key-management/keys

  • Generate Key: POST /api/key-management/keys

  • Import Key: POST /api/key-management/keys/import

  • Revoke Key: POST /api/key-management/keys/{kid}/revoke

  • Export Key: GET /api/key-management/keys/{kid}

🔑 Cryptographic Operations

  • Encrypt: POST /api/crypto/encrypt

  • Decrypt: POST /api/crypto/decrypt

  • Sign Data: POST /api/crypto/sign

  • Verify Signature: POST /api/crypto/verify

  • Re-encrypt: POST /api/crypto/reencrypt

🔄 Streaming Operations

  • Encrypt (Streaming): POST /api/crypto/stream/encrypt

  • Decrypt (Streaming): POST /api/crypto/stream/decrypt

  • Sign (Streaming): POST /api/crypto/stream/sign

  • Verify (Streaming): POST /api/crypto/stream/verify

  • Re-encrypt (Streaming): POST /api/crypto/stream/reencrypt


📌 Conclusion

AnkaSecure provides multiple ways to test and interact with its cryptographic API, ensuring flexibility for different needs:

Swagger UI for quick interactive testing.

Postman for structured API workflows.

cURL for command-line integration.

AnkaSecure CLI for automated operations.

SDKs for smooth application integration.


🔗 Key Resources