### Credily API - Train from External Data Sources ### Use with VS Code REST Client, Insomnia, or Postman ### Replace localhost:8000 with your Credily API server address @baseUrl = http://localhost:8000 @model_path = C:/credily/models/credit_model.pkl ############################################################################### ### 1. TRAIN FROM PostgreSQL DATABASE ############################################################################### POST {{baseUrl}}/api/train-from-source Content-Type: application/json { "data_source": { "source_type": "database", "database_type": "postgres", "connection_string": "postgresql://user:password@localhost:5432/credit_db", "query": "SELECT age, income, credit_score, loan_amount, debt_to_income, default FROM credit_applications WHERE created_at >= '2024-01-01' LIMIT 10000" }, "config": { "target_column": "default", "test_size": 0.2, "balance_data": true, "clean_data": true, "optimize_threshold": true }, "model_name": "credit_model_postgres_2024" } ############################################################################### ### 2. TRAIN FROM MySQL DATABASE ############################################################################### POST {{baseUrl}}/api/train-from-source Content-Type: application/json { "data_source": { "source_type": "database", "database_type": "mysql", "connection_string": "mysql://user:password@localhost:3306/credit_db", "query": "SELECT * FROM loan_applications WHERE status = 'processed' AND approved_date >= DATE_SUB(NOW(), INTERVAL 6 MONTH)" }, "config": { "target_column": "default", "balance_data": true } } ############################################################################### ### 3. TRAIN FROM MongoDB ############################################################################### POST {{baseUrl}}/api/train-from-source Content-Type: application/json { "data_source": { "source_type": "database", "database_type": "mongodb", "connection_string": "mongodb://user:password@localhost:27017/", "query": "{\"database\": \"credit_db\", \"collection\": \"applications\", \"query\": {\"status\": \"processed\"}}" }, "config": { "target_column": "default" } } ############################################################################### ### 4. TRAIN FROM MongoDB with Aggregation Pipeline ############################################################################### POST {{baseUrl}}/api/train-from-source Content-Type: application/json { "data_source": { "source_type": "database", "database_type": "mongodb", "connection_string": "mongodb://user:password@localhost:27017/", "query": "{\"database\": \"credit_db\", \"collection\": \"applications\", \"pipeline\": [{\"$match\": {\"status\": \"processed\"}}, {\"$limit\": 5000}]}" }, "config": { "target_column": "default", "balance_data": true } } ############################################################################### ### 5. TRAIN FROM REST API (JSON Response) ############################################################################### POST {{baseUrl}}/api/train-from-source Content-Type: application/json { "data_source": { "source_type": "api", "url": "https://api.example.com/v1/credit-data", "method": "GET", "headers": { "Accept": "application/json", "User-Agent": "Credily/1.0" }, "auth": { "type": "bearer", "token": "your-api-token-here" }, "params": { "status": "approved", "limit": "5000" }, "json_path": "data.records" }, "config": { "target_column": "default", "test_size": 0.2 } } ############################################################################### ### 6. TRAIN FROM REST API with POST Body ############################################################################### POST {{baseUrl}}/api/train-from-source Content-Type: application/json { "data_source": { "source_type": "api", "url": "https://api.example.com/v1/query", "method": "POST", "headers": { "Content-Type": "application/json", "Authorization": "Bearer your-token" }, "body": { "filters": { "date_range": { "start": "2024-01-01", "end": "2024-12-31" }, "status": "approved", "min_loan_amount": 5000 }, "fields": ["age", "income", "credit_score", "loan_amount", "default"], "limit": 10000 }, "json_path": "result.data" }, "config": { "target_column": "default", "balance_data": true }, "model_name": "api_model_2024" } ############################################################################### ### 7. TRAIN FROM GraphQL API ############################################################################### POST {{baseUrl}}/api/train-from-source Content-Type: application/json { "data_source": { "source_type": "graphql", "url": "https://api.example.com/graphql", "graphql_query": "query GetCreditApplications($status: String!, $limit: Int!) { creditApplications(status: $status, limit: $limit) { age income creditScore loanAmount default } }", "graphql_variables": { "status": "processed", "limit": 5000 }, "headers": { "Authorization": "Bearer your-graphql-token" }, "json_path": "data.creditApplications" }, "config": { "target_column": "default" } } ############################################################################### ### 8. TRAIN FROM CSV FILE URL ############################################################################### POST {{baseUrl}}/api/train-from-source Content-Type: application/json { "data_source": { "source_type": "url", "url": "https://storage.example.com/datasets/credit_data_2024.csv", "format": "csv" }, "config": { "target_column": "default", "balance_data": true } } ############################################################################### ### 9. TRAIN FROM Excel FILE URL ############################################################################### POST {{baseUrl}}/api/train-from-source Content-Type: application/json { "data_source": { "source_type": "url", "url": "https://storage.example.com/datasets/credit_data.xlsx", "format": "excel" }, "config": { "target_column": "default" } } ############################################################################### ### 10. VALIDATE DATA SOURCE (Test Connection) ############################################################################### POST {{baseUrl}}/api/validate-data-source Content-Type: application/json { "source_type": "database", "database_type": "postgres", "connection_string": "postgresql://user:password@localhost:5432/credit_db", "query": "SELECT age, income, credit_score, default FROM credit_applications LIMIT 10" } ############################################################################### ### 11. VALIDATE API DATA SOURCE ############################################################################### POST {{baseUrl}}/api/validate-data-source Content-Type: application/json { "source_type": "api", "url": "https://api.example.com/v1/credit-data", "method": "GET", "auth": { "type": "bearer", "token": "test-token" }, "json_path": "data.records" }