API Connection

The API Connection feature in the Scorport Connection Module allows users to integrate external APIs into their strategies, enabling real-time data exchange and enhanced decision-making. This page explains how to configure an API connection, including the use of mock data for testing when real API access is unavailable.


Steps to Add an API Connection

Step 1: Create a New API Connection
  1. Open the Connection Designer module from your dashboard.
  2. Click Create New Connection and choose API as the connection type.
  3. Enter a Connection Name (e.g., "TestConnection") for easy identification.

image.png


Step 2: Configure the API
  1. Choose the Method:

    • Select the HTTP method: GET or POST.
    • This determines how the data will be sent or received.
  2. Enter the API URL:

    • Add the API URL (e.g., https://TestAPI/CB) in the URL field.
  3. Add Query Parameters and Path Parameters:

    • Query Params:
      • Define the key-value pairs to be appended to the URL as query strings.
      • Example: ?key=value.
    • Path Params:
      • Define the key-value pairs that form part of the URL path.
      • Example: /api/{key} where key is replaced by the value.
  4. Set Up Headers:

    • Add headers required for the API, such as Authorization or Content-Type.
    • Example: Authorization: Bearer {token}.
  5. Add Payload (For POST Requests):

    • Define the JSON body to be sent with the request.
    • Example:
      json

      { "key": "value" }
  6. Create Mock Data:

    • If real API access is unavailable, define mock responses for testing:
      • Mockup: Provide a simulated response to mimic real API behavior.

Step 3: Test the Connection
  1. Click the Test button to validate the API connection.
    • If using mock data, the system will display the mock response.
    • If real API access is available, the system will return the actual API response.
  2. Debug and refine any configurations as needed.

image.png


Step 4: Save the Connection
  1. After successful testing, click Save to store the connection.
  2. Pre-define the request parameters (GET or POST) to ensure consistency.
  3. Note: The URL can only be modified to the real API endpoint after the engine has been fully tested and validated.

Example: API Integration with Mock Data

Scenario: Testing a Credit Score API
  1. Connection Name: CreditScoreAPI.
  2. URL: https://api.creditscore.com/getScore.
  3. Method: GET.
  4. Query Params:
    • key: user_id.
    • value: 12345.
  5. Headers:
    • Authorization: Bearer test_token.
    • Content-Type: application/json.
  6. Mockup Response:
    • json

      { "credit_score": 750, "status": "success" }

Best Practices for API Connections

  1. Use Mock Data:
    • When API access is unavailable, mock data allows for testing the strategy workflow without real responses.
  2. Validate Before Saving:
    • Always test the connection to ensure parameters, headers, and payloads are correctly configured.
  3. Update URLs After Testing:
    • Replace the mock URL with the real API endpoint once the engine is ready for production.

Benefits of API Connections

  1. Real-Time Data:
    • Enhance strategies with dynamic, up-to-date information from external sources.
  2. Mock Testing:
    • Ensure strategy accuracy without relying on live API access.
  3. Seamless Integration:
    • Easily incorporate external services into your decision-making workflows.

The API Connection feature in Scorport empowers users to integrate external systems dynamically, ensuring robust and adaptable strategies.