Since Coda and the API is in beta, you can also see this library as in beta. Use it on your own risk.
An inspiration what you could do with it:
Read data from cells and use it on your site
(sync your menu for your restaurant website, show/count your current projects, show how many available items are in stock, show office hours, team membersā¦)
Fill a table with data
(create a web form to submit data into coda, count events on your site)
Use coda controls to control your website
(create a āmood-sliderā next to your to-do list that shows your motivation and then change the colors/images of your website based on your acutal mood)
A basic example how to get data from a cell:
Click to see the table in Coda
$coda = new CodaPHP('<API TOKEN>'); // Create a new instance
$result = $coda->getRow('<DOC ID>', 'Products', 'Goatmilk'); // Get the row with name 'Goatmilk'
echo $result['values']['Price']; // Output Price value of this row
This will output 14.9 on the page.
More examples and a documentation to all functions is provided in the readme on Github.
Updates and contribution
First of all thanks to @oleg for your early feedback!
Iāll try to keep the library up to date whenever new API features are released.
If your find bugs, have problems implementing it or if have some suggestions, donāt hesitate to contact me Also, it would be cool if you share your results if you implement it somewhere.
Thanks for your contribution, @Daniel_Stieber! Weād linked to your repository on our API docs under a new āThird-party librariesā section. If anyone else has a library for our API theyād like added there, get in touch.
Thanks for adding this, Iām trying to use an API for the first time and Iām getting and error.
Fatal error : Uncaught Error: Class āCodaPHPā not found in /Users/juan/Documents/Sites/coda-api/index.php:235 Stack trace: #0 /Users/juan/.composer/vendor/laravel/valet/server.php(158): require() #1 {main} thrown in /Users/juan/Documents/Sites/coda-api/index.php
So far Iāve only installed it through composer and added the following to my index.php file:
require ā./vendor/autoload.phpā; $coda = new CodaPHP(ā<YOUR API TOKEN>ā);
// List all your docs
$result = $coda->listDocs(); var_dump($result);
Are you able to develop your demo a bit further maybe using a simple form with a submit button?
Iām keen to use my own forms so I can get a simple design layout that matches my site and also having an option to gather the data in an A4 format so I can email / post invoices. I just need a few demoās to get my started so I can work out how itās done.
Iām taking it that the API key will also be visible?
When I was looking at APIs when I was using Airtable, I believe they were talking about a proxy to not only hide the API key but also combat Airtableās five requests per second per base rate limit. Does Coda have a limit like this?
I will enhance CodaPHP when new features in the Coda API will be available or bugs are coming up. Currently it should cover all available API methods.
The API Key is visible to all people who have access to your server. Since PHP is a server-sided programming language, it only passes results to the browser/user, no plain code. So there should not be any way for a website visitor to get your API Key. I guess this is as secure as every āconfig.phpā with mysql login data etc. But yes, everyone with ftp server access can get the API Key and has full access to all your docs, so be careful with it.
Regarding rate limit: The docs say, that there is a āreasonable rate limitā. You can find more about this here.
Do you mean a simple online form that creates rows in a coda table?
@Daniel_Stieber Iām curious how you sort and filter data once you receive the response? For instance, I wanted to filter the returned rows using the listRows function but couldnāt find the right syntax to use the query parameter from the List rows endpoint in the API. I saw in your documentation for ways to use the query parameter to search docs, but the query parameter in the List rows endpoint needs a key and value. I thought ['query' => array('Food Group' => 'Grains/Starches')] might work in this scenario but it didnāt.
listRows() was not handling the query right! I fixed that issue in the current development version: https://github.com/danielstieber/CodaPHP/tree/develop
I already tried it with your code, and it worked fine. You can even shorten the array syntax: $rows = $coda->listRows($docID, $tableID, ['query' => ['Food Group' => 'Grains/Starches']]);
Maybe you can give it a shot.
Before I release 0.0.3 with the fix, I have one question to @oleg or someone of the API team:
Is it possible to add multiple filters in a query in the listRows method and how would a request look like? (like where ab=xy and cd=wy)
I was not able to do it or to find out the right syntax. CodaPHP currently only translates one query, but if the API can do it, Iād like to implement it too.
I guess in most scenarios it would make sense to fetch (and maybe even cache) all rows and filter it down with php locally. so no big deal until there is no āfree plan with limited rowsā
Very nice! Love that you were able to use it in a really useful project!
Do you have some feedback on the library? Like, was something not you expected it to be, or do you see the need of some more data formatting options or something?
Iāve realized that the API allows you to duplicate docs as well. This is not implemented yet and will be part of a future update.
thanks @Daniel_Stieber. For this project no. but i am working on another Wordpress plugin which will be more involved.
so far its pretty simple and self explanatory. might have some questions for the next project.
Thank you, thank you , thank you! This is exactly what I was looking for. I want to use Coda for our companyās intranet, to include dynamic reporting for our employees and was struggling to find a good solution for building web forms to update a Coda table. Thanks again for putting this together and making it publicly available!