Spaces:
Runtime error
Runtime error
| ### Credily API - Make Predictions from External Data Sources | |
| ### Use with VS Code REST Client, Insomnia, or Postman | |
| @baseUrl = http://localhost:8000 | |
| @model_path = C:/credily/models/credit_model.pkl | |
| ############################################################################### | |
| ### 1. PREDICT FROM PostgreSQL DATABASE | |
| ############################################################################### | |
| POST {{baseUrl}}/api/predict-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 FROM new_loan_applications WHERE processed = false" | |
| }, | |
| "model_path": "{{model_path}}", | |
| "include_proba": true, | |
| "save_results": true | |
| } | |
| ############################################################################### | |
| ### 2. PREDICT FROM REST API | |
| ############################################################################### | |
| POST {{baseUrl}}/api/predict-from-source | |
| Content-Type: application/json | |
| { | |
| "data_source": { | |
| "source_type": "api", | |
| "url": "https://api.example.com/v1/pending-applications", | |
| "method": "GET", | |
| "headers": { | |
| "Accept": "application/json" | |
| }, | |
| "auth": { | |
| "type": "bearer", | |
| "token": "your-api-token" | |
| }, | |
| "json_path": "data.applications" | |
| }, | |
| "model_path": "{{model_path}}", | |
| "threshold": 0.45, | |
| "include_proba": true, | |
| "save_results": true | |
| } | |
| ############################################################################### | |
| ### 3. PREDICT FROM GraphQL ENDPOINT | |
| ############################################################################### | |
| POST {{baseUrl}}/api/predict-from-source | |
| Content-Type: application/json | |
| { | |
| "data_source": { | |
| "source_type": "graphql", | |
| "url": "https://api.example.com/graphql", | |
| "graphql_query": "query GetPendingApplications($status: String!) { loanApplications(status: $status) { id age income creditScore loanAmount } }", | |
| "graphql_variables": { | |
| "status": "pending_review" | |
| }, | |
| "headers": { | |
| "Authorization": "Bearer your-token" | |
| }, | |
| "json_path": "data.loanApplications" | |
| }, | |
| "model_path": "{{model_path}}", | |
| "include_proba": true | |
| } | |
| ############################################################################### | |
| ### 4. PREDICT FROM MongoDB | |
| ############################################################################### | |
| POST {{baseUrl}}/api/predict-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\": \"pending_applications\", \"query\": {\"status\": \"pending\"}}" | |
| }, | |
| "model_path": "{{model_path}}", | |
| "save_results": true | |
| } | |
| ############################################################################### | |
| ### 5. PREDICT FROM CSV FILE URL | |
| ############################################################################### | |
| POST {{baseUrl}}/api/predict-from-source | |
| Content-Type: application/json | |
| { | |
| "data_source": { | |
| "source_type": "url", | |
| "url": "https://storage.example.com/predictions/pending_loans.csv", | |
| "format": "csv" | |
| }, | |
| "model_path": "{{model_path}}", | |
| "threshold": 0.5, | |
| "include_proba": true, | |
| "save_results": true | |
| } | |
| ############################################################################### | |
| ### 6. PREDICT WITH CUSTOM THRESHOLD | |
| ############################################################################### | |
| POST {{baseUrl}}/api/predict-from-source | |
| Content-Type: application/json | |
| { | |
| "data_source": { | |
| "source_type": "api", | |
| "url": "https://api.example.com/v1/applications-to-score", | |
| "auth": { | |
| "type": "bearer", | |
| "token": "token" | |
| }, | |
| "json_path": "data" | |
| }, | |
| "model_path": "{{model_path}}", | |
| "threshold": 0.35, | |
| "include_proba": true, | |
| "save_results": true | |
| } | |