{"id":15481640,"url":"https://github.com/danielstieber/codaphp","last_synced_at":"2025-07-25T01:06:15.247Z","repository":{"id":53018417,"uuid":"157110954","full_name":"danielstieber/CodaPHP","owner":"danielstieber","description":"PHP library to use data from Coda documents in webprojects (via Coda API)","archived":false,"fork":false,"pushed_at":"2022-08-27T11:35:52.000Z","size":42,"stargazers_count":30,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-17T04:19:19.611Z","etag":null,"topics":["coda","composer","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielstieber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-11T18:58:45.000Z","updated_at":"2025-01-16T12:05:11.000Z","dependencies_parsed_at":"2022-08-21T09:50:12.860Z","dependency_job_id":null,"html_url":"https://github.com/danielstieber/CodaPHP","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielstieber%2FCodaPHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielstieber%2FCodaPHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielstieber%2FCodaPHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielstieber%2FCodaPHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielstieber","download_url":"https://codeload.github.com/danielstieber/CodaPHP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250269750,"owners_count":21402929,"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":["coda","composer","php"],"created_at":"2024-10-02T05:05:19.479Z","updated_at":"2025-04-22T15:40:43.099Z","avatar_url":"https://github.com/danielstieber.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"CodaPHP\n=======================\n[![Latest Stable](https://img.shields.io/github/release/danielstieber/codaphp.svg?style=flat-square)](https://github.com/danielstieber/codaphp/releases)\n[![Coda API Version](https://img.shields.io/badge/Coda_API_version-1.3.0-orange.svg?style=flat-square)](https://coda.io/developers/apis/v1)\n![Downloads](https://img.shields.io/packagist/dt/danielstieber/coda-php?style=flat-square)\n\n* [Quickstart](#Quickstart)\n* [Detailed Documentation](#Documentation)\n* [Doc \u0026 Pack Analytics](#Analytics)\n* [Caching](#Caching)\n* [Changelog](#Changelog)\n\nCodaPHP is a library that makes it easy to use data from [Coda](https://www.coda.io) docs in web projects by using the [Coda API](https://coda.io/developers/apis/v1). \n\nEasily use all available API calls with one library including\n* List all documents\n* Read data from tables, formulas and controls\n* Add/modify rows\n* Manage doc permissions\n* and a lot more\n\n→ [**Get 10$ discount on Coda paid plans when signing up with this link**](https://coda.io/?r=Qjx7OzpmTa2L6IPfkY-anw)\n\n## Quickstart\n### Installation and basic usage\nInstall the library through [Composer](http://getcomposer.org/):\n```bash\nphp composer.phar require danielstieber/coda-php\n```\nand add it to your project:\n```PHP\nrequire './vendor/autoload.php';\n$coda = new CodaPHP\\CodaPHP('\u003cYOUR API TOKEN\u003e');\n\n// List all your docs\n$result = $coda-\u003elistDocs();\nvar_dump($result);\n```\n\n### Handling table data\nLet's assume you have the table 'Products' in your Coda doc:\n#### Products\n| Title   ⚑ | Price | Status      |\n|-----------|-------|-------------|\n| Goatmilk  | 14.90 | available ▼ |\n| Goatmeat  | 38.90 | available ▼ |\n\n```PHP\n// Get the price of the goatmilk\n$docId = $coda-\u003egetDocId('\u003cYOUR DOC URL\u003e');\n\n// Lists only Products with status 'available' (currently only one filter allowed)\n$availableProducts = $coda-\u003elistRows($docId, 'Products', ['query' =\u003e ['status' =\u003e 'available']]);\n\n// Show value of one cell\n$result = $coda-\u003egetRow($docId, 'Products', 'Goatmilk');\nvar_dump($result['values']['Price']);\n// Will show you 'float(14.90)'\n\n// Add the new product 'Goatcheese'\nif($coda-\u003einsertRows($docId, 'Products', ['Title' =\u003e 'Goatcheese', 'Price' =\u003e 23.50, 'Status' =\u003e 'available'])) {\n  echo 'Product added';\n}\n\n// Change the status of the product 'Goatmilk' to 'sold out'\nif($coda-\u003einsertRows($docId, 'Products', ['Title' =\u003e 'Goatmilk', 'Status' =\u003e 'sold out'], ['Title'])) {\n  echo 'Product updated';\n}\n```\n### Triggering automations\nSince May 2022, Coda automations can be triggered via webhooks – and via CodaPHP. To trigger an automation, the automation must be set to \"Webhook invoked\". To run the automation you need the doc ID an the ID of the automation rule. You can find the rule ID when you click on the 3 dots (kebap menu) above the rule step settings.\n\n```PHP\n// Trigger the automation\n$result = $coda-\u003erunAutomation('\u003cYOUR DOC ID\u003e', '\u003cTHE RULE ID\u003e');\n```\n\n## Overview\nThis is a personal side project. If you have any suggestions, find bugs or want to contribute, don't hesitate to contact me. You can use the [offical Coda community](https://community.coda.io/) to asks questions and reach out as well.\n\n### Token\nGenerate your token in the Coda profile settings. *Notice: Everyone with this token has full access to all your docs!*\n\n### Methods\nThe method names are inspired by the wording of the [official Coda API documentation](https://coda.io/developers/apis/v1beta1) and are listed below.\n\n### Parameters\nAll parameters can be found in the [official Coda API documentation](https://coda.io/developers/apis/v1beta1). Just add an associative array with your parameters to selected functions. The parameter _useColumnNames_ is set true by default in all 'row' functions. I list the important ones below.\n\n### Response\nIn case of success, responses are mostly untouched but converted to PHP arrays. Exception is `insertRow()` function, which provides a boolean true in case of success.\nIn case of an error, the response includes the statusCode and provided error message, also untouched and converted to an array.\n\n### Cache data\nEvery API call may take a few seconds. It is recommended to store results and only call for new when necessary. The library provides a simple caching mechanic to store received data in a .codaphp_cache folder. **This mechanic is optional** and needs to be activated. Learn more in the [caching instructions](#Caching)\n\n## Documentation\n```PHP\n$coda = new CodaPHP('\u003cYOUR API TOKEN\u003e'); // Create instance of CodaPHP\n```\n### Docs\n```PHP\n$coda-\u003egetDocId('\u003cYOUR DOC URL\u003e'); // Get the id of a doc\n\n$coda-\u003elistDocs(); // List all docs you have access to\n$coda-\u003elistDocs(['query' =\u003e 'todo']);  // List docs filtered by searchquery 'todo'\n$coda-\u003egetDoc('\u003cDOC ID\u003e'); // Get a specific doc\n$coda-\u003ecreateDoc('My new doc'); // Create a new doc\n$coda-\u003ecreateDoc('Copy of my old doc', '\u003cDOC ID\u003e'); // Copy a doc\n```\n### Pages (former Folders \u0026 Sections)\n```PHP\n$coda-\u003elistPages('\u003cDOC ID\u003e'); // List all sections in a doc\n$coda-\u003egetPage('\u003cDOC ID\u003e', '\u003cPAGE NAME OR ID\u003e'); // Get a section in a doc\n```\n### Tables/Views, Columns and Rows\n```PHP\n$coda-\u003elistTables('\u003cDOC ID\u003e'); // List all tables in a doc\n$coda-\u003egetTable('\u003cDOC ID\u003e', '\u003cTABLE/VIEW NAME OR ID\u003e'); // Get a table in a doc\n\n$coda-\u003elistColumns('\u003cDOC ID\u003e', '\u003cTABLE/VIEW NAME OR ID\u003e'); // List all columns in a table\n$coda-\u003egetColumn('\u003cDOC ID\u003e', '\u003cTABLE/VIEW NAME OR ID\u003e', '\u003cCOLUMN NAME OR ID\u003e'); // Get a column in a table\n\n$coda-\u003elistRows('\u003cDOC ID\u003e', '\u003cTABLE/VIEW NAME OR ID\u003e'); // List all row in a table\n$coda-\u003einsertRows('\u003cDOC ID\u003e', '\u003cTABLE/VIEW NAME OR ID\u003e', [['\u003cCOLUMN ID OR NAME\u003e' =\u003e '\u003cVALUE\u003e']], ['\u003cKEYCOLUMN\u003e']); // Insert/updates a row in a table\n\n// Examples:\n$coda-\u003einsertRows('\u003cDOC ID\u003e', 'todos', ['title' =\u003e 'Shower']); // Adds one row to 'todo'\n$coda-\u003einsertRows('\u003cDOC ID\u003e', 'todos', [['title' =\u003e 'Wash dishes'], ['title' =\u003e 'Clean car']]); // Adds two rows to 'todo'\n$coda-\u003einsertRows('\u003cDOC ID\u003e', 'todos', [['title' =\u003e 'Shower', 'status' =\u003e 'done'], ['title' =\u003e 'Buy goatcheese']], ['title']); // Updates the status of 'Shower' and inserts a new todo\n\n$coda-\u003eupdateRow('\u003cDOC ID\u003e', '\u003cTABLE/VIEW NAME OR ID\u003e', '\u003cROW NAME OR ID\u003e', ['\u003cCOLUMN ID OR NAME\u003e' =\u003e '\u003cVALUE\u003e']); // Updates a row in a table\n$coda-\u003egetRow('\u003cDOC ID\u003e', '\u003cTABLE/VIEW NAME OR ID\u003e', '\u003cROW NAME OR ID\u003e'); // Get a row in a table\n$coda-\u003edeleteRow('\u003cDOC ID\u003e', '\u003cTABLE/VIEW NAME OR ID\u003e', '\u003cROW NAME OR ID\u003e'); // Deletes a row in a table\n```\n### Working with Views\nSince Coda API Version 1.0.0 there are no seperate view methods. All view operations can be done via the table methods.\n### Pushing Buttons\n```PHP\n$coda-\u003epushButton('\u003cDOC ID\u003e', '\u003cTABLE/VIEW NAME OR ID\u003e', '\u003cROW NAME OR ID\u003e', '\u003cCOLUMN NAME OR ID'\u003e); // Pushes the button on the given column in a table\n```\n### Formulas and Controls\n```PHP\n$coda-\u003elistFormulas('\u003cDOC ID\u003e'); // List all formulas in a doc\n$coda-\u003egetFormula('\u003cDOC ID\u003e', '\u003cFORMULA NAME OR ID\u003e'); // Get a formula in a doc\n\n$coda-\u003elistControls('\u003cDOC ID\u003e'); // List all controls in a doc\n$coda-\u003egetControl('\u003cDOC ID\u003e', '\u003cCONTROL NAME OR ID\u003e'); //Get a control in a doc\n```\n### Manage permissions\n```PHP\n$coda-\u003elistPermissions('\u003cDOC ID\u003e'); // Get information about users \u0026 permissions for a doc\n$coda-\u003eaddUser('\u003cDOC ID\u003e', '\u003cEMAIL\u003e'); // Add a user to a doc (default permissions are 'write')\n$coda-\u003eaddUser('\u003cDOC ID\u003e', '\u003cEMAIL\u003e', 'readonly', true); // Add a 'readonly' user and notify via email\n$coda-\u003edeleteUser('\u003cDOC ID\u003e', '\u003cEMAIL\u003e'); // Removes a user from the doc\n$coda-\u003eaddPermission('\u003cDOC ID\u003e', '\u003cPERMISSION TYPE\u003e', '\u003cPRINCIPAL\u003e', '\u003cNOTIFY\u003e'); // Add a permission to a doc\n$coda-\u003edeletePermission('\u003cDOC ID\u003e', '\u003cPERMISSION ID\u003e'); // Remove a permission from a doc\n$coda-\u003egetACLMetadata('\u003cDOC ID\u003e'); // Returns the ACL metadata of a doc\n```\nLearn more about permission settings with the API [here](https://coda.io/developers/apis/v1#tag/ACLs).\n### Run automations / trigger webhooks\n```PHP\n$coda-\u003erunAutomation('\u003cYOUR DOC ID\u003e', '\u003cTHE RULE ID\u003e');\n```\n\n### Account and other\n```PHP\n$coda-\u003ewhoAmI(); // Get information about the current account\n$coda-\u003eresolveLink('\u003cDOC URL\u003e'); // Resolves a link \n$coda-\u003egetMutationStatus('\u003cREQUEST ID\u003e'); // Resolves a link \n```\n\n### Analytics\n```PHP\n$coda-\u003elistDocAnalytics(); // List all docs with analytics data\n$coda-\u003elistDocAnalytics(['query' =\u003e 'Goats', 'sinceDate' =\u003e '2022-08-02', 'sinceDate' =\u003e '2022-08-04']); // List docs about \"Goats\" with analytics data between 2nd and 4th of August 2022\n// All parameters for all methods can be found in the official API docs: https://coda.io/developers/apis/v1#tag/Analytics/operation/listDocAnalytics\n$coda-\u003elistPageAnalytics('\u003cDOC ID\u003e'); // List analytics data on page level of given doc\n$coda-\u003elistPackAnalytics(); // List all packs where user has edit rights with analytics data\n$coda-\u003elistPackAnalytics(['workspaceId' =\u003e 'ws-123Ave']); // List all packs where user has edit rights with analytics data from workspace ws-123Ave\n$coda-\u003elistPackFormulaAnalytics('\u003cPACK ID'); // List analytisc data on formula level of given pack\n\n$coda-\u003egetDocAnalyticsSummery(); // Returns summarized analytics data for available docs.\n$coda-\u003egetPackAnalyticsSummery(); // Returns summarized analytics data for available packs.\n\n$coda-\u003egetAnalyticsUpdatedDay(); // Returns days based on Pacific Standard Time when analytics were last updated. Usually 1 day ago PST.\n```\n\n## Caching\nThe library can cache API requests in JSON files. If caching is activated, the library tries to create a `.codaphp_cache` folder in your project root. If it can't create or find the folder, it will deactivate caching. You can also create the folder on your own and set CHMOD so the library can read \u0026 write files in it. Only doc data \u0026 content will be cached, no permissions, links or mutation status!\n```PHP\n$coda = new CodaPHP('\u003cYOUR API TOKEN\u003e', '\u003cACTIVATE CACHE\u003e', '\u003cEXPIRY TIME IN SECONDS\u003e'); // Instance creation with otptional caching \u0026 expiry time\n$coda = new CodaPHP('\u003cYOUR API TOKEN\u003e', true); // Instance with activated caching\n```\nBy default, the cache will expire after 7 days. You can manually change the expiry time.\n```PHP\n$coda = new CodaPHP('\u003cYOUR API TOKEN\u003e', true, 86400); // Activate caching and set cache to 1 day (in seconds)\n```\nYou can also clear the cache manually\n```PHP\n$coda-\u003eclearCache(); // Clears the whole cache\n```\n#### Control cache inside the doc\nA simple way to control the cache status from the coda doc is a button that triggers the clear cache method.\n```PHP\n$coda = new CodaPHP('\u003cYOUR API TOKEN\u003e', true);\nif(isset($_GET['clearCache'])) {\n\t$coda-\u003eclearCache();\n}\n```\nNow you can add a \"open hyperlink\"-button in your doc that opens https://yourdomain.com/?clearCache. After clicking the button the website will receive the latest data and saves it in the cache again.\n![clear cache button](https://i.imgur.com/it4rkxV.png)\n\n## Changelog\n### 0.4.0 (August 28, 2022)\n* Update to API version 1.3.0\n* New features:\n\t- Added Analytics endpoints\n* Bug fixes:\n\t- Improved getDocId() regex for better matching\n\n### 0.3.0 (May 24, 2022)\n* Update to API version 1.2.6.\n* New features:\n\t- Trigger \"Webhook invoked\" automations\n\n### 0.2.0 (January 3, 2021)\n* Update to API version 1.1.0.\n* New features:\n\t- Added ACL permission management\n\t- Added optional caching\n\n### 0.1.0 (August 15, 2020)\n* Update to API version 1.0.0.\n* Breaking changes:\n\t- Sections \u0026 Folders have been replaced by pages\n\t- Removed 'view' methods. You can access views via table methods.\n* New features:\n\t- Added mutation status method\nYou can read more about API version 1.0.0 [here](https://community.coda.io/t/launched-coda-api-v1/17248)\n\n### 0.0.4 (February 16, 2020)\n* Updated to API version 0.2.4-beta. New features:\n\t- Pushing buttons inside of tables \u0026 views\n\t- Getting and interacting with views\n\t- Creating docs in folders\n\t- Ability to disable parsing of cell values\n\n### 0.0.3 (March 16, 2019)\n* Fixed an issue with using queries in listRows (Thanks to [Al Chen](https://github.com/albertc44) from Coda for mentioning this)\n\n### 0.0.2 (November 15, 2018)\n* Fixed an issue regarding table names with special characters (Thanks to Oleg from Coda for mentioning this)\n\n### 0.0.1 (November 11, 2018)\n* Initial version based on v0.1.1-beta of Coda API","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielstieber%2Fcodaphp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielstieber%2Fcodaphp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielstieber%2Fcodaphp/lists"}