I like to think that we have a pretty decent Lighthouse API. It doesn’t handle attachments yet (have you tried to upload multipart file content with ruby? yuck!), and a few other things, but it’s good enough to enable the creation of something like Lighthouse Keeper.
Jeremy and I were just discussing some ideas for a new Lighthouse client library (more on that later once it’s not so vaporous. Then Kyle chimes in:

Zing!
There are definitely some pain points we need to address there. I’ve mostly been focusing on issues like poor/outdated documentation and major omissions (attachments). But in the meantime, I’ll probably throw out some helper API calls to make some of this common stuff better.
If you happen to follow edge Rails work, I recently posted about autoloading api schemas in ActiveResource. This works by requesting the #new action and using those values as the defaults for your newly instantiated objects. This is fine and dandy, and has been supported and included in the Rails resource scaffold for awhile. But, how do you deal with properties that are filled by drop downs? It’d be nice to be able to return the available values in the returned data from the #new action:
{"ticket":
{"title": "", "assigned_user_id": null}
"attributes":
{"assigned_user_id": [
{"id":1, "name": "bob"}, {"id":2, "name": "fred"}]}}
That example doesn’t really translate well to XML. I strongly prefer JSON, but there’s no way I can remove XML support. So, here are a couple other ideas we had:
<ticket>
<assigned_user_id nil="true" />
<valid_options>
<assigned_user_id>
<assigned_user>
<id>1</id>
<name>bob</name>
</assigned_user>
</assigned_user_id>
</valid_options>
</ticket>
This puts the available values under a single property. Though it makes the nested xml harder to deal with. Here’s another approach.
<ticket>
<assigned_user_id nil="true" />
<assigned_user_id_options>
<assigned_user>
<id>1</id>
<name>bob</name>
</assigned_user>
</assigned_user_options>
</ticket>
These conventions allow client libraries like ActiveResource to properly filter out the values that aren’t actual property values into some list. Either way would allow you to build your own new object form from a single call. Does anyone else have any thoughts on making this possible? Are there existing APIs that I could look at? Should I keep it simple and rely on the client to sufficiently load and cache these options?


3 Comments
I think it depends on your usage of the API. A lot of users will likely be using it just to add tickets, so if you can give them the additional information they need, like assigned users, milestones, etc then it reduces the complexity of their code and the number of API requests they need to make.
For applications like Lighthouse Keeper which do more than just add tickets, something like this won’t be quite as beneficial. I’m already downloading the data and caching it locally for other things such as searching so I never actually make API calls to get new templates. It’d be a good addition for the majority of users though I should think.
As for what to choose, I think the valid options tag would work best, as all of the options for each field with choices can be put in there, which is quite a bit cleaner.
I’m leaning towards that too. It’s only a single key that you have to ignore/deal with, vs a bunch of keys. Maybe even abstract it a bit more:
It’s great to hear that work is being done to update the API. Did some of these (or other) API changes go live in the past few days by chance? I use the API for more than adding tickets…I update with new comments, status, etc as well. Updating tickets through the API seems to be broken all of a sudden: http://help.lighthouseapp.com/discussions/problems/471-error-when-updating-a-ticket-through-the-api
Make your voice heard
Sorry, but comments are closed for this item.