/api_sandbox
Type: /type/page
body: value: This is a place to experiment with Open Library API. See [API documentation](/dev/docs/api) for help.

<h2 class="api">get</h2>

<script src="/static/js/json2.js" type="text/javascript"></script>

<script>
query_count = 0;
queries = {};
function sample_query(textbox_id, title, query, nostringify) {
    query_count = query_count + 1;
    
   if (nostringify)
       queries[query_count] = query;
   else 
        queries[query_count] = JSON.stringify(query, null, "    ");
    
    var a = '<a href="#" id="QUERYCOUNT" dest_id="TEXTBOX_ID" onclick="return on_sample_query(this);">TITLE</a><br/>';
    a = a.replace("QUERYCOUNT", query_count);
    a = a.replace("TEXTBOX_ID", textbox_id);
    a = a.replace("TITLE", title);
    document.write(a);
}

function on_sample_query(a) {
    document.getElementById(a.getAttribute("dest_id")).value = queries[a.id];
    return false;
}
</script>


<div class="api">
<table cellpadding="0" cellspacing="0" border="0"><tr><td valign="top" width="50%">
<div class="query">
<b>Sample Queries:</b><br/><br/>

<script>
sample_query("key", "Get /",  "/", true);
sample_query("key", "Get /b/OL1001932M",  "/b/OL1001932M", true);
sample_query("key", "Get /i18n/type/edition/strings.en",  "/i18n/type/edition/strings.en", true);
</script>

<form action="/api/get" method="GET"  name="get" target="iget">
    <input type="hidden" name="text" value="true"/>
    <input type="hidden" name="prettyprint" value="true"/>
    <input type="hidden" name="stats" value="true"/>
    <input name="key" id="key" value="/" style="width: 100%; margin-top: 6px;" />
    <div class="button-border" style="margin-top: 6px;">
        <button type="submit" class="apiblue">Query</button>
   </div>
</form>
</div>
</td>
<td valign="top" class="arrow">&#x21D2;</td>
<td valign="top" width="50%">
<div class="response">
<b>Result:</b><br/>
<iframe name="iget" id="iget" width="100%">
</iframe>

</div>
</td></tr></table>   
</div>

<h2 class="api">things</h2>

<div class="api">
<table cellpadding="0" cellspacing="0" border="0"><tr><td valign="top" width="50%">
<div class="query">
<b>Sample Queries:</b><br/><br/>

<script>
sample_query("things_query", "Get all templates sorted by key.", {
    "key~": "/templates/*",
    "sort": "key"
});
sample_query("things_query", "Get 10 pages in the sorted order of title.", {
    "type": "/type/page",
    "limit": 10,
    "sort": "title"
});
sample_query("things_query", "Get 50 books written by Mark Twain.", {
    "type": "/type/edition",
    "authors": "/a/OL18319A",
    "limit": 50,
    "sort": "key"
});
</script>

<form action="/api/things" method="GET" target="ithings">
    <input type="hidden" name="text" value="true"/>
    <input type="hidden" name="prettyprint" value="true"/>
    <input type="hidden" name="stats" value="true"/>
    <textarea name="query" id="things_query" rows="10" style="margin-top: 6px;">
    </textarea>
    <br/>
    <div class="button-border" style="margin-top: 6px;">
        <button type="submit" class="apiblue">Query</button>
    </div>
</form>
</div>

</td>
<td valign="top" class="arrow">&#x21D2;</td>
<td valign="top" width="50%">
<div class="response">
<b>Result:</b><br/>
<iframe name="ithings" id="ithings" width="100%">
</iframe>

</div>
</td></tr></table>   
</div>

<h2 class="api">versions</h2>

<div class="api">
<table cellpadding="0" cellspacing="0" border="0"><tr><td valign="top" width="50%">
<div class="query">
<b>Sample Queries:</b><br/><br/>

<script>
sample_query("versions_query", "Get Recent Changes.", {
    "sort": "-created",
    "limit": 10
});
sample_query("versions_query", "Get history of /.", {
    "key": "/",
    "sort": "-created",
    "limit": 10
});

</script>

<form action="/api/versions" method="GET" target="iversions">
    <input type="hidden" name="text" value="true"/>
    <input type="hidden" name="prettyprint" value="true"/>
    <input type="hidden" name="stats" value="true"/>
    <textarea name="query" id="versions_query" rows="10" style="margin-top: 6px;">
    </textarea>
    <br/>
    <div class="button-border" style="margin-top: 6px;">
        <button type="submit" class="apiblue">Query</button>
    </div>
</form>
</div>

</td>
<td valign="top" class="arrow">&#x21D2;</td>
<td valign="top" width="50%">
<div class="response">
<b>Result:</b><br/>
<iframe name="iversions" id="iversions" width="100%">
</iframe>

</div>
</td></tr></table>   
</div>
title: API Sandbox
stats: true
m: edit
text: true
prettyprint: true