Query — Query the database #
This operation allows you to execute a SELECT query. The query must follow a specific format and has certain limitations:
- Only one entity type per query (no JOINs)
- Maximum of 100 results per query (use
LIMITandOFFSET(for pagination) - The clauses
WHERE,ORDER BYandLIMITare optional - The request must be URL-encoded
GET
https://apps.kafinea.com/{instance}/webservice.php
| Setting | Type | Required | Description |
|---|---|---|---|
operation |
string | yes | Must be query |
sessionName |
string | yes | Session ID |
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 semicolon at the end is required.
Details:
| Element | Description |
|---|---|
ColumnsList |
A comma-separated list of field names |
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 conditions:
| Type | Syntax | Example |
|---|---|---|
| Operator | <, >, <=, >=, !=, = |
lastname = 'Dupont' |
| IN | IN(val1, val2, ...) |
industry IN('Tech', 'Finance') |
| LIKE | LIKE 'pattern' |
lastname LIKE '%dup%' |
Query Related — Query Related Lists #
This operation retrieves the entities from the related lists of a specific entity. The query follows the same format as query, but without a semicolon at the end.
GET
https://apps.kafinea.com/{instance}/webservice.php
| Setting | Type | Required | Description |
|---|---|---|---|
operation |
string | yes | Must be query_related |
sessionName |
string | yes | Session ID |
id |
string | yes | Parent entity's Web service ID |
relatedLabel |
string | yes | Name of the linked module |
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"
Example query:
SELECT * FROM Documents WHERE filesize > 10000