Update RESTful API to allow for changes made externally

Bug #538235 reported by bgimpert
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Open Library
Confirmed
Medium
Anand Chitipothu

Bug Description

Allow for users in general to modify objects by sending a PUT request to the resource URL with appropriate Content-Type header. This probably means some sort of authenticated HTTP session, etc. Definitely would like to add new IDs to an edition in code. Also include an example or two in the API documentation. (Currently a TODO.)

Revision history for this message
George (george-archive) wrote :

Anand - Ben is a friend here in SF who's looking to help us out in a variety of ways. Right now, he's connecting OLID, ISBN and Goodreads IDs and we need to find a way to help him write that data to our editions.

What do you think? What's the best way to do this?

Changed in openlibrary:
assignee: nobody → Anand Chitipothu (anandology)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
bgimpert (ben-somethingmodern) wrote :

Simple of some OpenLibrary -> Goodreads ID mappings, that we should be able to programmatically add to OpenLibrary entries via the RESTful API.

Revision history for this message
George (george-archive) wrote :

A note from Otis at Goodreads about the idea:

"I'm not sure why you'd need to keep the mappings though? Our API lets you lookup by ISBN or Goodreads ID, so you shouldn't need the Goodreads IDs. Maybe if I understood more about what exactly you are doing I could help? In general though, we don't actually rate limit developer accounts (yet), though we do monitor things and shut down accounts that are going haywire. So if you needed to up your activity for a few days, preferrably off-hours, that would be ok."

And my reply:

We want to write Goodreads IDs into Open Library, against their corresponding OL records. I suppose we could ping GR every time we load an edition page to see if there's a GR page available, but...

You can see an example of the Goodreads ID in situ here:
http://upstream.openlibrary.org/books/OL22842232M/Beautiful_creatures

We'd like to put links like that on any edition record we can map to.

Revision history for this message
George (george-archive) wrote :

Anand tells me that the write API already exists, he just needs to document. It'll take about an hour, and he'll try to do it this week.

(I think it would be good to control/corral access to the write API. IMO, it shouldn't be a free-for-all. Perhaps with a key, or by being placed in a certain user group, or...)

Revision history for this message
George (george-archive) wrote :

Hi George,

If it would help, we can just give you a csv dump with all isbns and goodreads_ids that we have. Then you could use the API for new stuff going forward...

Otis

---

Want that?

Revision history for this message
bgimpert (ben-somethingmodern) wrote : Re: [Bug 538235] Re: RESTful API for Changes

Definitely want it! Then we could just hit the Goodreads API with the script
I wrote as a part of getting new entries in the system.

On Tue, Mar 16, 2010 at 1:05 PM, George <email address hidden> wrote:

> Hi George,
>
> If it would help, we can just give you a csv dump with all isbns and
> goodreads_ids that we have. Then you could use the API for new stuff
> going forward...
>
> Otis
>
> ---
>
> Want that?
>
> --
> RESTful API for Changes
> https://bugs.launchpad.net/bugs/538235
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Open Library: Confirmed
>
> Bug description:
> Allow for users in general to modify objects by sending a PUT request to
> the resource URL with appropriate Content-Type header. This probably means
> some sort of authenticated HTTP session, etc. Definitely would like to add
> new IDs to an edition in code. Also include an example or two in the API
> documentation. (Currently a TODO.)
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/openlibrary/+bug/538235/+subscribe
>
>

--
Ben Gimpert
mobile (415)533-7847
<email address hidden>

Revision history for this message
George (george-archive) wrote : Re: RESTful API for Changes
Revision history for this message
bgimpert (ben-somethingmodern) wrote : Re: [Bug 538235] Re: RESTful API for Changes

Very cool. Now whenever Anand gets me API write access, I'll fire off a
giant update!

On Wed, Mar 17, 2010 at 11:04 AM, George <email address hidden> wrote:

> Here it is, Ben!
>
> http://www.goodreads.com/system/goodreads_isbns.csv.tgz
>
> --
> RESTful API for Changes
> https://bugs.launchpad.net/bugs/538235
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Open Library: Confirmed
>
> Bug description:
> Allow for users in general to modify objects by sending a PUT request to
> the resource URL with appropriate Content-Type header. This probably means
> some sort of authenticated HTTP session, etc. Definitely would like to add
> new IDs to an edition in code. Also include an example or two in the API
> documentation. (Currently a TODO.)
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/openlibrary/+bug/538235/+subscribe
>
>

--
Ben Gimpert
mobile (415)533-7847
<email address hidden>

Revision history for this message
Anand Chitipothu (anandology) wrote :

On 17-Mar-10, at 11:46 PM, bgimpert wrote:

> Very cool. Now whenever Anand gets me API write access, I'll fire
> off a
> giant update!

Ben, we would to distinguish between people and bots. Can you please
create a new account with username ending with Bot and let me know the
details?

You can use the olapi python library to access the API.

http://github.com/openlibrary/olapi/blob/master/olapi.py

And here is the sample code for adding goodreads ids.

from olapi import OpenLibrary

ol = OpenLibrary()
ol.login("SomeBot", "secret")

def add_identifier(book, id_name, id_value):
      ids = book.setdefault("identifiers", {})
      ids.setdefault(id_name, []).append(id_value)

def add_goodreads_id(olid, goodreads_id):
     book = ol.get(olid)
     add_identifier(book, "goodreads", goodreads_id)
     ol.save(book.key, book, "Added goodreads ID.")

def load():
     for line in open(filename):
         olid, isbn, goodreads_id = line.strip().split()
         add_goodreads_id(olid, goodreads_id)

if __name__ == "__main__":
      import sys
      load(sys.argv[1])

George (george-archive)
summary: - RESTful API for Changes
+ Update RESTful API to allow for changes made externally
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.