{"body": {"type": "/type/text", "value": "\r\n\r\nOpen Library provides RESTful API for accessing resources in multiple formats.\r\n\r\n* [[#content|Content]]\r\n* [[#query|Query]]\r\n* [[#history|History]]\r\n* [[#save|Save]]\r\n* [[#status_codes|Status Codes]]\r\n\r\n\r\n## Content\r\n\r\nTo request any content, the requested format can be specified using `Accept:` header or as part of the URL.\r\nThe currently available formats are JSON and RDF.\r\n\r\n $ curl http://openlibrary.org/a/OL1A.json\r\n {\r\n \"name\": \"Sachi Rautroy\", \r\n ...\r\n }\r\n $ curl -s -H 'Accept: application/json' http://openlibrary.org/b/OL1M\r\n {\r\n \"name\": \"Sachi Rautroy\", \r\n ...\r\n }\r\n \r\nOptional `callback` parameter can be specified when the requested format is JSON.\r\n\r\n $ curl http://openlibrary.org/a/OL1A.json?callback=process\r\n process({\r\n \"name\": \"Sachi Rautroy\", \r\n ...\r\n });\r\n \r\nThe RDF format is available for books and for authors.\r\n\r\n $ curl http://openlibrary.org/b/OL6807502M.rdf\r\n \r\n \r\n \r\n \r\n Lawrence Lessig\r\n \r\n \r\n \r\n Code and other laws of cyberspace\r\n Basic Books\r\n New York\r\n 1999\r\n xii, 297 p. :\r\n ....\r\n \r\n $ curl -H 'Accept: application/rdf+xml' http://openlibrary.org/b/OL6807502M.rdf\r\n \r\n \r\n \r\n \r\n Lawrence Lessig\r\n \r\n \r\n \r\n Code and other laws of cyberspace\r\n \r\n\r\n \r\n\r\n## Query\r\n\r\nThe Query API allows querying the Open Library system for matching objects. \r\n\r\n $ curl 'http://openlibrary.org/query.json?type=/type/edition&authors=/a/OL1A'\r\n [\r\n {\r\n \"key\": \"/b/OL1M\"\r\n }, \r\n {\r\n \"key\": \"/b/OL4731M\"\r\n }, \r\n ...\r\n ]\r\n $ curl -H 'Accept: application/json' 'http://openlibrary.org/query?type=/type/edition&authors=/a/OL1A'\r\n [\r\n {\r\n \"key\": \"/b/OL1M\"\r\n }, \r\n {\r\n \"key\": \"/b/OL4731M\"\r\n }, \r\n ...\r\n ] \r\n\r\nAdditional properties of each object can be requested by passing a query parameter with empty value.\r\n\r\n $ curl 'http://openlibrary.org/query.json?type=/type/edition&authors=/a/OL1A&title='\r\n [\r\n {\r\n \"key\": \"/b/OL1M\", \r\n \"title\": \"Kabit\\u0101.\"\r\n }, \r\n {\r\n \"key\": \"/b/OL4731M\", \r\n \"title\": \"Sacci Ra\\u0304utara\\u0304y\\u0307a grantha\\u0304bal\\u0323i\\u0304.\"\r\n }, \r\n ...\r\n ]\r\n\r\nAll properties can be requested using a special query parameter `*`.\r\n\r\n $ curl 'http://openlibrary.org/query.json?type=/type/edition&authors=/a/OL1A&*='\r\n [\r\n {\r\n \"pagination\": \"8, 304 p.\", \r\n ...\r\n \"title\": \"Kabit\\u0101.\", \r\n ...\r\n \"key\": \"/b/OL1M\", \r\n ...\r\n },\r\n ...\r\n ]\r\n\r\nOptional `limit` and `offset` parameters can be passed to limit the number of requests and offset in the results respectively.\r\nUnless any limit is specified, the responses is limited to 20 entries. Maximum allowed value of `limit` is 1000 due to performance reasons.\r\n\r\n $ curl 'http://openlibrary.org/query.json?type=/type/edition&authors=/a/OL1A&limit=2'\r\n [\r\n {\r\n \"key\": \"/b/OL1M\"\r\n }, \r\n {\r\n \"key\": \"/b/OL4731M\"\r\n }\r\n ]\r\n\r\nQueries can also be specified by passing the query as JSON dictionary.\r\nThe above mentioned approach is just a syntactic-sugar for this.\r\n\r\n # curl fails because it doesn't escape query parameter\r\n $ wget -q -O - 'http://openlibrary.org/query.json?query={\"type\": \"/type/edition\", \"authors\": \"/a/OL1A\", \"title\": null, \"limit\": 2}'\r\n [\r\n {\r\n \"key\": \"/b/OL1M\", \r\n \"title\": \"Kabit\\u0101.\"\r\n }, \r\n {\r\n \"key\": \"/b/OL4731M\", \r\n \"title\": \"Sacci Ra\\u0304utara\\u0304y\\u0307a grantha\\u0304bal\\u0323i\\u0304.\"\r\n }\r\n ]\r\n\r\nPlease note that this API should not be used for bulk downloads. \r\nDumps of the entire data are provided at regular intervals and they can be used for bulk access.\r\n\r\n\r\n## History\r\n\r\nChange history of any object can be accessed by passing `?m=history` query parameter to the resource url.\r\n\r\n $ curl http://openlibrary.org/b/OL1M.json?m=history\r\n [\r\n {\r\n \"comment\": \"test\", \r\n \"created\": \"2008-10-14T08:58:48.091739\", \r\n ...\r\n },\r\n ...\r\n ]\r\n $ curl -H 'Accept: application/json' http://openlibrary.org/b/OL1M?m=history\r\n [\r\n {\r\n \"comment\": \"test\", \r\n \"created\": \"2008-10-14T08:58:48.091739\", \r\n ...\r\n },\r\n ...\r\n ]\r\n \r\nThe entries are sorted in the descending order of created time. \r\nThe number of entries are limited to 20 by default and a different limit can be specified by passing `limit` parameters. \r\nOptional `offset` parameter can also be specified to get results starting from an offset.\r\nMaximum allowed value of `limit` is 1000 due to performance reasons.\r\n\r\n $ curl http://openlibrary.org/b/OL1M.json?m=history&limit=2&offset=1\r\n [\r\n {\r\n \"comment\": \"test table of contents\", \r\n \"created\": \"2008-10-13T06:46:27.278809\", \r\n ...\r\n },\r\n {\r\n \"comment\": \"test\", \r\n \"created\": \"2008-09-12T14:37:30.974510\", \r\n ...\r\n }\r\n ]\r\n \r\nSupport for RSS and Atom formats will be available soon.\r\n\r\n## Recent Changes\r\n\r\nRecent changes is available in JSON, RSS and Atom formats.\r\n\r\n $ curl http://openlibrary.org/recentchanges.json\r\n [\r\n {\r\n \"comment\": \"new author\", \r\n ...\r\n },\r\n ...\r\n ]\r\n $ curl -H 'Accept: application/json' http://openlibrary.org/recentchanges\r\n [\r\n {\r\n \"comment\": \"new author\", \r\n ...\r\n },\r\n ...\r\n ]\r\n \r\nParameters, `type`, `key` and `author` can be specified to limit the results to modifications to objects of specified type, specified key and by an author respectively.\r\nAlso `limit` and `offset` can be specified to limit number of results and offset.\r\n\r\n $ curl http://openlibrary.org/recentchanges.json?type=/type/page\r\n ...\r\n $ curl http://openlibrary.org/recentchanges.json?author=/user/anand&offset=20&limit=20\r\n\r\nSupport for RSS and Atom formats will be available soon.\r\n\r\n\r\n## Login\r\n\r\nTo login to Open Library programatically, a POST request must be send to `/account/login` with `username` and `password` must be passed as a JSON dictionary. \r\n\r\n $ curl -i -H 'Content-Type: application/json' -d '{\"username\": \"joe\", \"password\": \"secret\"}' http://openlibrary.org/account/login\r\n HTTP/1.1 200 OK\r\n Set-Cookie: ol_session=\"/user/joe%2C2009-02-19T07%3A52%3A13%2C74fc6%24811f4c2e5cf52ed0ef83b680ebed861f\"; Path=/\r\n \r\nUpon successful login, a set-cookie header is returned in the response. \r\n\r\n\r\n## Save\r\n\r\nModifying objects can be done by sending a PUT request to the resource url with appropriate `Content-Type` header.\r\nThe currently supported format is only JSON.\r\n\r\n TODO: show an example\r\n \r\nPlease note that right now this only an internal API and works only from the localhost.\r\n\r\n\r\n## Status codes\r\n\r\n### 200 OK\r\n\r\nStatus code `200 OK` is returned when the request is handled successfully.\r\n\r\n### 400 Bad Request\r\n\r\nStatus code `400 Bad Request` is returned when there is any error in the provided input data.\r\nThe error message is specified in the response body.\r\n\r\n### 403 Forbidden\r\n\r\nStatus code `403 Forbidden` is returned for PUT/POST requests when the requesting user does not have the required permissions to modify the resource.\r\n\r\nThe request can be repeated by providing the required credentials.\r\n\r\n### 404 Not Found\r\n\r\nStatus code `404 Not Found` is returned when the requested resource is not found.\r\n\r\n### 500 Internal Server Error\r\n\r\nStatus code `500 Internal Server Error` is returned if handling the request causes any internal errors.\r\nDebug information about the error may be provided in the response to help trouble-shooting the issue."}, "created": {"type": "/type/datetime", "value": "2009-02-19T12:23:41.119991"}, "title": "Open Library RESTful API", "last_modified": {"type": "/type/datetime", "value": "2009-08-13T13:33:19.722564"}, "latest_revision": 7, "key": "/dev/docs/restful_api", "type": {"key": "/type/page"}, "id": 33886345, "revision": 7}