Snelstartgids

Binnen enkele minuten aan de slag

Volg deze stapsgewijze handleiding om je eerste succesvolle API-aanroepen naar mindzieStudio te maken en procesmining-functionaliteiten in je applicaties te integreren.

Vereisten

  • API-gegevens: Toegangstoken, tenant ID en project ID
  • Basis-URL: De API-endpoint van jouw mindzie-instance
  • HTTPS-toegang: Beveiligde verbinding met jouw mindzie-instance
  • Ontwikkelomgeving: Je favoriete programmeertaal en HTTP-client

Geen gegevens? Bekijk de Authenticatiehandleiding om te leren hoe je toegang tot de API verkrijgt.

Stap 1: Test basisconnectiviteit

Begin met het testen van de basisconnectiviteit om zeker te zijn dat jouw mindzie-instance bereikbaar is:

curl -X GET "https://your-mindzie-instance.com/api/Action/ping"

Verwachte reactie:

{
  "status": "ok",
  "timestamp": "2024-01-15T10:30:00Z",
  "version": "1.0.0"
}

Stap 2: Verifieer authenticatie

Test je authenticatiegegevens met de geauthenticeerde ping-endpoint:

curl -X GET "https://your-mindzie-instance.com/api/Action/ping/authenticated" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "X-Tenant-Id: YOUR_TENANT_GUID" \
  -H "X-Project-Id: YOUR_PROJECT_GUID" \
  -H "Content-Type: application/json"

Verwachte reactie:

{
  "status": "authenticated",
  "timestamp": "2024-01-15T10:30:00Z",
  "tenantId": "12345678-1234-1234-1234-123456789012",
  "projectId": "87654321-4321-4321-4321-210987654321",
  "userId": "user@company.com",
  "permissions": ["read", "write", "admin"]
}

Stap 3: Je eerste API-aanroep

Laten we een praktische API-aanroep doen om de actieverleden op te halen:

curl -X GET "https://your-mindzie-instance.com/api/Action/history?limit=5" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "X-Tenant-Id: YOUR_TENANT_GUID" \
  -H "X-Project-Id: YOUR_PROJECT_GUID" \
  -H "Content-Type: application/json"

Voorbeeldantwoord:

{
  "actions": [
    {
      "actionId": "87654321-4321-4321-4321-210987654321",
      "actionType": "analyze",
      "status": "completed",
      "startTime": "2024-01-15T10:30:00Z",
      "endTime": "2024-01-15T10:32:15Z",
      "duration": 135,
      "userId": "user@company.com"
    }
  ],
  "pagination": {
    "currentPage": 1,
    "totalPages": 1,
    "totalItems": 1,
    "itemsPerPage": 5
  }
}

Taalspecifieke voorbeelden

JavaScript

Gebruik de fetch API of axios voor moderne webapplicaties en Node.js-backends.

Python

Gebruik de requests-bibliotheek voor datawetenschap-workflows en backend-automatisering.

C#/.NET

Gebruik HttpClient voor bedrijfsapplicaties en microservices.

JavaScript Voorbeeld

Volledig voorbeeld met moderne JavaScript en fetch API:

// Configuratie
const API_CONFIG = {
  baseURL: 'https://your-mindzie-instance.com/api',
  token: 'YOUR_ACCESS_TOKEN',
  tenantId: 'YOUR_TENANT_GUID',
  projectId: 'YOUR_PROJECT_GUID'
};

// Helperfunctie voor API-aanroepen
async function callMindzieAPI(endpoint, options = {}) {
  const url = `${API_CONFIG.baseURL}${endpoint}`;

  const defaultHeaders = {
    'Authorization': `Bearer ${API_CONFIG.token}`,
    'X-Tenant-Id': API_CONFIG.tenantId,
    'X-Project-Id': API_CONFIG.projectId,
    'Content-Type': 'application/json'
  };

  try {
    const response = await fetch(url, {
      ...options,
      headers: { ...defaultHeaders, ...options.headers }
    });

    if (!response.ok) {
      throw new Error(`HTTP ${response.status}: ${response.statusText}`);
    }

    return await response.json();
  } catch (error) {
    console.error('API-aanroep mislukt:', error);
    throw error;
  }
}

// Voorbeeldgebruik
async function quickStartExample() {
  try {
    // 1. Test connectiviteit
    console.log('Connectiviteit testen...');
    const pingResult = await callMindzieAPI('/Action/ping');
    console.log('Ping succesvol:', pingResult);

    // 2. Test authenticatie
    console.log('Authenticatie testen...');
    const authResult = await callMindzieAPI('/Action/ping/authenticated');
    console.log('Authenticatie succesvol:', authResult);

    // 3. Verkrijg actieverleden
    console.log('Actieverleden ophalen...');
    const history = await callMindzieAPI('/Action/history?limit=5');
    console.log('Actieverleden:', history);

    console.log('Snelstart succesvol afgerond!');
    return history;
  } catch (error) {
    console.error('Snelstart mislukt:', error);
    throw error;
  }
}

// Voer het voorbeeld uit
quickStartExample();

Python Voorbeeld

Volledig voorbeeld met de Python requests-bibliotheek:

import requests
import json
from typing import Dict, Any

class MindzieQuickStart:
    def __init__(self, base_url: str, token: str, tenant_id: str, project_id: str):
        self.base_url = base_url.rstrip('/')
        self.headers = {
            'Authorization': f'Bearer {token}',
            'X-Tenant-Id': tenant_id,
            'X-Project-Id': project_id,
            'Content-Type': 'application/json'
        }

    def call_api(self, endpoint: str, method: str = 'GET', **kwargs) -> Dict[str, Any]:
        """Doe een API-aanroep naar mindzie"""
        url = f"{self.base_url}{endpoint}"

        try:
            response = requests.request(
                method=method,
                url=url,
                headers=self.headers,
                **kwargs
            )
            response.raise_for_status()
            return response.json()
        except requests.exceptions.RequestException as e:
            print(f"API-aanroep mislukt: {e}")
            raise

    def run_quick_start(self):
        """Voer de snelstartsequentie uit"""
        print("Starten met mindzie API Snelstart...")

        try:
            # 1. Test connectiviteit
            print("1. Connectiviteit testen...")
            ping_result = requests.get(f"{self.base_url}/api/Action/ping")
            ping_result.raise_for_status()
            print(f"   Connectiviteit OK: {ping_result.json()}")

            # 2. Test authenticatie
            print("2. Authenticatie testen...")
            auth_result = self.call_api('/api/Action/ping/authenticated')
            print(f"   Authenticatie OK: {auth_result['status']}")

            # 3. Verkrijg actieverleden
            print("3. Actieverleden ophalen...")
            history = self.call_api('/api/Action/history?limit=5')
            print(f"   {len(history['actions'])} acties opgehaald")

            print("Snelstart succesvol afgerond!")
            return history

        except Exception as e:
            print(f"Snelstart mislukt: {e}")
            raise

# Voorbeeldgebruik
if __name__ == "__main__":
    # Configureer je gegevens
    quick_start = MindzieQuickStart(
        base_url='https://your-mindzie-instance.com/api',
        token='YOUR_ACCESS_TOKEN',
        tenant_id='YOUR_TENANT_GUID',
        project_id='YOUR_PROJECT_GUID'
    )

    # Voer de snelstart uit
    result = quick_start.run_quick_start()
    print(f"Definitief resultaat: {json.dumps(result, indent=2)}")

C#/.NET Voorbeeld

Volledig voorbeeld met C# HttpClient:

using System;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;

public class MindzieQuickStart
{
    private readonly HttpClient _httpClient;
    private readonly string _baseUrl;

    public MindzieQuickStart(string baseUrl, string token, string tenantId, string projectId)
    {
        _baseUrl = baseUrl.TrimEnd('/');

        _httpClient = new HttpClient();
        _httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");
        _httpClient.DefaultRequestHeaders.Add("X-Tenant-Id", tenantId);
        _httpClient.DefaultRequestHeaders.Add("X-Project-Id", projectId);
    }

    public async Task<T> CallApiAsync<T>(string endpoint)
    {
        try
        {
            var response = await _httpClient.GetAsync($"{_baseUrl}{endpoint}");
            response.EnsureSuccessStatusCode();

            var content = await response.Content.ReadAsStringAsync();
            return JsonSerializer.Deserialize<T>(content, new JsonSerializerOptions
            {
                PropertyNameCaseInsensitive = true
            });
        }
        catch (HttpRequestException ex)
        {
            Console.WriteLine($"API-aanroep mislukt: {ex.Message}");
            throw;
        }
    }

    public async Task RunQuickStartAsync()
    {
        Console.WriteLine("Starten met mindzie API Snelstart...");

        try
        {
            // 1. Test connectiviteit
            Console.WriteLine("1. Connectiviteit testen...");
            using var pingClient = new HttpClient();
            var pingResponse = await pingClient.GetAsync($"{_baseUrl}/api/Action/ping");
            pingResponse.EnsureSuccessStatusCode();
            Console.WriteLine("   Connectiviteit OK");

            // 2. Test authenticatie
            Console.WriteLine("2. Authenticatie testen...");
            var authResult = await CallApiAsync<AuthResponse>("/api/Action/ping/authenticated");
            Console.WriteLine($"   Authenticatie OK: {authResult.Status}");

            // 3. Verkrijg actieverleden
            Console.WriteLine("3. Actieverleden ophalen...");
            var history = await CallApiAsync<ActionHistoryResponse>("/api/Action/history?limit=5");
            Console.WriteLine($"   {history.Actions.Length} acties opgehaald");

            Console.WriteLine("Snelstart succesvol afgerond!");
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Snelstart mislukt: {ex.Message}");
            throw;
        }
    }

    public void Dispose()
    {
        _httpClient?.Dispose();
    }
}

// Datamodellen
public class AuthResponse
{
    public string Status { get; set; }
    public string TenantId { get; set; }
    public string ProjectId { get; set; }
    public string UserId { get; set; }
}

public class ActionHistoryResponse
{
    public ActionItem[] Actions { get; set; }
    public PaginationInfo Pagination { get; set; }
}

public class ActionItem
{
    public string ActionId { get; set; }
    public string ActionType { get; set; }
    public string Status { get; set; }
    public DateTime StartTime { get; set; }
    public DateTime? EndTime { get; set; }
}

public class PaginationInfo
{
    public int CurrentPage { get; set; }
    public int TotalPages { get; set; }
    public int TotalItems { get; set; }
}

// Gebruik
class Program
{
    static async Task Main(string[] args)
    {
        var quickStart = new MindzieQuickStart(
            "https://your-mindzie-instance.com/api",
            "YOUR_ACCESS_TOKEN",
            "YOUR_TENANT_GUID",
            "YOUR_PROJECT_GUID"
        );

        try
        {
            await quickStart.RunQuickStartAsync();
        }
        finally
        {
            quickStart.Dispose();
        }
    }
}

Veelvoorkomende problemen & oplossingen

Authenticatiefouten

  • 401 Unauthorized: Controleer of je toegangstoken correct is en niet verlopen
  • 403 Forbidden: Controleer tenant/project-ID’s en gebruikersrechten
  • 400 Bad Request: Zorg dat alle vereiste headers zijn inbegrepen

Verbindingsproblemen

  • Netwerk time-outs: Controleer firewall-instellingen en netwerkconnectiviteit
  • SSL/TLS-fouten: Controleer certificaatgeldigheid en HTTPS-configuratie
  • DNS-resolutie: Bevestig dat de URL van de mindzie-instance juist is

Verzoeklimieten

  • 429 Too Many Requests: Implementeer een exponentiële backoff retry-logica
  • Controleer limieten: Bekijk de response-headers voor limietinformatie
  • Optimaliseer verzoeken: Gebruik paginering en filtering om API-aanroepen te verminderen

Volgende stappen

Gefeliciteerd! Je hebt de mindzieAPI snelstart succesvol voltooid. Verken vervolgens de Actions API of Blocks API om krachtige integraties te bouwen.