easybib.com / for developers

Find our documentation at developer.easybib.com

EasyBib Version 2.0 API examples

To assist with API integration, we have some demonstration examples.

Example 1:

This is a form. After submission, the following occurs.

  • The data is POSTed to /demo/formresults
  • Server-side, the data is converted into a JSON string. The JSON structure is noted in the API reference document.
  • This JSON request is then sent, via PUT, to https://api.citation-api.com/rest/cite for citation formatting.
  • Our API sends back a JSON response. This result is then decoded and displayed.
  • Note 1: Your API key will be different than the one below.
  • Note 2: It may be helpful to view the source of this page.
View HTML forms

Example 2: JSON string

This is an example JSON string. As long as data is structured this way, it can be sent via PUT to our URL.

  • First, we take the JSON string and url encode it for a hidden form field.
  • We pass the JSON array via PUT to https://api.citation-api.com/rest/cite
  • Note 1: Your API key will be different than the one below.
  • Note 2: It may be helpful to view the source of this page.

The JSON string:

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

To test this, click the button below.



Example 2.1: JSON but returning inline citations

This is the same as above, but with

"inline": true
added to the payload, which will return inline citations.

To specify where that specific citation can be found, you can use the "start", "end", and "nonconsecutive" keys, as seen here inside "pubnonperiodical".

The JSON string:

{
    "inline": true,
    "key": "187fc6821e7be05c3d77b8b4b4d294e5",
    "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"
        }
    ]
}

To test this, click one of the buttons below.



Example 3: Bulk JSON string

This is an example of a bulk JSON string being sent to: https://api.citation-api.com/2.1/rest/bulk The JSON string:

{
    "key": "187fc6821e7be05c3d77b8b4b4d294e5",
    "style": "bibtex",
    "bulk": [
        {
            "custom_id": "0",
            "section_id":"34",
            "source":"chapter",
            "chapter":
            {
                 "title":"Section title"
            },
            "pubtype":
            {
                "main":"pubnonperiodical"
            },
            "pubnonperiodical":
            {
                "title":"Book Zero",
                "publisher":"Publisher",
                "city":"New York",
                "year":"2006",
                "series":""
            },
            "contributors":[
                {
                    "function":"author",
                    "first":"John",
                    "middle":"",
                    "last":"Doe"
                },
                {
                    "function":"author",
                    "first":"Jane",
                    "middle":"S",
                    "last":"Smith"
                }
            ]
        },
        {
            "custom_id": "A1",
            "source": "chapter",
            "section_id":"",
            "chapter":
            {
                 "title":"Section title"
            },
            "pubtype":
            {
                "main":"pubnonperiodical"
            },
            "pubnonperiodical":
            {
                "title":"Book A1",
                "publisher":"Publisher",
                "city":"New York",
                "year":"2006",
                "series":""
            },
            "contributors":[
                {
                    "function":"author",
                    "first":"John",
                    "middle":"",
                    "last":"Doe"
                },
                {
                    "function":"author",
                    "first":"Jane",
                    "middle":"S",
                    "last":"Smith"
                }
            ]
        },
        {
            "custom_id": "1",
            "source": "journal",
            "journal": {
                "title": "The fate of peanut butter"
            },
            "pubtype": {
                "main": "pubjournal",
                "suffix": "pubdatabase"
            },
            "pubjournal": {
                "title": "Public Policy Journal One",
                "issue": "4",
                "volume": "39",
                "year": "2001",
                "start": "20",
                "nonconsecutive": "1"
            },
            "contributors": [
                {
                    "function": "author",
                    "first": "John",
                    "middle": "",
                    "last": "Doe"
                }
            ],
            "pubdatabase": {
                "searchtext": "http://www.jstor.org"
            }
        }
    ]
}

To test this, click the button below.



Example 3.1: Bulk JSON but returning inline citations

And again, the 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.

We're also switching to the harvard1 style for this one, to highlight the location usage (some styles ignore this information).

The JSON string:

{
    "inline": true,
    "key": "187fc6821e7be05c3d77b8b4b4d294e5",
    "style": "harvard1",
    "bulk": [
        {
            "custom_id": "0",
            "section_id": "34",
            "source": "chapter",
            "chapter": {
                "title": "Section title"
            },
            "pubtype": {
                "main": "pubnonperiodical"
            },
            "pubnonperiodical": {
                "title": "Book Zero",
                "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"
                }
            ]
        },
        {
            "custom_id": "A1",
            "source": "chapter",
            "section_id": "",
            "chapter": {
                "title": "Section title"
            },
            "pubtype": {
                "main": "pubnonperiodical"
            },
            "pubnonperiodical": {
                "title": "Book A1",
                "publisher": "Publisher",
                "city": "New York",
                "year": "2006",
                "series": ""
            },
            "contributors": [
                {
                    "function": "author",
                    "first": "John",
                    "middle": "",
                    "last": "Doe"
                },
                {
                    "function": "author",
                    "first": "Jane",
                    "middle": "S",
                    "last": "Smith"
                }
            ]
        },
        {
            "custom_id": "1",
            "source": "journal",
            "journal": {
                "title": "The fate of peanut butter"
            },
            "pubtype": {
                "main": "pubjournal",
                "suffix": "pubdatabase"
            },
            "pubjournal": {
                "title": "Public Policy Journal One",
                "issue": "4",
                "volume": "39",
                "year": "2001",
                "start": "20",
                "nonconsecutive": "1"
            },
            "contributors": [
                {
                    "function": "author",
                    "first": "John",
                    "middle": "",
                    "last": "Doe"
                }
            ],
            "pubdatabase": {
                "searchtext": "http:\/\/www.jstor.org"
            }
        }
    ]
}

To test this, click the button below.



Example 4: Docx Export

This is an example of the json string above being sent to https://api.citation-api.com/rest/docx/version/2.0



Example 5: Widgets




Version 1.0