# Rest API

# The API URL

This is base URL of content delivery API. You can find your repository's API endpoint in the Settings -> API section.

https://your-repository-name.cdn.doclify.io/api/v2

# Authentication

All requests to the API must be authenticated by API key. There are 2 ways to provide the API key.

# Header (recomennded)

Send x-api-key header with API key as value.

curl -XGET -H 'x-api-key: MyApiKey' 'https://your-repository-name.cdn.doclify.io/api/v2'

# Query paramater

Send key query paramater with API key as value.

https://your-repository-name.cdn.doclify.io/api/v2?key=MyApiKey

# Endpoints

# Search documents

You can use this endpoints to search for documents and return limited number of results.

GET https://your-repository-name.cdn.doclify.io/api/v2/documents/search?q=[]

# Parameters

Name Type Required Description Example
q Array Yes List of query rules [["sys.collection", "eq", "articles"]]
lang String Optional Content's language, if not provided, default is used en
limit Number Optional Number of results, max 300, default 20 3
order Array Optional Order results, default is latest to oldest [["title", "asc"]]
with Array Optional Load relations ["author"]

# Paginate documents

You can use this endpoints to get paginated documents.

GET https://your-repository-name.cdn.doclify.io/api/v2/documents/paginated?q=[]

# Parameters

Name Type Required Description Example
q Array Yes List of query rules [["sys.collection", "eq", "articles"]]
lang String Optional Content's language, if not provided, default is used en
page Number Optional Page to return 5
perPage Number Optional Number of results per page, max 300, default 20 50
order Array Optional Order results, default is latest to oldest [["title", "asc"]]
with Array Optional Load relations ["author"]

# Get document

You can use this endpoints to get single document. If none is found a 404 error is returned.

GET https://your-repository-name.cdn.doclify.io/api/v2/documents/single?q=[]

# Parameters

Name Type Required Description Example
q Array Yes List of query rules [["sys.collection", "eq", "articles"]]
lang String Optional Content's language, if not provided, default is used en
order Array Optional Order results, default is latest to oldest [["title", "asc"]]
with Array Optional Load relations ["author"]

# Querying

You can query the documents API by system fields or any custom field that is indexed. Each field support different operators, see table below for support of operators.

# Example

[["rating", "gte", 50], ["title", "match", "api querying"]]

# Operators

Operator Description
eg Must equal to value
not Must not equal to value
in Must be one of the values
nin Must not be one of the values
gt Must be greater than
gte Must be greater than or equal
lt Must be less than
lte Must be less than or equal
fulltext Full-text search
match Must match phrase

# System fields

Name Type Operators Example
sys.id Number eq, not, in, nin, gt, lt, gte, lte 123
sys.uid String eq, not, in, nin hello-world
sys.collection String eq blog-posts
sys.contentType String eq article
sys.publishedAt String eq, not, gt, lt, gte, lte 2020-03-19T00:00:00.000Z
sys.firstPublishedAt String eq, not, gt, lt, gte, lte 2020-03-19T00:00:00.000Z

# Custom fields

Field type Type Operators Example
Text String eq, not, in, nin, fulltext, match My blog post
Number String eq, not, in, nin 53
Boolean Boolean eq, not true
Long Text String fulltext, match My blog post
Rich Text String fulltext, match My blog post
Relation Number eq, not, in, nin 123
Date String eq, not, in, nin, gt, lt, gte, lte 2020-03-19T00:00:00.000Z
Date & time String eq, not, in, nin, gt, lt, gte, lte 2020-03-19T00:00:00.000Z
Select String eq, not, in, nin option

You can query custom fields by field uid.

WARNING

If you don't query by contentType or collection that has contentType specified, you have to prefix the field's uid by contentType uid.

Example: [["article.featured", "eq", true]]

TIP

You can query nested properties using dot notation.

Example: [["article.group.featured", "eq", true]]