Occurrences by dictionary entry
DAPCA lemmatizes its texts against the Leipzig Akkadian Dictionary (LAD): every lexical token of the corpus can be assigned to a dictionary entry. This API answers the opposite question — which DAPCA tokens have been assigned to a given dictionary entry, and in what context do they occur? The entries are LAD's, and its first user is the LAD project, which reads in DAPCA how its lemmata are attested.
The API answers in JSON. It is not a way to download the corpus: the list of occurrences gives references only, and the context (line and translation) is returned for a few chosen occurrences at a time.
1. Access
The API is closed. It needs an active DAPCA account holding the permission for the LAD
API; administrators have it implicitly. Without it every request answers
401 Unauthorized.
There are two ways to authenticate, for two kinds of client:
| Client | How |
|---|---|
| a browser | log in to DAPCA as usual, then open the API address: the JSON is shown in the page |
| a program (script, server) | send the account's API token in the header Authorization: Bearer <token> |
The API token is issued by an administrator (user management panel, API token column, New). It is shown once, at the moment it is issued, and DAPCA keeps no readable copy: if it is lost, a new one is issued, and the old one stops working. A token opens the API only — not the rest of the site — and stops working as soon as the account is deactivated or the token revoked.
Always use https://. A request to http:// is redirected, but the token has already crossed
the network unencrypted: consider it exposed and ask an administrator to revoke it.
What the account sees
The API applies the account's visibility, exactly like the web pages. The account given to an external project such as LAD is a Reader account with the permission for the LAD API: it reads what a reader of the public site reads, nothing more.
| A Reader account through the API | |
|---|---|
| Texts | only texts released for publication; tokens of texts still in preparation are left out of the counts and the lists, and in a context request they are reported as missing |
| Translations | only where the text's translations are public; a published text whose translations are not yet released returns its lines but no translations |
| Editorial notes | never: the API returns no notes or commentary, only the line and its translations |
| Counts | computed on the same visible texts, so n_tokens, total and the lists always agree |
The archives assigned to the account do not widen this: for a Reader they only choose the bibliography shown by default. An account with wider access (User, Advanced user, Administrator) sees through the API what it sees on the site, unpublished texts and their translations included — which is why an external project is given a Reader account.
2. Try it from a tablet
The quickest way to see what the API returns needs no program at all:
- log in with an account holding the permission for the LAD API;
- open a text and click a lemmatized word: the token information window opens;
- in its Lemma Information section, the
{}button next to the lemma opens in a new tab the JSON of that single occurrence, with its line and translations (§5.2).
Screenshot da inserire
images/development/api_infotoken_button.jpg — la finestra del token con il pulsante {}
accanto alla matita, sezione Lemma Information.
From there the rest of the API is one edit of the address away:
| Change to the address | What you get |
|---|---|
add more ids to occ=, comma-separated (up to ten) |
the context of those occurrences too (§5.2) |
remove ?occ=… |
the list of all the entry's occurrences, page by page (§5.1) |
remove /occurrences as well |
the summary of the entry (§4) |
The button appears only on words assigned to a LAD entry, and only for accounts with the permission; for everyone else the window is unchanged.
3. The LAD identifier
Entries are addressed by their LAD identifier, the idno of the entry in the LAD TEI files
— for example LAD007005 for māru "son". It is the same identifier that appears in the address
of the LAD entry page in DAPCA (/lemma/lad/LAD007005). An unknown identifier answers
404 with {"error": "not found"}.
4. Summary of an entry
GET /lemma/api/lad/<lad_id>
The entry as DAPCA stores it, the written forms under which it is attested in the corpus, and the number of tokens:
{
"lad": {
"lad_id": "LAD007005",
"lemma": "māru",
"homonym": null,
"pos": "subst",
"meaning_en": "son",
"retired_at": null
},
"n_tokens": 7969,
"forms": [
{ "form": "DIŠ-DUMU", "n": 19 },
{ "form": "DUMU", "n": 6710 },
{ "form": "DUMU.MEŠ", "n": 537 }
],
"occurrences_url": "https://dapca.cnr.it/lemma/api/lad/LAD007005/occurrences"
}
retired_at is set when LAD has withdrawn the entry; DAPCA keeps it, and no new token is ever
assigned to it. Forms are written in DAPCA's transliteration (Unicode, subscript indices).
5. Occurrences
GET /lemma/api/lad/<lad_id>/occurrences
The endpoint works in two ways.
5.1 The list: references, page by page
Without parameters, or with page and per_page, it returns the occurrences as
references: where each token is, not what surrounds it. This is what you browse to choose
the occurrences whose context you want.
| Parameter | Meaning | Default |
|---|---|---|
page |
page number, from 1 | 1 |
per_page |
occurrences per page, at most 500 | 100 |
Occurrences are ordered by text siglum, then by line, then by position in the line.
{
"lad": { "lad_id": "LAD007005", "lemma": "māru", "homonym": null },
"total": 7969,
"page": 1,
"per_page": 2,
"pages": 3985,
"next": "https://dapca.cnr.it/lemma/api/lad/LAD007005/occurrences?page=2&per_page=2",
"occurrences": [
{
"occ_id": 63322,
"form": "DUMU",
"notation": "DUMU",
"classe": null,
"ebl": "māru I",
"tablet": {
"id": 2517,
"siglum": "SMN 2839",
"site": "Nuzi",
"school": null,
"doi": null,
"url": "https://dapca.cnr.it/tablet/2517"
},
"url": "https://dapca.cnr.it/tablet/2517#18382",
"line": { "face": "o", "face_label": "Obv.", "line": "2", "r_order": 2 }
}
]
}
| Field | Meaning |
|---|---|
occ_id |
the token's identifier: what you pass to ask for its context (§5.2) |
form |
the written form, as in the transliteration |
notation |
the form as it was entered |
classe |
the semantic class when the token carries one (e.g. a topographical name); null for an ordinary word |
ebl |
the corresponding lemma of the electronic Babylonian Library, when one is assigned |
tablet |
the text: siglum, site, scribal school, DOI if the edition has one, address of its page |
url |
the text's page, opened at the line |
line |
surface (o obverse, v reverse, lw lower edge, up upper edge, lx left edge, rx right edge), line number as printed, and the line's order in the text |
next |
the address of the next page; null on the last |
5.2 The context of chosen occurrences
With occ, a comma-separated list of one to ten token identifiers, it returns those
occurrences only, each with its context:
curl -H "Authorization: Bearer <token>" \
"https://dapca.cnr.it/lemma/api/lad/LAD007005/occurrences?occ=63322,122106"
Each occurrence carries the same fields as in the list, plus:
line.text— the line in plain transliteration, determinatives in braces (DUMU {m}a-ri-[im-ma-at-ka₄ u₃]);line.html— the line as DAPCA displays it (see §6);translations— the identifiers of the translations that cover the line.
The translations themselves are given once, in a separate translations object, because
several occurrences of the same text often share one:
{
"lad": { "lad_id": "LAD007005", "lemma": "māru", "homonym": null },
"occurrences": [
{
"occ_id": 63322,
"form": "DUMU",
"…": "…",
"line": {
"face": "o", "face_label": "Obv.", "line": "2", "r_order": 2,
"text": "DUMU {m}a-ri-[im-ma-at-ka₄ u₃]",
"html": "<span data-wid=\"63322\"><span class=\"log\">DUMU</span></span> …"
},
"translations": [143]
}
],
"translations": {
"143": {
"text": "Ainsi (parlent) [Tuhmiya] fils d’Ari[m-matka et] Mera[llu épouse de Tuhmiya] :",
"source": "group",
"provenance": "human",
"lines": [
{ "face": "o", "line": "1", "text": "um-ma [{m}tuḫ-mi-ia-ma]", "…": "…" },
{ "face": "o", "line": "2", "text": "DUMU {m}a-ri-[im-ma-at-ka₄ u₃]", "…": "…" }
],
"lines_truncated": false
}
},
"missing": []
}
- A translation's
linesare the lines of the text it translates, in the same form asline: this is the passage of the tablet that goes with the translation. A translation covering more than 30 lines is cut at the first 30, andlines_truncatedsays so. sourceandprovenancesay where the translation comes from and how it was produced.missinglists the requested identifiers that were not returned: a token of another entry, of a text the account cannot see, or not a word.
More than ten identifiers, or anything that is not a list of numbers, answers 400 with an
error message.
6. The HTML of a line
line.html reproduces the transliteration as the tablet page shows it, with classes instead of
styles, so the receiving site can render it in its own typography:
| Markup | Meaning |
|---|---|
<span data-wid="N"> |
one token; N is its occ_id — use it to highlight the occurrence |
<span class="sil"> |
syllabic reading |
<span class="log"> |
logogram |
<sup class="det"> |
determinative |
<span class="fco"> |
phonetic complement |
<span class="frg"> |
broken, inside [ ] |
<span class="dmg"> |
damaged but legible, inside ⸢ ⸣ |
The brackets themselves are plain text, outside every element. All content is escaped.