Citation Formatting API: Retrieve a formatted citation

Retrieving a formatted citation requires an API key – please sign up here first. You can find fully working examples for this API on our api demo page.

Get a fully formatted citation for your own use

This option returns a fully formatted citation. You can then use this citation to display on your site. For instance, if you are an electronic database publisher, you can use EasyBib to automatically generate citations to display back to the user. For more information on the citation payload required for the calls below, please refer to our citation object specification for details.

To go this route, send the JSON data to the following URL via PUT:

https://api.citation-api.com/2.1/rest/cite

Sending responses via PUT

Most scripting and programming languages allow you to create an http request object, which you then use to take the JSON data and send it to us via PUT. We have outlined some example code snippets in our example section. If you do not see your language of choice in this section, and are confused about how to do this, contact us and we’ll help you.

Example payload: (Please note: This has to be urlencoded)

{
    "key": "[your api key]",
    "source": "book",
    "style": "mla7",
    "book": {
    },
    "pubtype": {
        "main": "pubnonperiodical"
    },
    "pubnonperiodical": {
        "title": "Catcher in the Rye",
        "publisher": "Little, Brown",
        "city": "Boston",
        "year": "1995"
    },
    "contributors": [
        {
            "function": "author",
            "first": "J",
            "middle": "D",
            "last": "Salinger"
        }
    ]
}

The response

The returned data (“response”) from EasyBib always includes a “status” field. Possible values are:

ok
error

These values will always be lowercase, and English. An example successful looks like this:

{
    "status":"ok",
    "data":"Salinger, J. D. <u>Catcher in the Rye<\/u>. Boston: Little, Brown, 1995."
}

In case of “error”, the response will also populate a field called “message”, which contains a description of the error which has occurred. This error is most likely not suitable for the end user and should be treated/escalated internally. For example:

{
    "status":"error",
    "message":"Missing required field 'style' in request."
}

Once you get this JSON object, you can then decode it and use the data to present a citation back to your user.

Bulk-posting citations

We support “bulk posting” (retrieving more than one citation at a time). To use this, send all citations in an array data, with only the requested style and your API key in the main object, as outlined below. You API endpoint for bulk citations is https://api.citation-api.com/2.1/rest/bulk:

{
    "key": "[your api key]",
    "style": "mla7",
    "bulk": [
        {
            "source": "book",
            "book": {
            },
            "pubtype": {
                "main": "pubnonperiodical"
            },
            "pubnonperiodical": {
                "title": "Catcher in the Rye",
                "publisher": "Little, Brown",
                "city": "Boston",
                "year": "1995"
            },
            "contributors": [
                {
                    "function": "author",
                    "first": "J",
                    "middle": "D",
                    "last": "Salinger"
                }
            ]
        }
    ]
}

Inline citations

Same as above, but with "inline": true added to the payload, which will return inline citations. Here too, you can also add a "start", "end" to the specific citations to specify the location. Both the bulk and standard endpoint support this parameter.

{
    "inline": true,
    "key": "[your api key]",
    "custom_id": "12345678",
    "source": "book",
    "style": "mla7",
    "pubtype": {
        "main": "pubnonperiodical"
    },
    "pubnonperiodical": {
        "title": "A Book Title",
        "publisher": "Publisher",
        "city": "New York",
        "year": "2006",
        "series": "",
        "start": "2",
        "end": "4"
    },
    "contributors": [
        {
            "function": "author",
            "first": "John",
            "middle": "",
            "last": "Doe"
        },
        {
            "function": "author",
            "first": "Jane",
            "middle": "S",
            "last": "Smith"
        }
    ]
}

DocX Export

Use https://api.citation-api.com/rest/docx/version/2.1 as API endpoint.