Welcome to the EonaCat Database Api

Authentication to the EonaCat Database Api

Please send your apiKey as a header value under the key x-api-key

List databases

  
    GET https://db.EonaCat.com/_databases

    Resp:
    200/OK
    [
      "test"
    ]
  

Create a Table

  
    POST https://db.EonaCat.com/test
    Data: 
    {
      "Name": "person",
      "PrimaryKey": "person_id",
      "Columns": [
        {
          "Name": "person_id",
          "Type": "int",
          "Nullable": false
        },
        {
          "Name": "first_name",
          "Type": "nvarchar",
          "MaxLength": 32,
          "Nullable": false
        },
        {
          "Name": "last_name",
          "Type": "nvarchar",
          "MaxLength": 32,
          "Nullable": true
        },
        {
          "Name": "age",
          "Type": "int",
          "Nullable": false
        },
        {
          "Name": "created",
          "Type": "datetime",
          "Nullable": true
        }
      ]
    }

  Resp:
  201/Created
  

Retrieve a Database

  
    GET https://db.EonaCat.com/test

    Resp:
    200/OK
    {
      "Name": "test",
      "Type": "mssql",
      "Hostname": "localhost",
      "Port": 1433,
      "Instance": "sqlexpress",
      "Debug": false,
      "TableNames": [
        "person"
      ]
    }
  

Describe a Table

  
    GET https://db.EonaCat.com/test/person?_describe

    Resp:
    200/OK
    {
      "Name": "person",
      "PrimaryKey": "person_id",
      "Columns": [
        {
          "Name": "person_id",
          "Type": "int",
          "Nullable": false
        },
        {
          "Name": "first_name",
          "Type": "nvarchar",
          "MaxLength": 32,
          "Nullable": false
        },
        {
          "Name": "last_name",
          "Type": "nvarchar",
          "MaxLength": 32,
          "Nullable": true
        },
        {
          "Name": "age",
          "Type": "int",
          "Nullable": false
        },
        {
          "Name": "created",
          "Type": "datetime",
          "Nullable": true
        }
      ]
    }
  

Create an Object

Be sure to use timestamps appropriate to your database type, for instance:

  
    POST https://db.EonaCat.com/test/person
    Data: { first_name: 'John', last_name: 'Doe', age: 36, created: '2022-07-27' }

    Resp:
    201/Created
    {
      "person_id": 1,
      "first_name": "John",
      "last_name": "Doe",
      "age": 36,
      "created": "2022-07-27 00:00:00"
    }
  

Create Multiple Objects

To create multiple objects, send a JSON array containing a series of dictionaries appropriate for the specified table.

  
    POST https://db.EonaCat.com/test/person?_multiple
    Data: [ { first_name: 'John', last_name: 'Doe', age: 36, created '2022-07-27' }, ... ]

    Resp:
    201/Created
  

Retrieve Objects

You can retrieve all of a table's contents, retrieve by a specific ID, and filter by key-value pairs (using the querystring).

  
    GET https://db.EonaCat.com/test/person 
    GET https://db.EonaCat.com/test/person/1
    GET https://db.EonaCat.com/test/person?first_name=John 

    Resp:
    200/OK
    [
      {
        "person_id": 1,
        "first_name": "John",
        "last_name": "Doe",
        "age": 36,
        "created": "2022-07-27T00:00:00Z"
      }, 
      { ... }
    ]
  

Retrieve Objects with Pagination

You can retrieve results and use pagination to return only a subset. Include _index, _max, _order, and _order_by in the querystring.

By default, SELECT requests are ordered ASCENDING by the table's primary key.

GET https://db.EonaCat.com/test/person?_max=1&_index=1&_order=asc&_order_by=person_id,first_name

Resp:
200/OK
[
  {
    "__row_num__": 1,
    "person_id": 1,
    "first_name": "John",
    "last_name": "Doe",
    "age": 36,
    "created": "2022-07-27 00:00:00"
  },
  { ... }
]

Update an Object

Supply the ID in the URL and include the key-value pairs to change in the request body.

PUT https://db.EonaCat.com/test/person/1
Data: { age: 38 }

Resp:
200/OK
{
  "person_id": 1,
  "first_name": "John",
  "last_name": "Doe",
  "age": 38,
  "created": "2022-07-27 00:00:00"
}

Search for an Object

PUT https://db.EonaCat.com/test/person
Data: 
{
  "Left": "person_id",
  "Operator": "GreaterThan",
  "Right": 0
}

Resp:
200/OK
[
  {
    "person_id": 1,
    "first_name": "John",
    "last_name": "Doe",
    "age": 38,
    "created": "2022-07-27 00:00:00"
  }
]

Delete an Object

DELETE https://db.EonaCat.com/test/person/1

Resp: 
204/Deleted

Truncate a Table

DELETE https://db.EonaCat.com/test/person?_truncate

Resp: 
204/Deleted

Drop a Table

DELETE https://db.EonaCat.com/test/person?_drop

Resp:
204/Deleted

Execute a Raw Query

      POST https://db.EonaCat.com/test?raw
      Data:
      SELECT * FROM person;
      Resp:
      200/OK 
      [
      {
      "person_id": 1,
      "first_name": "John",
      "last_name": "Doe",
      "age": 38,
      "created": "2022-07-27 00:00:00"
      }
      ]