If you're already parsing the XML, what does it matter where it is in
the response? We're using Atom+XHTML so that any API URL works in a feed
reader as well, but the XHTML should be pretty trivial to parse.
> 2. Are there any plans afoot to offer the data in other formats. I was
> thinking specifically of JSON. I haven't yet checked to see whether a
> Zotero item can be completely mapped onto a JSON object (it's not easy
> to find even a documented Atom representation. Shouldn't it be on the
> same page as the REST API docs?), but again, it seems like an ideal
> choice for at least a subset of an item's data.
The write API�which we're currently putting the finishing touches
on�uses JSON, so item responses, at least, will be returnable as JSON
(i.e., content=json, as an alternative to the default content=html for
an XHTML 'content' block). We'll have to see if this makes sense for
other types of responses as well, but it's pretty easy to support if so.
Eventually the API will probably support returning items in various
bibliography formats�at least BIBO RDF�but that requires server-side
translation support, which is a little ways off.
I think it would be valuable to have JSON returned as an option.
>> 2. Are there any plans afoot to offer the data in other formats. I was
>> thinking specifically of JSON. I haven't yet checked to see whether a
>> Zotero item can be completely mapped onto a JSON object (it's not easy
>> to find even a documented Atom representation. Shouldn't it be on the
>> same page as the REST API docs?), but again, it seems like an ideal
>> choice for at least a subset of an item's data.
>
> The write API—which we're currently putting the finishing touches on—uses
> JSON, so item responses, at least, will be returnable as JSON (i.e.,
> content=json, as an alternative to the default content=html for an XHTML
> 'content' block). We'll have to see if this makes sense for other types of
> responses as well, but it's pretty easy to support if so.
>
> Eventually the API will probably support returning items in various
> bibliography formats—at least BIBO RDF—but that requires server-side
> translation support, which is a little ways off.
So again: what if some developer (like the OP) wants to help add this
support to help out. How do they do that?
Bruce
If you keep going down the JSON road, and want to support JSON
representations across the board It might make sense to do something
similar to what Google did with gdata. Or perhaps look at JSON-C?
[1] http://code.google.com/apis/gdata/docs/json.html
[2] http://code.google.com/apis/youtube/2.0/developers_guide_jsonc.html
//Ed
Not to fill in the blanks, but this is the source here:
https://www.zotero.org/svn/dataserver/trunk/
Is it wrong to assume patches are "welcome" on this list?
//Ed
I don't see much advantage to pure JSON representations of the Atom
feeds. The JSON we have running internally is pretty simple�basically
just the item field names and values (with arrays for creators and tags).
Something like JSON-C might be worth considering down the line as a
lightweight alternative to Atom+JSON. But I don't think there's any need
to worry about that unless people start finding Atom+JSON to be
prohibitively heavy.
It is not.
The problem you may run into (I have) is that if you slowly accrete
json serializations, you may find they start seeming a bit adhoc and
inconsistent as a whole. If you already have a consistent atom
serialization across the api (like gdata) it probably would pay
dividends to have a similar approach to the json. But hey, opinions
are cheap, particularly mine :-)
//Ed
+1 on what Ed is expressing here. Having to actually think carefully
about the JSON format seems to run counter to JSON's advantages
(simple serialization of native data structures), but in fact, pays
off handsomely in the medium/long term. And for building a RESTful
system, well-known, well-understood representation semantics
(*especially* regarding links) is critical. Atom-inspired JSON can,
in my experience, be quite a big win, since systems that interact with
your will share a basic (Atom-ish) understanding of your resources.
I like JSON-C, although I am not convinced it is the only/best game in
town. In fact, w/o a proper schema language, establishing
hard-and-fast JSON formats may be difficult. In my opinion, Atom
presents a meta-model (
http://www.dehora.net/journal/2008/10/07/magnificent-seven-the-value-of-atom/
) that is hard to beat. I think a JSON serialization should at least
aspire to that utility. (By "should" I mean "it would benefit all
concerned, now and in the future...").
A couple of examples:
We use this Atom-inspired JSON format in *all* of our widely diverse
digital collections:
Also, I think it might be very useful to give a close look at the
BibJSON format. Not so much Atom-inspired, but seems a v. good fit
for Zotero, nonetheless:
http://www.bibkn.org/bibjson/index.html#mozTocId220879
And of course, with good documentation and Google's backing, JSON-C is
a fine choice as well.
--Peter Keane
> But hey, opinions
> are cheap, particularly mine :-)
>
> //Ed
>
> --
> You received this message because you are subscribed to the Google Groups "zotero-dev" group.
> To post to this group, send email to zoter...@googlegroups.com.
> To unsubscribe from this group, send email to zotero-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/zotero-dev?hl=en.
>
>
To be clear, the JSON we'll be offering for the write API is a
substitute for the XHTML currently included in the 'content' block of
Zotero Atom responses (e.g. https://api.zotero.org/groups/1/items).
We're not serializing item data as Atom beyond the standard Atom fields,
which provide limited summary information for the full item data in
'content'. The point is to be a direct, lossless representation of
Zotero's internal data model for use in building tools that modify
Zotero data (e.g., zotero.org).
I think this will be a worthy discussion to have (and yes, I do see your
point about the value of the Atom link semantics) if we end up offering
a format=json response�as opposed to a content=json Atom response�but
there are no current plans to do so. That could change if there was
significant demand.
switch ($this->queryParams['format']) {
case 'atom':
$this->responseXML = Zotero_Atom::createAtomFeed(
$this->getFeedNamePrefix($this->objectLibraryID) . $title,
$this->uri,
$items,
$totalResults,
$this->queryParams,
$this->apiVersion
);
break;
case 'bib':
echo Zotero_Cite::getBibliographyFromCiteServer($items, $this->queryParams['style'], $this->queryParams['css']);
exit;
default:
throw new Exception("Invalid format");
}
could be reorganized just a little to make the request scoped state more explicitly defined and reused across serializations:On 3/1/11 11:06 PM, Peter Keane wrote:
On Tue, Mar 1, 2011 at 9:12 PM, Ed Summers<e...@pobox.com> wrote:
On Tue, Mar 1, 2011 at 3:22 PM, Dan Stillman<dsti...@zotero.org> wrote:
I don't see much advantage to pure JSON representations of the Atom feeds.
The JSON we have running internally is pretty simple—basically just the item
field names and values (with arrays for creators and tags).
The problem you may run into (I have) is that if you slowly accrete
json serializations, you may find they start seeming a bit adhoc and
inconsistent as a whole. If you already have a consistent atom
serialization across the api (like gdata) it probably would pay
dividends to have a similar approach to the json.
+1 on what Ed is expressing here. Having to actually think carefully
about the JSON format seems to run counter to JSON's advantages
(simple serialization of native data structures), but in fact, pays
off handsomely in the medium/long term. And for building a RESTful
system, well-known, well-understood representation semantics
(*especially* regarding links) is critical. Atom-inspired JSON can,
in my experience, be quite a big win, since systems that interact with
your will share a basic (Atom-ish) understanding of your resources.
To be clear, the JSON we'll be offering for the write API is a substitute for the XHTML currently included in the 'content' block of Zotero Atom responses (e.g. https://api.zotero.org/groups/1/items). We're not serializing item data as Atom beyond the standard Atom fields, which provide limited summary information for the full item data in 'content'. The point is to be a direct, lossless representation of Zotero's internal data model for use in building tools that modify Zotero data (e.g., zotero.org).
I think this will be a worthy discussion to have (and yes, I do see your point about the value of the Atom link semantics) if we end up offering a format=json response—as opposed to a content=json Atom response—but there are no current plans to do so. That could change if there was significant demand.
--You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To post to this group, send email to zoter...@googlegroups.com.
To unsubscribe from this group, send email to zotero-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/zotero-dev?hl=en.
Group membership calls are not public, but there's been some demand for
a call to determine the libraries the current API key has access to,
along with permissions for each library. So we'll likely be adding that.
Addendum: Faolan reminds me that /groups with an API key returns the
groups that the key has access to (including public ones the user
belongs to even if the key doesn't have explicit permissions for it).
Sorry, make that /users/<userID>/groups. I've added this call to the API
doc.
Concerning RESTful practice, it's import to honor the HATEOAS
constraint (Hypermedia as the Engine of Application State), meaning
that with any representation, related representations of interest
should be actual hypertext links. So Instead of parsing the
representation to find a group id and then constructing the proper URL
(that you know how to construct based on some documenation somewhere),
you might have, say, within a representation of a "user" the following
link:
<link rel="http://zotero.org/relation/user_groups"
href="http//zotero.org/user/johndoe/1234/groups">
Documentation for an API should only need to document:
-- what the resources of interest are (users, user groups, titles, etc.)
-- what standardized formats are used for representations (Atom.XHTML,
JSON -- in which case the actual structure of the JSON, noting how
user agent recognizes a hyperlink needs to be specified)
-- define the link rels used (preferably using those found in the IANA
link registry: http://www.iana.org/assignments/link-relations/link-relations.xml
if/when applicable).
--peter
1) The key doesn't have access to your private group.
2) Keys weren't properly providing access to public groups they didn't
have explicit access to. (We had decided they should but apparently
hadn't made the change.) Fixed now.
> Similarly, the 'alternate'
> link (http://zotero.org/users/436/groups) gives me a 'page not found'
> error.
The API currently displays rel="alternate" links in a few places where
it shouldn't.
I think you need to use the group's ID number, not its name, in the URL.
Best,
Jeremy
--
Jeremy Boggs · Associate Director of Research · Center for History and
New Media · George Mason University · chnm.gmu.edu · @clioweb
No. <id> is just a unique identifier. <link rel="self"/> tells you the
API URI.
But we will return a 400 instead of a 500 for that error.