Query — Querying the Database #
This operation allows you to perform a SELECT query. The query must follow a specific format and has certain limitations:
- Only one entity type per query (no JOIN)
- Maximum 100 results per query (use
LIMITandOFFSETto paginate) - The
WHERE,ORDER BY, andLIMITclauses are optional - The query must be URL-encoded
GET
https://apps.kafinea.com/{instance}/webservice.php
| Parameter | Type | Required | Description |
|---|---|---|---|
operation |
string | yes | Must be query |
sessionName |
string | yes | Session identifier |
query |
string | yes | SQL query (URL-encoded) |
curl example:
curl "https://apps.kafinea.com/YourKafinea/webservice.php?operation=query&sessionName=YOUR_SESSION_ID&query=SELECT%20*%20FROM%20Contacts%20WHERE%20lastname%3D'Dupont'%20LIMIT%2010%20;"
Query Format #
SELECT * | ColumnsList | count(*)
FROM ModuleName
WHERE Conditions
ORDER BY ColumnsList
LIMIT Offset, Limit ;
Important: the final semicolon is mandatory.
Details:
| Element | Description |
|---|---|
ColumnsList |
List of field names separated by commas |
ModuleName |
Entity module name |
Conditions |
Separated by AND or OR, processed from left to right. No grouping with parentheses. |
Offset |
Integer (optional) |
Limit |
Integer |
Available condition types:
| Type | Syntax | Example |
|---|---|---|
| Operator | <, >, <=, >=, !=, = |
lastname = 'Dupont' |
| IN | IN(val1, val2, ...) |
industry IN('Tech', 'Finance') |
| LIKE | LIKE 'pattern' |
lastname LIKE '%dup%' |
Query Related — Querying Related Lists #
This operation allows you to retrieve entities from the related lists of a specific entity. The query follows the same format as query, but without a final semicolon.
GET
https://apps.kafinea.com/{instance}/webservice.php
| Parameter | Type | Required | Description |
|---|---|---|---|
operation |
string | yes | Must be query_related |
sessionName |
string | yes | Session identifier |
id |
string | yes | Webservice ID of the parent entity |
relatedLabel |
string | yes | Related module name |
query |
string | yes | SQL query (URL-encoded, without final ;) |
curl example:
curl "https://apps.kafinea.com/YourKafinea/webservice.php?operation=query_related&sessionName=YOUR_SESSION_ID&id=21x3456&relatedLabel=Documents&query=SELECT%20*%20FROM%20Documents%20WHERE%20filesize%20%3E%2010000"
Query example:
SELECT * FROM Documents WHERE filesize > 10000