smugmug.albums.get and more levels of hierarchy in the future?
jfriend
Registered Users Posts: 8,097 Major grins
I plan to use smugmug.albums.get to display a site index and I'd like to write the JS code in a way that won't have to be changed when Smugmug starts supporting more levels of hierarchy than just categories and subcategories. Is there any way to do that?
As of now, the response looks like this which specifically calls out Category and SubCategory which doesn't look to me very extensible to additional levels of hierarchy:
Is there any way to write forward looking code that won't have to be rewritten when more levels of hierarchy are supported? Is this part of the API going to be revamped ahead of the launch of more levels of hierarchy so code can prepare?
As of now, the response looks like this which specifically calls out Category and SubCategory which doesn't look to me very extensible to additional levels of hierarchy:
{ "stat": "ok", "method": "smugmug.albums.get", "Albums": [ { "id": 5608869, "Key": "vwzCG", "Category": { "id": 315305, "Name": "Kenya", "URL": "http://jfriend.smugmug.com/Kenya" }, "SubCategory": { "id": 568323, "Name": "Highlights", "URL": "http://jfriend.smugmug.com/Kenya/Highlights" }, "Title": "Landscapes", "URL": "http://jfriend.smugmug.com/Kenya/Highlights/Landscapes/5608869_vwzCG" }, { "id": 5608779, "Key": "ZJ27n", "Category": { "id": 315305, "Name": "Kenya", "URL": "http://jfriend.smugmug.com/Kenya" }, "SubCategory": { "id": 568323, "Name": "Highlights", "URL": "http://jfriend.smugmug.com/Kenya/Highlights" }, "Title": "Animals", "URL": "http://jfriend.smugmug.com/Kenya/Highlights/Animals/5608779_ZJ27n" }, ...
Is there any way to write forward looking code that won't have to be rewritten when more levels of hierarchy are supported? Is this part of the API going to be revamped ahead of the launch of more levels of hierarchy so code can prepare?
--John
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
0
Comments
We are working on a setup that enables you to receive info and access to upcoming changes some time before full launch. Follow the forum for more info.
http://msphoto.smugmug.com
http://twitter.com/tasmanic
So, if I understand what you're saying, this method will break in the future when you release more levels. Bummer, that's unfortunate to have to design code now that you already know will break in the future. The fact that you're working on more levels of hierarchy has been known for a long time - I'm surprised the API isn't out in front of that to keep newly written code from breaking in the future.
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Want faster uploading? Vote for FTP!
John,
No, that is not correct. When we release more levels of hierarchy, we will be releasing a new api version which will support the new hierarchy scheme. The old api versions will continue to work with the existing cat/subcat restrictions (for a period of time to give developers a chance to migrate).
Cheers,
David
SmugMug API Developer
My Photos
Why not release a new response format now that lets developers code for both the present and the future rather than making us write one way now and have to rewrite in the future?
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
From an api perspective, not all of the specifics has been bedded down yet. As you mentioned in your original post, the current method isn't very extensible.
Currently hierarchy-wise, you defined a CategoryID and SubCategoryID for an album. For the new format, these parameters will most probably be replaced by a ContainerID or ParentID, rather than adding a third parameter like SubSubCategoryID.
I haven't determined yet how practical (or efficient) it will be to return the entire hierarchy for every album in the smugmug.albums.get response.
Off the top of my head, one possible response format could be as below, where we just return the immediate parent (note, for ease of a sample, I used CategoryID as the ContainerID...that won't be the case in reality)
As for backwards compatibility with older api methods, we haven't yet determined whether albums in a deeper level of hierarchy would be returned with a truncated hierarchy (cat/subcat only) or excluded from the response altogether.
Hope that makes some sense.
Cheers,
David
SmugMug API Developer
My Photos
I guess I'm being a pain about this because I HATE writing code that I know will have to be rewritten in the future. It violates one of my principles of quality software development.
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
umm, no that's not correct either...the new response format will be rolled out on a new api version (ie. most likely 1.4.0), so your code will function exactly as it does now on whatever api version you are currently using, until you upgrade to that version and modify your code accordingly.
SmugMug API Developer
My Photos
If you introduced a new response format that can represent the additional levels of hierarchy now, then people could write code once that would work with the existing two levels now and the additional levels of the future - no rewrite needed.
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
SmugMug API Developer
My Photos
That's not the best way for anyone and it's a lot of extra work for me to support. I'd prefer not to have to put anyone through that (including all the extra work for me to support them). The fact that customizations can regularly break on Smugmug is one of the things that makes it a pain to have a highly customized site on Smugmug. I'm trying to champion there being less breakage, both selfishly for my own support burden, because people using customizations will have better sites and less maintenance and because it makes a better service overall for you.
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Nothing is remotely broken there.
SmugMug API Developer
My Photos
Take the example of a customer who installs this customization now to show a hierarchical site index on their site. Then you release N levels of hieararchy and they modify their site to use more levels. Then, ask that customer if their site index is functioning correctly. They will say "No" - it's not working correctly (broken).
You can argue a technicality whether it's the API function that's broken or not - the point is what the customer sees/feels and their functionality will be broken. That's what I'm trying to avoid and I'm surprised you don't seem interested in helping. I can't believe that you don't see the value in releasing an API response now that can be written to once and will work 100% correctly both now AND after N levels of hierarchy are released. If you don't understand that value to your API consumers, then there's not much I can do here as it's a pretty basic feature of a quality API (it continues to deliver complete results even as new features are added and doesn't have to be recoded by people using it).
If you don't care to see my point here, I guess I'll be done now and SM customers will just have to deal with customizations that require maintenance in the future (what I'm trying to avoid).
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
Want faster uploading? Vote for FTP!
I'm not sure how outlining the facts is being ungrateful.
SmugMug API Developer
My Photos
Want faster uploading? Vote for FTP!
Portfolio • Workshops • Facebook • Twitter
Samir, Devbobo works full time on the API for us and the feedback John has given is invaluable.
Portfolio • Workshops • Facebook • Twitter
Want faster uploading? Vote for FTP!
For a long, long time, we've devoted a TREMENDOUS amount of $$$$$ and human resource into our API, and have fostered many, many, many apps from it.
Portfolio • Workshops • Facebook • Twitter
The stats API is still broken, btw. :cry
Want faster uploading? Vote for FTP!
I suspect that devbobo and I just don't communicate well on the forums here because I know he's acted on previous suggestions I've made in the last few months: session-less API access that works when site is in read-only mode is in 1.3 and custom size option that makes it easier to deal with new image URLs is also in 1.3. So, it seems like the spirit is willing and hopefully we just have a communication glitch on this issue.
So, I hope my point was clear enough to be understood and the API will be modified to support N levels long before N levels actually ships (as soon as possible would be best).
Meanwhile, I guess that I have no other choice now but to write code that uses the current (old) format of the API that will have to be modified later to support N levels. That's what I was hoping to avoid.
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question
We understand your desire and need to have any new response format or API available before our customers have access to deeper hierarchies.
What I was trying to say is that we don't have it at the moment. So if you build something NOW we unfortunately can't tell you how to make it future proof since we don't have full design or implementation for those APIs.
I'm also saying that we will make this available as soon as we can, and definitely before our customers have access to the functionality.
http://msphoto.smugmug.com
http://twitter.com/tasmanic
Homepage • Popular
JFriend's javascript customizations • Secrets for getting fast answers on Dgrin
Always include a link to your site when posting a question