Fasty API

Fasty provide now an API out of the box for fetching your datasets data from your single page applications. If you need more interactions (CRUD) you'll still be able to write your own API within the admin UI.

The endpoint

GET https://yourdomain.com/_db/:db_name/api/:type

The URL will accept some query string as parameters such as : limit, offset, order, search and fields

Here a sample

curl https://fasty.ovh/_db/db_cms/api/posts?limit=2

Response

{
  "count": 1,
  "data": {
    "any_fields": "value",
    "assets": []
  }
}

The number of total objects it returned. Even if you set a limit, it will return you the global count for pagination purpose. Assets associated to your item (if any) will be returned as well in the assets key.

Pagination

The API endpoint allow you to define the limit & offset for pagination purpose.

curl https://fasty.ovh/_db/db_cms/api/posts?limit=10&offset=20

Select fields to be returned

curl https://fasty.ovh/_db/db_cms/api/posts?fields=title,description

Filter by term

You can use any field to filter on.

curl https://fasty.ovh/_db/db_cms/api/posts?title=Hello+World

Ordering

curl https://fasty.ovh/_db/db_cms/api/posts?order=created_at,-title

You can order your query by specifying the field and the direction (ASC or DESC). Adding a - before your key name will order it by DESC. You can define as many key you want.

Fulltext search

If your dataset contains a fulltext index, you can run some search on it.

curl https://fasty.ovh/_db/db_cms/api/posts?search=Fasty

Combination

You can of course, filter, order, select fields in a same request.

curl https://fasty.ovh/_db/db_cms/api/posts?limit=2&online=true&search=Fasty

Leave a comment