{"id":25176177,"url":"https://github.com/kitsunetech-com/velox-api","last_synced_at":"2025-10-25T09:10:10.844Z","repository":{"id":275798946,"uuid":"910585297","full_name":"KitsuneTech-com/Velox-API","owner":"KitsuneTech-com","description":"Velox public API interface","archived":false,"fork":false,"pushed_at":"2025-02-04T16:25:53.000Z","size":13,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-04T17:23:14.824Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KitsuneTech-com.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-31T18:04:22.000Z","updated_at":"2025-02-04T16:44:07.000Z","dependencies_parsed_at":"2025-02-04T17:33:24.023Z","dependency_job_id":null,"html_url":"https://github.com/KitsuneTech-com/Velox-API","commit_stats":null,"previous_names":["kitsunetech-com/velox-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KitsuneTech-com%2FVelox-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KitsuneTech-com%2FVelox-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KitsuneTech-com%2FVelox-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KitsuneTech-com%2FVelox-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KitsuneTech-com","download_url":"https://codeload.github.com/KitsuneTech-com/Velox-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247107819,"owners_count":20884794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-09T13:16:34.993Z","updated_at":"2025-10-14T10:33:51.228Z","avatar_url":"https://github.com/KitsuneTech-com.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Velox API\n\nThe Velox API works in conjunction with Velox Server to provide an interface that reduces database interaction to a set of POST calls made to common endpoints,\nwhich forward requests to \"query definition files\" as needed based on the nature of the request. Because the structure of this API depends exclusively\non POST requests, it is inherently non-RESTful; in lieu of using HTTP verbs, the nature of the request is determined by how the body of the POST is structured.\n\nAll requests to a Velox API endpoint are done using either form-encoded variables or a raw JSON object, containing one or more of the main SQL query verbs\n(select, update, insert, delete) as keys and having the values thereof in the form of JSON-encoded arrays of objects representing the conditions and/or\nvalues to be used by the corresponding query. Each object in the array, depending on the type of query being used, will have either or both of the following properties: \"where\", which defines the filtering criteria (as in a SQL WHERE clause); and \"values\", which contains name-value pairs to be inserted or updated by the query. The \"where\" property is itself an array of objects, each representing a set of criteria to be ORed together; each element object represents specific column criteria, with the properties ANDed together. The values of these properties are arrays of one to three elements, the first of which is a string containing a standard SQL operator, and the following element(s) corresponding to the right side of the operation. The \"values\" property is simpler; the object represents a single row to be inserted or updated, with the keys and values being the column names and intended values, respectively.\n\nIf all this seems complicated, an illustration may help to clear it up. Let's say you have a table called \"addresses\", structured as so:\n\nid | address1       | address2 | city              | state | zip   |\n-- | -------------- | -------- | ----------------- | ----- | ----- |\n 1 | 123 Elm Street | Apt. 123 | Spring            | TX    | 77373 |\n 2 | 456 Oak Road   | null     | Summer Branch     | TX    | 75486 |\n 3 | 789 Pine Ave.  | Ste. 456 | Falls City        | TX    | 78113 |\n 4 | 1011 Cedar Dr. | Box 789  | Winters           | TX    | 79567 |\n\nIf you wanted to get any rows from Falls City, TX, using SQL, you might write the query as so:\n \n```sql\nSELECT * FROM addresses WHERE city = 'Falls City' AND state = 'TX';\n```\n \nWith the Velox API, if the query definition file includes:\n \n```sql\n$QUERIES['SELECT'] = new StatementSet($conn,\"SELECT * FROM addresses WHERE \u003c\u003ccriteria\u003e\u003e\");\n```\n \nthen the JSON used to perform the same query would be:\n \n```json\n{\"select\": [{\"where\": [{\"city\": [\"=\",\"Falls City\"], \"state\": [\"=\",\"TX\"]}]}]}\n```\n \nAlternatively, if this were to be built programmatically:\n \n```js\n//Define the request body\nlet request = {};\nrequest.select = [];\n  \n//Define the row object\nlet row = {};\nrow.where = [];\n\n//Define the where criteria\nlet criteria = {};\ncriteria.city = [\"=\",\"Falls City\"];\ncriteria.state = [\"=\",\"TX\"];\nrow.where.push(criteria);\n\n//Add the row object to the request\nrequest.push(row);\n```\n\nSimilarly, if you wanted an UPDATE query to set any null address2 values to \"---\", using this in the query definition file:\n \n```sql\n$QUERIES['UPDATE'] = new StatementSet($conn,\"UPDATE addresses SET \u003c\u003cvalues\u003e\u003e WHERE \u003c\u003ccondition\u003e\u003e\");\n```\n \nThe JSON in the request would look like:\n \n```json\n{\"update\": [{\"values\": {\"address2\": \"---\"}, \"where\": [{\"address2\": [\"IS NULL\"]}]}]}\n```\n \nOr programmatically:\n \n```js\n//Define the request body\nlet request = {};\nrequest.update = [];\n\n//Define the row object\nlet row = {};\nrow.values = {};\nrow.where = [];\n\n//Define the values\nrow.values.address2 = \"---\";\n\n//Define the criteria\nlet criteria = {};\ncriteria.address2 = [\"IS NULL\"];\nrow.where.push(criteria);\n\n//Add the row object to the request\nrequest.push(row);\n```\n \nBeing able to build API requests programmatically through JavaScript objects allows filters and updates of high complexity to be constructed client-side\nwith minimal code on the back-end. StatementSet is optimized for specifically these kinds of queries; it only builds as many PreparedStatements as necessary to run the request; where possible, similar criteria are grouped together and run as criteria on one PreparedStatement.\n\n### Conditional operators\n\n#### Binary comparisons\n\nMost comparison operations in SQL are binary, meaning that a pair of values are compared to each other. For these binary comparisons, the corresponding Velox JSON uses the SQL operator as the first element of the comparison array, and the value to be compared as the second.\n\n```json\n{\"select\": [{\"where\": [{\"state\": [\"=\",\"TX\"], \"beginDate\": [\"\u003e\",\"2000-01-01\"]}]}]}\n```\n\n#### IS NULL / IS NOT NULL\n\n`IS NULL` and `IS NOT NULL` are treated as unary, meaning that the column is not checked against an arbitrary value. For these, the comparison array will consist only of the desired operator.\n\n```json\n{\"update\": [{\"values\": {\"address2\": \"---\"}, \"where\": [{\"address2\": [\"IS NULL\"]}]}]}\n```\n\n#### BETWEEN / NOT BETWEEN\n\n`BETWEEN` and `NOT BETWEEN` are trinary; these compare the column value to two arbitrary values. If one of these is used, the comparison array must consist of three elements: first the operator, then the two values to which the column is compared.\n\n```json\n{\"select\": [{\"where\": [{\"beginDate\": [\"BETWEEN\",\"2000-01-01\",\"2001-01-01\"]}]}]}\n```\n\n#### IN / NOT IN\n\n`IN` and `NOT IN` are also supported. These operators compare the column against an arbitrary number of values, so for these, the comparison array must consist of two elements: the operator, and an array of values to which the column will be compared.\n\n```json\n{\"select\": [{\"where\": [{\"myNumber\": [\"IN\",[1,2,4,8]]}]}]}\n```\n\n#### EKIL / EKILR\nIn addition to the SQL standard comparison operations, Velox provides `EKIL` and `EKILR`. These are inverted versions of `LIKE` and `RLIKE`, respectively (read it backwards), and perform the same comparisons, except that when the statement is assembled, the placeholder is put on the left side of the expression rather than on the right. (e.g. `:value LIKE myColumn`). This inversion allows the value to be compared against a pattern stored in the given column, where normally one would compare a value in the given column to a chosen pattern.\n\nThus:\n```json\n{\"select\": [{\"where\": [{\"number_pattern\": [\"EKIL\",\"2053553\"]}]}]}\n```\nwould match a row where number_pattern has the value \"205%\", since \"2053553\" LIKE \"205%\".\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitsunetech-com%2Fvelox-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkitsunetech-com%2Fvelox-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitsunetech-com%2Fvelox-api/lists"}