# Citation Generator (APA, IEEE, Harvard…) API

> Turn DOIs, ISBNs, PMIDs, URLs, BibTeX, RIS or fields into references and in-text citations: APA, IEEE, Harvard, Vancouver, Chicago, MLA, APA Vietnam.

- Endpoint: `GET | POST https://apibox.io.vn/v1/citation`
- Category: Text
- HTML docs: https://apibox.io.vn/docs/citation/ (Vietnamese: https://apibox.io.vn/vi/docs/citation/)
- Online tool: https://apibox.io.vn/tools/citation/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

Send `items`: DOIs, ISBNs, PMIDs (`pmid:123`), web page URLs, BibTeX or RIS records, CSL-JSON or plain objects (`type`, `title`, `authors`, `year`, `journal`, `volume`, `issue`, `pages`, `publisher`…), up to 100 items and 25 online lookups per request. DOIs are resolved by doi.org content negotiation (Crossref, DataCite…), ISBNs through Open Library, PMIDs through the NCBI citation exporter and pages through their citation / Dublin Core / Open Graph tags; lookups are cached for a day and nothing is stored. Duplicates (same DOI or PMID) are listed once.

Styles: `apa` (7th), `apa-6`, `ieee`, `harvard` (Cite Them Right), `vancouver` (NLM), `chicago` (author-date, 18th), `mla` (9th) and `apa-vn`, the convention of many Vietnamese universities: Vietnamese authors keep their full name in natural order and Vietnamese works come first, sorted by given name. Vietnamese names are parsed correctly (`Nguyễn Văn An` = family Nguyễn), reversed records from databases are fixed, Vietnamese titles are not title-cased, and `lang=vi` uses the Vietnamese CSL locale.

The JSON answer has the reference list (text and HTML), the in-text citation of each item and the CSL-JSON data (`exports=1` adds BibTeX and RIS). `format=text|html|bibtex|ris|csl|docx` returns that format directly; DOCX has hanging indents ready for a thesis. Styles and locales: Citation Style Language project (CC BY-SA 3.0); rendering by citation-js and citeproc-js (CPAL-1.0).

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `items` | body | array | no |  | DOIs, ISBNs, PMIDs, URLs, BibTeX / RIS strings or objects. |
| `doi` | query|body | string | no |  | One or more DOIs (comma-separated). |
| `isbn` | query|body | string | no |  | One or more ISBNs. |
| `bibtex` | body | string | no |  | BibTeX records. |
| `ris` | body | string | no |  | RIS records. |
| `style` | query|body | string | no | `apa` | `apa`, `apa-vn`, `apa-6`, `ieee`, `harvard`, `vancouver`, `chicago`, `mla`. |
| `lang` | query|body | string | no | `en` | `en` or `vi` (terms such as "và c.s."). |
| `vn_names` | query|body | string | no | `auto` | `auto`, `full` (Vietnamese authors as full names in every style) or `off`. |
| `format` | query|body | string | no | `json` | `json`, `text`, `html`, `bibtex`, `ris`, `csl` or `docx`. |
| `exports` | query|body | boolean | no |  | Add BibTeX and RIS to the JSON answer. |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/citation" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"style":"apa","items":[{"type":"article","title":"Ứng dụng học máy trong dự báo phụ tải điện","authors":["Nguyễn Văn An","Trần Thị Bình"],"year":2021,"journal":"Tạp chí Khoa học và Công nghệ","volume":"59","issue":"3","pages":"45-60","doi":"10.1234/abc.2021"},{"type":"book","title":"Deep learning","authors":"Goodfellow, Ian; Bengio, Yoshua; Courville, Aaron","year":2016,"publisher":"MIT Press"}]}'
```

## Example response

```json
{
  "style": "apa",
  "style_name": "APA 7th edition",
  "locale": "en-US",
  "count": 2,
  "bibliography": [
    {
      "id": "ref2",
      "text": "Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep learning. MIT Press.",
      "html": "<div data-csl-entry-id=\"ref2\" class=\"csl-entry\">Goodfellow, I., Bengio, Y., &#38; Courville, A. (2016). <i>Deep learning</i>. MIT Press.</div>"
    },
    {
      "id": "ref1",
      "text": "Nguyễn, V. A., & Trần, T. B. (2021). Ứng dụng học máy trong dự báo phụ tải điện. Tạp chí Khoa học và Công nghệ, 59(3), 45–60. https://doi.org/10.1234/abc.2021",
      "html": "<div data-csl-entry-id=\"ref1\" class=\"csl-entry\">Nguyễn, V. A., &#38; Trần, T. B. (2021). Ứng dụng học máy trong dự báo phụ tải điện. <i>Tạp chí Khoa học và Công nghệ</i>, <i>59</i>(3), 45–60. https://doi.org/10.1234/abc.2021</div>"
    }
  ],
  "citations": [
    {
      "id": "ref1",
      "text": "(Nguyễn & Trần, 2021)"
    },
    {
      "id": "ref2",
      "text": "(Goodfellow et al., 2016)"
    }
  ],
  "items": [
    {
      "type": "article-journal",
      "title": "Ứng dụng học máy trong dự báo phụ tải điện",
      "author": [
        {
          "family": "Nguyễn",
          "given": "Văn An"
        },
        {
          "family": "Trần",
          "given": "Thị Bình"
        }
      ],
      "container-title": "Tạp chí Khoa học và Công nghệ",
      "volume": "59",
      "issue": "3",
      "page": "45-60",
      "issued": {
        "date-parts": [
          [
            2021
          ]
        ]
      },
      "DOI": "10.1234/abc.2021",
      "id": "ref1",
      "language": "vi-VN"
    },
    {
      "type": "book",
      "title": "Deep learning",
      "author": [
        {
          "family": "Goodfellow",
          "given": "Ian"
        },
        {
          "family": "Bengio",
          "given": "Yoshua"
        },
        {
          "family": "Courville",
          "given": "Aaron"
        }
      ],
      "publisher": "MIT Press",
      "issued": {
        "date-parts": [
          [
            2016
          ]
        ]
      },
      "id": "ref2"
    }
  ],
  "attribution": "Citation styles and locales: Citation Style Language project and the style authors (https://citationstyles.org), CC BY-SA 3.0 (https://creativecommons.org/licenses/by-sa/3.0/). Rendering: citation-js (MIT) and citeproc-js 2.4.63 by Frank Bennett, used unmodified under the Common Public Attribution License 1.0 (CPAL-1.0, licence text: https://opensource.org/license/cpal-1-0); source code: https://github.com/Juris-M/citeproc-js (version 2.4.63: https://www.npmjs.com/package/citeproc/v/2.4.63). Third-party licences: https://apibox.io.vn/licenses"
}
```

## Use cases

- Build the reference list of a thesis from a list of DOIs
- Convert BibTeX or RIS exports to APA or IEEE text
- Format Vietnamese references the way the university guide asks
- Add a "cite this" button to articles or a library catalogue

## FAQ

### Which APA version is used?

apa is the 7th edition; apa-6 is still available for faculties that require it; apa-vn is APA 7 with the Vietnamese name and ordering convention.

### Why is a DOI not found?

The DOI may not be registered or the agency may not support content negotiation. Send the fields or BibTeX instead; failed items are listed in errors.

### Are in-text citations numbered for IEEE?

Yes. For IEEE and Vancouver the number is the position in the reference list; author-date styles give (Author, year).
