mindsdb
1openapi: 3.0.02info:3title: MindsDB API4description: >-5OpenAPI Specification for MindsDB's REST API. Each API Endpoint corresponds
6to a specific SQL Statement e.g POST /model => CREATE MODEL7version: 0.0.18contact:9email: admin@mindsdb.com10license:11name: GNU General Public License v3.012url: 'https://github.com/mindsdb/mindsdb/blob/staging/LICENSE'13servers:14- url: 'http://127.0.0.1:47334/v1/api'15description: MindsDB local deployments16components:17schemas:18Database:19type: object20properties:21name:22type: string23engine:24type: string25description: Handler used to create this database (e.g. postgres)26type:27type: string28description: Type of database (data | project | system)29Model:30type: object31properties:32name:33type: string34accuracy:35type: number36description: Accuracy of trained model between 0 and 137active:38type: boolean39description: Whether or not this model is currently the active version40version:41type: number42description: Version of this model43status:44type: string45description: Current status of this model (generating | creating | complete | error)46predict:47type: string48description: Column name that this model predicts49mindsdb_version:50type: string51description: MindsDB version associated with this model52error:53type: string54description: Error encountered during training, if applicable55fetch_data_query:56type: string57description: SQL query used to fetch training data for this model58created_at:59type: string60description: Time model was created at in YYYY-MM-DD HH:MM:SS format (trained models only)61training_time:62type: string63description: How long training this model took in HH:MM:SS format (trained models only)64update:65type: string66description: Set to "available" when a new version of MindsDB is available that makes the model obsolete, or when new data is available in the data that was used to train the model (trained models only).67
68Project:69type: object70properties:71name:72type: string73
74Table:75type: object76properties:77name:78type: string79type:80type: string81description: Type of table (data | view)82
83View:84type: object85properties:86name:87type: string88query:89type: string90description: SELECT query used to create the view91paths:92'/api/databases':93get:94security:95- ApiKeyAuth: []96summary: Returns a list of database names.97description: Gets all databases created by the user.98responses:99'200':100description: A JSON array of database names101content:102application/json:103schema:104type: array105items:106$ref: '#/components/schemas/Database'107
108'401':109description: Invalid API key error message110content:111application/json:112schema:113type: object114items:115type: string116'500':117description: Server error118content:119application/json:120schema:121type: object122items:123type: string124post:125security:126- ApiKeyAuth: []127summary: Creates a new database connection.128description: Creates a new database connection. The example parameters below are for connecting to [MySQL](/data-integrations/mysql). See [here](/data-integrations/all-data-integrations) for which parameters to use for your datasource.129requestBody:130required: true131content:132application/json:133schema:134type: object135properties:136database:137type: object138properties:139name:140type: string141engine:142type: string143parameters:144type: object145description: Parameters used to connect to your data source. These example parameters are for connecting to [MySQL](/data-integrations/mysql). See [here](/data-integrations/all-data-integrations) for which parameters to use for your datasource.146properties:147user:148type: string149password:150type: string151host:152type: string153port:154type: string155database:156type: string157responses:158# OpenAPI spec defines '200' status as a successful operation, so even though the159# response code is '201', we need to use '200' so docs are properly generated.160'200':161description: The created database162content:163application/json:164schema:165$ref: '#/components/schemas/Database'166'401':167description: Invalid API key error message168content:169application/json:170schema:171type: object172items:173type: string174'400':175description: Bad request format176content:177application/json:178schema:179type: object180items:181type: string182'409':183description: Database already exists184content:185application/json:186schema:187type: object188items:189type: string190'500':191description: Server error192content:193application/json:194schema:195type: object196items:197type: string198
199'/api/databases/{databaseName}':200get:201security:202- ApiKeyAuth: []203summary: Gets info about existing database.204description: Gets info about an existing database.205parameters:206- name: databaseName207in: path208description: Name of existing database209required: true210schema:211type: string212responses:213'200':214description: A JSON object with database informations215content:216application/json:217schema:218$ref: '#/components/schemas/Database'219
220'401':221description: Invalid API key error message222content:223application/json:224schema:225type: object226items:227type: string228'404':229description: Database not found230content:231application/json:232schema:233type: object234items:235type: string236'500':237description: Server error238content:239application/json:240schema:241type: object242items:243type: string244
245put:246security:247- ApiKeyAuth: []248summary: Updates an existing database connection.249description: Updates an existing database connection, or creates a new connection if one doesn't exist. The example parameters below are for updating a [MySQL](/data-integrations/mysql) connection. See [here](/data-integrations/all-data-integrations) for which parameters to use for your datasource.250parameters:251- name: databaseName252in: path253description: The name of the project254required: true255schema:256type: string257requestBody:258required: true259content:260application/json:261schema:262type: object263properties:264database:265type: object266properties:267engine:268type: string269parameters:270type: object271description: Parameters used to connect to your data source. These example parameters are for connecting to [MySQL](/data-integrations/mysql). See [here](/data-integrations/all-data-integrations) for which parameters to use for your datasource.272properties:273user:274type: string275password:276type: string277host:278type: string279port:280type: string281database:282type: string283responses:284'200':285description: Database was successfully updated286content:287application/json:288schema:289$ref: '#/components/schemas/Database'290'400':291description: Bad request format292content:293application/json:294schema:295type: object296items:297type: string298'401':299description: Invalid API key error message300content:301application/json:302schema:303type: object304items:305type: string306'500':307description: Server error308content:309application/json:310schema:311type: object312items:313type: string314delete:315security:316- ApiKeyAuth: []317summary: Deletes an existing database.318description: Deletes an existing database connection by name.319parameters:320- name: databaseName321in: path322description: Name of existing database to delete323required: true324schema:325type: string326responses:327'200':328description: An empty response indicates success329content:330application/json:331schema:332type: string333'401':334description: Invalid API key error message335content:336application/json:337schema:338type: object339items:340type: string341'404':342description: Database not found343content:344application/json:345schema:346type: object347items:348type: string349'500':350description: Server error351content:352application/json:353schema:354type: object355items:356type: string357'/api/projects':358get:359security:360- ApiKeyAuth: []361summary: Returns a list of projects.362description: Gets all projects created by the user.363responses:364'200':365description: A JSON array of projects366content:367application/json:368schema:369type: array370items:371$ref: '#/components/schemas/Project'372'401':373description: Invalid API key error message374content:375application/json:376schema:377type: object378items:379type: string380'500':381description: Server error382content:383application/json:384schema:385type: object386items:387type: string388'/api/projects/{projectName}':389get:390security:391- ApiKeyAuth: []392summary: Get a project by name.393description: Gets a project created by the user.394parameters:395- name: projectName396in: path397description: The name of the project398required: true399schema:400type: string401responses:402'200':403description: The returned project404content:405application/json:406schema:407$ref: '#/components/schemas/Project'408'401':409description: Invalid API key error message410content:411application/json:412schema:413type: object414items:415type: string416'404':417description: Project not found418content:419application/json:420schema:421type: object422items:423type: string424'500':425description: Server error426content:427application/json:428schema:429type: object430items:431type: string432
433'/api/projects/{projectName}/models':434post:435security:436- ApiKeyAuth: []437summary: This endpoint trains a new ML Model.438description: Starts training a new Machine Learning model.439parameters:440- name: projectName441in: path442description: The name of the project443required: true444schema:445type: string446requestBody:447required: true448content:449application/json:450schema:451type: object452properties:453query:454type: string455description: The SQL CREATE MODEL statement used to train this model. See the [CREATE MODEL](https://docs.mindsdb.com/sql/create/model) statement456responses:457'200':458description: Model training started459content:460application/json:461schema:462$ref: '#/components/schemas/Model'463'400':464description: Bad request465content:466application/json:467schema:468type: object469items:470type: string471'401':472description: Invalid API key error message473content:474application/json:475schema:476type: object477items:478type: string479'404':480description: Project not found481content:482application/json:483schema:484type: object485items:486type: string487'500':488description: Server error489content:490application/json:491schema:492type: object493items:494type: string495get:496security:497- ApiKeyAuth: []498summary: Returns a list of models.499description: Gets info about all models in the project.500parameters:501- name: projectName502in: path503description: The name of the project504required: true505schema:506type: string507responses:508'200':509description: A JSON array of models names510content:511application/json:512schema:513type: array514items:515$ref: '#/components/schemas/Model'516'401':517description: Invalid API key error message518content:519application/json:520schema:521type: object522items:523type: string524'404':525description: Project not found526content:527application/json:528schema:529type: object530items:531type: string532'500':533description: Server error534content:535application/json:536schema:537type: object538items:539type: string540'/api/projects/{projectName}/models/{modelName}':541get:542security:543- ApiKeyAuth: []544summary: Gets info about specific model.545description: Gets info for a specific model in the project.546parameters:547- name: projectName548in: path549description: The name of the project550required: true551schema:552type: string553- name: modelName554in: path555description: The name of the model556required: true557schema:558type: string559responses:560'200':561description: Model information562content:563application/json:564schema:565$ref: '#/components/schemas/Model'566'401':567description: Invalid API key error message568content:569application/json:570schema:571type: object572items:573type: string574'404':575description: Model not found576content:577application/json:578schema:579type: object580items:581type: string582'500':583description: Server error584content:585application/json:586schema:587type: object588items:589type: string590delete:591security:592- ApiKeyAuth: []593summary: Deletes an existing model.594description: Deletes a model in the project.595parameters:596- name: projectName597in: path598description: The name of the project599required: true600schema:601type: string602- name: modelName603in: path604description: The name of the model605required: true606schema:607type: string608responses:609'200':610description: Empty response if delete is successful611content:612application/json:613schema:614type: string615'401':616description: Invalid API key error message617content:618application/json:619schema:620type: object621items:622type: string623'404':624description: Project or model not found625content:626application/json:627schema:628type: object629items:630type: string631'500':632description: Server error633content:634application/json:635schema:636type: object637items:638type: string639'/api/projects/{projectName}/models/{modelName}/predict':640post:641security:642- ApiKeyAuth: []643summary: This endpoint fetches predictions from the model.644description: Uses this model to make a prediction for values of new data.645parameters:646- name: projectName647in: path648description: The name of the project649required: true650schema:651type: string652- name: modelName653in: path654description: The name of the model655required: true656schema:657type: string658requestBody:659required: true660content:661application/json:662schema:663type: array664properties:665data:666type: object667description: The data for querying the model as key/value e.g column name/value. Example with [home rental prices](https://docs.mindsdb.com/sql/tutorials/home-rentals) - [{"sqft":823}]668responses:669'200':670description: Model queried succesfully671content:672application/json:673schema:674type: object675items:676type: string677description: Prediction object that contains data columns and the target value, confidence, lower and upper bound.678'401':679description: Invalid API key error message680content:681application/json:682schema:683type: object684items:685type: string686'404':687description: Project or model not found688content:689application/json:690schema:691type: object692items:693type: string694'500':695description: Server error696content:697application/json:698schema:699type: object700items:701type: string702'/api/projects/{projectName}/models/{modelName}/describe':703get:704security:705- ApiKeyAuth: []706summary: Describe a model707description: Gets the attributes of a specific model.708parameters:709- name: projectName710in: path711description: The name of the project712required: true713schema:714type: string715- name: modelName716in: path717description: The name of the model718required: true719schema:720type: string721requestBody:722content:723application/json:724schema:725type: object726properties:727attribute:728type: string729description: Attribute of the model to describe. See our [DESCRIBE documentation](https://docs.mindsdb.com/sql/api/describe). E.g. info, features, model730
731responses:732'200':733description: A JSON object with model informations734content:735application/json:736schema:737type: object738items:739type: string740description: Array containing model information741'401':742description: Invalid API key error message743content:744application/json:745schema:746type: object747items:748type: string749'404':750description: Model not found751content:752application/json:753schema:754type: object755items:756type: string757'500':758description: Server error759content:760application/json:761schema:762type: object763items:764type: string765'/api/projects/{projectName}/views':766post:767security:768- ApiKeyAuth: []769summary: This endpoint creates a view which is a result-set of the SELECT statement.770description: Creates a [view](https://docs.mindsdb.com/sql/create/view) from a SELECT statement.771parameters:772- name: projectName773in: path774description: The name of the project775required: true776schema:777type: string778requestBody:779required: true780content:781application/json:782schema:783type: object784properties:785view:786type: object787properties:788name:789type: string790description: Name of the view791query:792type: string793description: The SQL query that will save the result-set in a view.794responses:795'200':796description: View created797content:798application/json:799schema:800type: array801items:802$ref: '#/components/schemas/View'803'401':804description: Invalid API key error message805content:806application/json:807schema:808type: object809items:810type: string811'404':812description: Project not found813content:814application/json:815schema:816type: object817items:818type: string819'500':820description: Server error821content:822application/json:823schema:824type: object825items:826type: string827get:828security:829- ApiKeyAuth: []830summary: List all views in a project831description: Gets all views in a project.832parameters:833- name: projectName834in: path835description: The name of the project836required: true837schema:838type: string839responses:840'200':841description: A JSON object with view names842content:843application/json:844schema:845type: array846items:847$ref: '#/components/schemas/View'848'401':849description: Invalid API key error message850content:851application/json:852schema:853type: object854items:855type: string856'404':857description: Project not found858content:859application/json:860schema:861type: object862items:863type: string864'500':865description: Server error866content:867application/json:868schema:869type: object870items:871type: string872'/api/projects/{projectName}/views/{viewName}':873get:874security:875- ApiKeyAuth: []876summary: SELECT from VIEW877description: Gets a single view.878parameters:879- name: projectName880in: path881description: The name of the project882required: true883schema:884type: string885- name: viewName886in: path887description: The name of the view888required: true889schema:890type: string891responses:892'200':893description: A JSON object with VIEW data894content:895application/json:896schema:897$ref: '#/components/schemas/View'898'401':899description: Invalid API key error message900content:901application/json:902schema:903type: object904items:905type: string906'404':907description: View or project not found908content:909application/json:910schema:911type: object912items:913type: string914'500':915description: Server error916content:917application/json:918schema:919type: object920items:921type: string922delete:923security:924- ApiKeyAuth: []925summary: Deletes an existing view.926description: Deletes an existing view in the project.927parameters:928- name: projectName929in: path930description: Project name the view is in931required: true932schema:933type: string934- name: viewName935in: path936description: View name to delete937required: true938schema:939type: string940responses:941'200':942description: Succesfully deleted943content:944application/json:945schema:946type: object947items:948type: string949'401':950description: Invalid API key error message951content:952application/json:953schema:954type: object955items:956type: string957'404':958description: View or projectnot found959content:960application/json:961schema:962type: object963items:964type: string965'500':966description: Server error967content:968application/json:969schema:970type: object971items:972type: string973put:974security:975- ApiKeyAuth: []976summary: Updates an existing view.977description: Updates an existing view, or creates a new view if one doesn't exist.978parameters:979- name: projectName980in: path981description: The name of the project982required: true983schema:984type: string985- name: viewName986in: path987description: The name of the view988required: true989schema:990type: string991requestBody:992required: true993content:994application/json:995schema:996type: object997properties:998view:999type: object1000properties:1001name:1002type: string1003description: Name of the view1004query:1005type: string1006description: The SQL query that will save the result-set in a view.1007responses:1008'200':1009description: View was successfully updated1010content:1011application/json:1012schema:1013$ref: '#/components/schemas/View'1014'400':1015description: Bad request format1016content:1017application/json:1018schema:1019type: object1020items:1021type: string1022'401':1023description: Invalid API key error message1024content:1025application/json:1026schema:1027type: object1028items:1029type: string1030'500':1031description: Server error1032content:1033application/json:1034schema:1035type: object1036items:1037type: string1038'/api/databases/{databaseName}/tables':1039post:1040security:1041- ApiKeyAuth: []1042summary: This endpoint creates a new table with the predictions result-set.1043description: Creates a new table from a select query. See [CREATE table documentation](https://docs.mindsdb.com/sql/create/table).1044parameters:1045- name: databaseName1046in: path1047description: Name of the database1048required: true1049schema:1050type: string1051requestBody:1052required: true1053content:1054application/json:1055schema:1056type: object1057properties:1058table:1059type: object1060properties:1061name:1062type: string1063select:1064type: string1065description: SELECT statement to create the table from1066replace:1067type: boolean1068description: Whether or not to delete a pre-existing table before creating it1069responses:1070'200':1071description: Table created1072content:1073application/json:1074schema:1075$ref: '#/components/schemas/Table'1076'401':1077description: Invalid API key error message1078content:1079application/json:1080schema:1081type: object1082items:1083type: string1084'404':1085description: Database not found1086content:1087application/json:1088schema:1089type: object1090items:1091type: string1092'500':1093description: Server error1094content:1095application/json:1096schema:1097type: object1098items:1099type: string1100
1101get:1102security:1103- ApiKeyAuth: []1104summary: Returns a list of tables in a database.1105description: Gets metadata for all tables in a database.1106parameters:1107- name: databaseName1108in: path1109description: The name of the database1110required: true1111schema:1112type: string1113responses:1114'200':1115description: A JSON array of tables1116content:1117application/json:1118schema:1119type: array1120items:1121$ref: '#/components/schemas/Table'1122'401':1123description: Invalid API key error message1124content:1125application/json:1126schema:1127type: object1128items:1129type: string1130'404':1131description: Database not found1132content:1133application/json:1134schema:1135type: object1136items:1137type: string1138'500':1139description: Server error1140content:1141application/json:1142schema:1143type: object1144items:1145type: string1146'/api/databases/{databaseName}/tables/{tableName}':1147get:1148security:1149- ApiKeyAuth: []1150summary: SELECT from Table1151description: Gets metadata for a table in a database.1152parameters:1153- name: databaseName1154in: path1155description: The name of the database1156required: true1157schema:1158type: string1159- name: tableName1160in: path1161description: The name of the table1162required: true1163schema:1164type: string1165responses:1166'200':1167description: A JSON object with SELECT data1168content:1169application/json:1170schema:1171$ref: '#/components/schemas/Table'1172'401':1173description: Invalid API key error message1174content:1175application/json:1176schema:1177type: object1178items:1179type: string1180'404':1181description: Table or database not found1182content:1183application/json:1184schema:1185type: object1186items:1187type: string1188'500':1189description: Server error1190content:1191application/json:1192schema:1193type: object1194items:1195type: string1196delete:1197security:1198- ApiKeyAuth: []1199summary: Deletes an existing table.1200description: Deletes a table in a database.1201parameters:1202- name: databaseName1203in: path1204description: The name of the database1205required: true1206schema:1207type: string1208- name: tableName1209in: path1210description: Table name to delete1211required: true1212schema:1213type: string1214responses:1215'200':1216description: Successfully deleted1217content:1218application/json:1219schema:1220type: object1221items:1222type: string1223'401':1224description: Invalid API key error message1225content:1226application/json:1227schema:1228type: object1229items:1230type: string1231'404':1232description: Table or database not found1233content:1234application/json:1235schema:1236type: object1237items:1238type: string1239'500':1240description: Server error1241content:1242application/json:1243schema:1244type: object1245items:1246type: string