This directory contains example scripts demonstrating how to use the DataSpace Python SDK.
-
Install the SDK:
pip install dataspace-sdk # or for development pip install -e .. -
Get a Keycloak token from your DataSpace instance
-
Update the examples with:
- Your API base URL
- Your Keycloak token
Demonstrates basic SDK operations:
- Login with Keycloak
- Search datasets, AI models, and use cases
- Display results
Run:
python basic_usage.pyShows how to work with organization-specific resources:
- Get user's organizations
- Fetch datasets, models, and use cases for each organization
- Display organization statistics
Run:
python organization_resources.pyDemonstrates advanced search capabilities:
- Complex filters (tags, sectors, geographies, status)
- Multiple search parameters
- Pagination
- Fetching all results
Run:
python advanced_search.pyShows proper error handling:
- Custom exception handling
- Token refresh on authentication errors
- Network error handling
- Graceful degradation
Run:
python error_handling.pyBefore running the examples, update these variables:
# API base URL
base_url = "https://api.dataspace.example.com"
# Your Keycloak token
keycloak_token = "your_keycloak_token_here"
# Resource IDs (for get_by_id operations)
dataset_id = "your-dataset-uuid"
model_id = "your-model-uuid"
usecase_id = 123 # Use case IDIf you get authentication errors:
- Verify your Keycloak token is valid
- Check if the token has expired
- Ensure you have the correct base URL
If you can't connect to the API:
- Verify the base URL is correct
- Check if the API is running
- Verify network connectivity
If resources are not found:
- Verify the resource ID is correct
- Check if you have permission to access the resource
- Ensure the resource exists in the system
- Read the full documentation
- Check the development guide
- Review the quick start guide
