Logo di BookMooch
 
home sfoglia informazioni iscriviti accedi
APIs a BookMooch
API OVERVIEW >
?



  • asin: all information about a book (or list of books).
    • Give it an asins= list of ASINs (or ISBNs) and it will return an XML document (documentation) of all the data for those asins.
    • If the ASIN does not exist inside the BookMooch data, no data is returned for it in the XML document.
    • Optional inc= parameter will restrict the output to only the fields named, ie inc=Edition+ISBN+Binding

  • pending: all information about pending mooch transaction (or list of transactions).
    • Pending transactions have the form of "userid/number" as in "johnbuckman/12".
    • Give it an ids= list of transaction ids and it will return an XML document (documentation) of all the data for those transaction. If the id does not point to a current pending transaction, no data is returned for it in the XML document.
    • Optional inc= parameter will restrict the output to only the fields named, ie inc=status+giver.
    • If you call "pending_confidential" instead of "pending", then HTTP-Auth is required (you must be this transaction's sender or receiver) and then postal address information is also included in the XML response.
    • You can find out what pending transactions a user has with a call to "/api/userid?userids=buckman_ca&inc=pending_give+pending_receive"

  • userid: all information about a given BookMooch user (or list of users).
    • Give it an userids= list of user ids and it will return an XML document (documentation) of all the data for those users.
    • If the userid does not point to a current BookMooch user, no data is returned for it in the XML document.
    • Optional inc= parameter will restrict the output to only the fields named, ie "inc=asins_listed+statusmsg".

  • wishlist: is an ISBN on a wishlist?
    • Give it an asin= list of ASINs (or ISBNs) and it will return a carriage-return separated list of ASINs that are on wishlists at BookMooch.
    • n=1 option returns number of people with that book on their wishlist.
    • o=xml option returns XML output.

  • amazon_add: add the given ASINs from Amazon into the BookMooch database.

  • userbook: add given ISBNs to user's inventory/wishlist/savelater.
    • Give it an asin= list of ASINs (or ISBNs) and it will return a carriage-return separated list of ASINs that were successfully added.
    • o=xml option returns XML output.
    • Requires http-auth name and password of user to add to. target= must be 'inventory' or 'wishlist' or 'savelater'.
    • Change action= to 'del' to delete instead of adding.
    • Optional: when adding to inventory, the &reserve_days=7 parameter will reserve the book for 7 days. You can specify any number of days you like or &reserve_days=0 to reserve the book forever. You also need to specify &reserve_userids= which is a space-separated list of userids who this book reserved for. Specify &reserve_userids=friends if you want the book to be reserved for all your friends. To remove the reservation via the API, you should remove the book from your inventory and then re-add it without a reservation.
    • Note: only works for ASINs that are already in the BookMooch database: to add a book from Amazon into the BookMooch database, use the "amazon_add" api

  • moochable: is an ISBN available for mooching?
    • Give it an asin= list of ASINs (or ISBNs) and it will return a carriage-return separated list of ASINs that are available for mooching (ie, on someone's inventory) at BookMooch.
    • n=1 option returns the count of the number of people with that book in their inventory, while n=2 returns a comma-separated list of userids with that book in their inventory.
    • o=xml option returns XML output with all fields.

  • mooch: mooch the given ASIN (asin=) from the specified user (giverid=) requesting that the book be sent to the specified postal address (address=) and country (country=).
    • If the output format is text, then the first line is the result code, the 2nd line is a short text version of the result code, and then the HTML resulting from the request is on the 3rd line and thereafter.
    • o=xml option returns XML output.
    • country= should be a two-letter ISO standard country code
    • If the output format is XML, these fields are all returned in an XML encoded format.
    • Optional comment= is stored in the mooch request and displayed to the book sender in their email and web interface.
    • The result code is set to 1 on success, or a number less than zero on failure.
    • Before calling "mooch" you should have called "moochable" to find the userids who are giving this book, and picked the userid you wanted to mooch from.
    • If you want to mooch books for only 1 point (ie, no international mooches), be sure to only mooch from userids who are in the same country as you are.
    • Requires http-auth name and password of the user you want to be when mooching.

  • pending_action: perform an action on a pending book mooch transaction.
    • Requires http-auth name and password of the appropriate book giving or receiving member in this pending transaction.
    • Possible actions are "accept" "cancel" "delay" "lost" "sent" "reject" "received" "received_forced" "remind_received" "remind_send".
    • An id= and action= is always required. All actions can take an optional comment=.
    • Output defaults to text, but can be set to XML with an o=xml option on the URL.
    • In text output, the first line is a 0 (success) or negative number (failure) indicating the final status of this action.
    • The 2nd line is a one-line text description of the final status.
    • The third and following lines is the HTML response for this action that would normally have been displayed in the BookMooch web interface.
    • Most pending actions also require param1= or param2= or param3= as follows:
      • for "action=accept"
        • param1="text string describing how soon you think you can send this book"
        • Example URL: pending_action?id=johnbuckman/33&action=accept&comment=x&o=xml
      • for "action=delay"
        • param1="text string describing the length of the delay"
        • Example URL: pending_action?id=johnbuckman/33&action=delay&comment=x¶m1=a+few+days&o=xml
      • for "action=remind_received"
        • No additional parameters are needed, only the id= is used for this call.
        • Example URL: pending_action?id=johnbuckman/32&action=remind_received&o=xml
      • for "action=remind_send"
        • No additional parameters are needed, only the id= is used for this call.
        • Example URL: pending_action?id=johnbuckman/32&action=remind_send&o=xml
      • for "action=received"
        • param1="Feedback score" and should be set to 0="NO OPINION: neither good nor bad (+0 feedback) or -1="UNHAPPY: transaction did not go well (-1 feedback)" or 1="HAPPY: everything ok (+1 feedback)"
        • param2="Optional, publicly viewable comments about this cancelled transaction."
        • Example URL: pending_action?id=johnbuckman/33&action=received&comment=x¶m1=0¶m2=great+condition+thanks&o=xml
      • for "action=received_forced"
        • param1="Feedback score" and should be set to 0="NO OPINION: neither good nor bad (+0 feedback) or -1="UNHAPPY: transaction did not go well (-1 feedback)" or 1="HAPPY: everything ok (+1 feedback)"
        • param2="Optional, publicly viewable comments about this cancelled transaction."
        • Example URL: pending_action?id=buckman_ca/118&action=received_forced&comment=x&o=xml
        • Note: only the book sender can force the book as received, and only after a reminder has been sent (ie action=remind), and only after 42 days have elapsed since the book was marked as sent
      • for "action=cancel"
        • param1="Why are you cancelling?" and should be set to 0="I changed my mind (or some other reason)" or 1="The book owner never responded"
        • param2="Feedback score" and should be set to 0="NO OPINION: neither good nor bad (+0 feedback) or -1="UNHAPPY: transaction did not go well (-1 feedback)"
        • param3="Optional, publicly viewable comments about this cancelled transaction."
        • Note: the "Message to book owner:" field is filled in with the comment= value on the URL.
        • Example URL: pending_action?id=buckman_ca/117&action=cancel&comment=x&o=xml¶m1=0¶m2=-1¶m3=never+heard+back
      • for "action=lost"
        • comment="Any comments you want to write to explain what happened."
        • Example URL: pending_action?id=johnbuckman/33&action=lost&comment=x&o=xml
      • for "action=sent"
        • comment="Any comments you want the requestor to get about your sending of this book."
        • Example URL: pending_action?id=johnbuckman/33&action=sent&comment=x&o=xml
      • for "action=reject"
        • comment="Any comments you want the requestor to get, to explain why you can't send the book." (required)
        • param1=either "r" to mean "Remove this book from your inventory, so that no-one else can ask you for it" or "l" meaning "Put the book back in your inventory for someone else to mooch"
        • Example URL: pending_action?id=johnbuckman/33&action=reject&comment=x¶m1=r&o=xml




    Passing large field values

    All the API calls can take their parameters either on the URL (ie HTTP GET) or in the POST data section.

    The GET method has the advantage of being easy to debug.

    The POST method has the advantage of being able to pass arbitrarily large fields in, such as a large number of ASINs.



    Error handling

    When no data is found for an API call or your parameters are missing or invalid, this is indicated with a "result_code" field that has a negative value. For each kind of error, a different negative number is returned. The "result_text" field is a text description of the error. Here is an example for a call to "userid?userids=john_smith"

    <?xml version="1.0" encoding="UTF-8"?>
    <userids>
    <userid>
    	<id>john_smith</id>
    	<result_code>-1</result_code>
    	<result_text>no data found</result_text>
    </userid>
    </userids>




    All these APIs are fairly high performance (except those that cause an email to be sent out), but try to not send more than 10 requests/second (or serialize your requests), so feel free to use them in your applications.



    Feel free to
    EMAIL JOHN >
    if you have any questions or need something that isn't available





  • [Correggi le traduzioni]