{% extends 'basedocumentation.html' %} {% block title %}API Help{% endblock %} {% block doccontent %}

API Help

Some of the data from Unglue.it is avaiable via a JSON API. You will need a key and username to be able to use the API.

{% if user.is_authenticated %}

Welcome {{user.username}}. Your API key is {{api_key}}.

{% else %}

Please sign in first.

{% endif %}

Ebook Widgets

You don't need an API key to embed Ebook (HTML) widgets.

Here's a widget that displays Unglue.it's featured ebook - it changes most every day! {{base_url}}{% url 'widget' 'featured' %}. Copy/paste this into your site:
If your website doesn't allow javascript (wordpress blogs, for example) you can use the no-script version. Copy/paste this into your site:
featured book cover
Today's Free Ebook at Unglue.it
{% if campaign %}
Here's a sample widget for the book {{campaign.name}} with ISBN {{campaign_isbn}}: {{base_url}}{% url 'widget' campaign_isbn %}. Copy/paste this into your site:
{% endif %}

Basic API info

Available Resources (JSON)

Resources on this list can be accessed via {{ base_url }}/api/v1/{resource_on_list}/?format=json&api_key={your_api_key}&username={your_username} .

Works can be ordered by how often they've been favorited; append &order_by=num_wishes (ascending) or &order_by=-num_wishes (descending).

Free Ebooks by ISBN

With an API key, you can check if there's a free ebook for any ISBN. ISBNs can be 10 or 13 digits, and can include dashes. This service returns all free-licensed ebooks for a work associated with an ISBN, and for each ebook includes information about file type, rights, and the provider hosting the file.

For example, here's how to get a list of ebook files for "Homeland".

{% if user.is_authenticated %} JSON: {{base_url}}/api/v1/free/?isbn=9780765333698&format=json&api_key={your_api_key}&username={your_username}
XML: {{base_url}}/api/v1/free/?isbn=9780765333698&format=xml&api_key={your_api_key}&username={your_username} {% else %} (Log in to see links) {% endif %}

Identifier Resolution

Here's how to get work/edition data for an isbn

{% if user.is_authenticated %} JSON: {{base_url}}/api/v1/identifier/?format=json&api_key={your_api_key}&username={your_username}&type=isbn&value=9780441012039
XML: {{base_url}}/api/v1/identifier/?format=xml&api_key={your_api_key}&username={your_username}&type=isbn&value=9780441012039

{% else %} (Log in to see links) {% endif %}

{% if user.is_authenticated %}

Campaign info

Here's how to get data on all campaigns. if the user is logged in to Unglue.it, they can tell if the campaign book is on their fave list

JSON: {{base_url}}/api/v1/campaign/?format=json&api_key={your_api_key}&username={your_username}<
XML: {{base_url}}/api/v1/campaign/?format=json&api_key={your_api_key}&username={your_username}

Identifier Resolution

Here's how to get work/edition data for an isbn

JSON: {{base_url}}/api/v1/identifier/?format=json&api_key={your_api_key}&username={your_username}&type=isbn&value=9780441012039
XML: {{base_url}}/api/v1/identifier/?format=xml&api_key={your_api_key}&username={your_username}&type=isbn&value=9780441012039

In addition to isbn, you can use 'goog' if you have a google books id, and 'oclc' for oclc numbers.

{% endif %}

OPDS Catalog Feeds

We have a basic implementation of OPDS feeds. You don't need a key to use them. The starting point is {{base_url}}{% url 'opds' %}

Examples:

filtered by format
{{base_url}}{% url 'opds_acqusition' 'epub' %}
filtered by license
{{base_url}}{% url 'opds_acqusition' 'by-sa' %}
filtered by title search
{{base_url}}{% url 'opds_acqusition' 's.open' %}
filtered by keyword
{{base_url}}{% url 'opds_acqusition' 'kw.fiction' %}
filtered by ungluer
{{base_url}}{% url 'opds_acqusition' '@eric' %}

There's also an OPDS record available for every work on unglue.it. For example, requesting, {{base_url}}{% url 'opds_acqusition' 'all'%}?work=13950 get you to the web page or opds record for A Christmas Carol.

ONIX Catalog Feeds

There is an ONIX 3.0 feed corresponding to every facet of our free ebook lists. You don't need a key to use them. There is a maximum of 100 books per result you can change with the max parameter. For example, here are the first hundred CC BY-ND-ND licensed books available in EPUB.

There's also an ONIX record available for every free ebook on unglue.it. For example, here is Issues in Open Research Data.

Identifiers with Content type negotiation

There's a URI to identify every work used in OPDS feeds. HTTP content negotiation is used for these ids, so requesting application/atom+xml;profile=opds-catalog;kind=acquisition for {{base_url}}{% url 'work_identifier' '13950' %} get you to the web page or opds record for A Christmas Carol. requesting text/xml gets you the onix record. Otherwise, you get the normal html page.

{% endblock %}