Logo

Sign InGet Started

Docs

Docs

Kernex REST API

Getting Started

You can use any language to access the Kernex API, as long as it supports HTTP requests.


Here's what you need to get started:


  1. An API Key. You can create an API Key in your app settings, in the API Keys section.
  2. Your app id. You can get your app id from your app settings, in the Info section.

Authorization

You need to pass your API Key in the x-api-key header.

API Resource

In order to perform CRUD operations against your Resources, you have to use the resource slug, which can be found in the resource settings, in the Info section.

Create Resource

Create a new Resource entry.

URL

https://api.kernex.io/api/v1/:appId/resource/:resourceSlug

HTTP Method

POST

Headers

x-api-key: your-api-key
content-type: application/json

Body:

{
  "title": "Hello"
}

Request Example

curl "https://api.kernex.io/api/v1/:appId/resource/:resourceSlug" \
 -X POST \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-key" \
-d "{\"title\":\"Hello\"}"

Response Example

{
  "_id": "entryId",
  "createdAt": "2024-08-20T18:17:01.680Z",
  "updatedAt": "2024-08-20T18:17:01.680Z",
  "title": "Hello"
}

Get Resource

Get a Resource entry.

URL

https://api.kernex.io/api/v1/:appId/resource/:resourceSlug/:entryId

HTTP Method

GET

Headers

x-api-key: your-api-key
content-type: application/json

Request Example

curl "https://api.kernex.io/api/v1/:appId/resource/:resourceSlug/:entryId" \
 -X GET \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-key"

Response Example

{
  "_id": "entryId",
  "createdAt": "2024-08-20T18:17:01.680Z",
  "updatedAt": "2024-08-20T18:17:01.680Z",
  "title": "Hello"
}

Find Resources

Find resources.

Params:

  • params
    • $limit (number, optional): the number of records to return. By default it will return 10 records. The maximum limit is 100.
    • $skip (number, optional): the number of records to skip. By default, the value is 0 (zero).
    • $select (array of strings, optional): the list of fields to include in the response. We recommend you to query only for the fields you need. By default, it will return all the fields. Also, the _id field will be returned ALWAYS, even if you don't include it in the $select array.
    • $sort (object, optional): an object where the keys are resource field names, and the values are either1 or-1, where1 will sort the entries by the specified field in ASCENDING order, and-1 will sort the entries by the specified field in DESCENDING order.
    • $join (array of objects, optional): join a list of related resources, where each object is defined as:
      • object.resource - the slug of the resource to join
      • object.on - the field name of the resource id on the current resource
      • object.as - the field name of the result
  • [field] (string | number | boolean | object, optional) : filter the entries by the specified field. the [field] is the field name, and the value is the value to filter by.
    The value can be either a string, number, boolean, or an object.
    Use the object to filter by specific operators. The list of available operators are:
    • $search - search by a string. Use this to search by a string for this field.
    • $gt - greater than. Use this to filter by a number greater than the specified value.
    • $gte - greater than or equal. Use this to filter by a number greater than or equal to the specified value.
    • $lt - less than. Use this to filter by a number less than the specified value.
    • $lte - less than or equal. Use this to filter by a number less than or equal to the specified value.

Returns:

  • response: a paginated response, with the following properties:
    • data(array of entries) - the list of the entries matching your filters.
    • total(number) - the total number of records matching your filters.
    • limit(number) - the limit specified in your query
    • skip(number) - the number of skipped records

Unlike the get method, it will not throw an error if no entries are found.

URL

https://api.kernex.io/api/v1/:appId/resource/:resourceSlug

Params

{
  "$limit": 10,
  "$skip": 0,
  "$select": [
    "title",
    "description"
  ],
  "$sort": {
    "title": 1
  },
  "title": {
    "$search": "hello"
  }
}

HTTP Method

GET

Headers

x-api-key: your-api-key
content-type: application/json

Request Example

curl "https://api.kernex.io/api/v1/:appId/resource/:resourceSlug?%24limit=10&%24skip=0&%24select%5B0%5D=title&%24select%5B1%5D=description&%24sort%5Btitle%5D=1&title%5B%24search%5D=hello" \
 -X GET \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-key"

Response Example

{
  "data": [
    {
      "_id": "entryId",
      "createdAt": "2024-08-20T18:17:01.680Z",
      "updatedAt": "2024-08-20T18:17:01.680Z",
      "title": "Hello"
    },
    {
      "_id": "entryId",
      "createdAt": "2024-08-20T18:17:01.680Z",
      "updatedAt": "2024-08-20T18:17:01.680Z",
      "title": "Hello, and Welcome"
    }
  ],
  "total": 2,
  "limit": 10,
  "skip": 0
}

Patch Resource

Patch a Resource entry. Patching will update the specified fields in the data, while not changing the unspecified ones.

URL

https://api.kernex.io/api/v1/:appId/resource/:resourceSlug/:resourceId

HTTP Method

PATCH

Headers

x-api-key: your-api-key
content-type: application/json

Body:

{
  "title": "New title"
}

Request Example

curl "https://api.kernex.io/api/v1/:appId/resource/:resourceSlug/:resourceId" \
 -X PATCH \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-key" \
-d "{\"title\":\"New title\"}"

Response Example

{
  "_id": "entryId",
  "createdAt": "2024-08-20T18:17:01.680Z",
  "updatedAt": "2024-08-20T18:17:01.680Z",
  "title": "New Title"
}

Update Resource

Update a Resource entry. Updating will update the entry entirely. If you want to update only some fields, then use the patch method.

RECOMMENDATION: we recommend you to use the patch method instead of update.

URL

https://api.kernex.io/api/v1/:appId/resource/:resourceSlug/:resourceId

HTTP Method

PUT

Headers

x-api-key: your-api-key
content-type: application/json

Body:

{
  "title": "New title"
}

Request Example

curl "https://api.kernex.io/api/v1/:appId/resource/:resourceSlug/:resourceId" \
 -X PUT \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-key" \
-d "{\"title\":\"New title\"}"

Response Example

{
  "_id": "entryId",
  "createdAt": "2024-08-20T18:17:01.680Z",
  "updatedAt": "2024-08-20T18:17:01.680Z",
  "title": "New Title"
}

Remove Resource

Remove a Resource entry.

URL

https://api.kernex.io/api/v1/:appId/resource/:resourceSlug/:resourceId

HTTP Method

DELETE

Headers

x-api-key: your-api-key
content-type: application/json

Request Example

curl "https://api.kernex.io/api/v1/:appId/resource/:resourceSlug/:resourceId" \
 -X DELETE \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-key"

Response Example

{
  "_id": "entryId",
  "createdAt": "2024-08-20T18:17:01.680Z",
  "updatedAt": "2024-08-20T18:17:01.680Z",
  "title": "Hello"
}