Name API

JonMosenkis edited this page Nov 15, 2017 · 4 revisions

Used as primarily as an "autocompleter", the name api takes a string and attempts to match that string against our data.

url: api/name/(?P<name>.+)

Some examples:

(Tip: install a JSON viewer for your browser so you can experiment with these on your own)

A name

https://www.sefaria.org/api/name/Rashi

{
  "lang": "en",
  "is_ref": false,
  "type": "Person",
  "key": "Rashi",
  "completions": Array[16][
    "Rashi",
    "Rashi on Zevachim",
    "Rashi on Zephaniah",
    "Rashi on Zechariah",
    "Rashi on Yoma",
    "Rashi on Yevamot",
    "Rashi on Temurah",
    "Rashi on Taanit",
    "Rashi on Sukkah",
    "Rashi on Sotah",
    "Rashi on Song of Songs",
    "Rashi on Shevuot",
    "Rashi on Shabbat",
    "Rashi on Sanhedrin",
    "Rashi on Ruth",
    "Rashi on Psalms"
  ]
}

As can be seen, Rashi is both a person and a commentator (and as such, Sefaria has many indices that start with his name). Rashi is not a valid Ref, but the suggested completions will lead to valid indices and Refs.

A Ref

https://www.sefaria.org/api/name/Shabbat.2a

{
  "completions": Array[1][
    "Shabbat.2a"
  ],
  "examples": Array[0][
    
  ],
  "type": "ref",
  "is_node": false,
  "is_range": false,
  "index": "Shabbat",
  "addressExamples": Array[2][
    "2a",
    "6"
  ],
  "book": "Shabbat",
  "sectionNames": Array[2][
    "Daf",
    "Line"
  ],
  "sections": Array[1][
    "2a"
  ],
  "is_book": false,
  "heAddressExamples": Array[2][
    "ב׳ א",
    "ו׳"
  ],
  "internalToSections": Array[1][
    3
  ],
  "toSections": Array[1][
    "2a"
  ],
  "is_ref": true,
  "is_segment": false,
  "lang": "en",
  "heSectionNames": Array[2][
    "דף",
    "שורה"
  ],
  "url": "Shabbat.2a",
  "ref": "Shabbat 2a",
  "internalSections": Array[1][
    3
  ],
  "is_section": true
}

As can be seen, Shabbat 2a is a valid Sefaria Ref, and data about this reference is supplied. On the other hand, no suggestions for auto-completion are supplied.

A random string

It is possible to query any string against the name api. In this case, the name api will attempt to supply the best possible matches to the string.

https://www.sefaria.org/api/name/foo

{
  "lang": "en",
  "is_ref": false,
  "completions": Array[16][
    "Footnotes to Teshuvot haRashba part VII",
    "Footnotes to Teshuvot haRashba part VI",
    "Footnotes to Teshuvot haRashba part V",
    "Footnotes to Teshuvot haRashba part IV",
    "Footnotes to Kohelet by Bruce Heitler",
    "Footnotes on Teshuvot haRashba Meyuchas LehaRamban",
    "Footnotes on Orot",
    "Footnotes to Teshuvot haRashba part 7",
    "Footnotes to Teshuvot haRashba part 6",
    "Footnotes to Teshuvot haRashba part 5",
    "Footnotes to Teshuvot haRashba part 4",
    "Footnotes to Teshuvot haRashba helek Sheva",
    "Footnotes to Teshuvot haRashba helek Shesh",
    "Footnotes to Teshuvot haRashba helek Chamesh",
    "Footnotes to Teshuvot haRashba helek Arbah",
    "Footnotes on Orot, The Process of Ideals in Israel, Unification of Ideals"
  ]
}

https://www.sefaria.org/api/name/Yom

{
  "lang": "en",
  "is_ref": false,
  "completions": Array[16][
    "Yoel ben Shmuel Sirkes",
    "Yonah ben Yisrael Babad",
    "Yosef Bekhor Shor",
    "Yosef Giqatillah",
    "Yosef Hayyim",
    "Yosef Shaul Nathanson",
    "Yom-Tov Lipmann Heller",
    "Yoma",
    "Yom Tov ben Avraham Isbilli",
    "Yoreh Deah",
    "Yoreh De'ah",
    "Yonah Gerondi",
    "Yonah",
    "Yoel",
    "Commentary on Sefer Hamitzvot of Rasag",
    "Commentary of Chida on Tractate Gerim"
  ]
}

The name api will attempt to reverse your keyboard from English to Hebrew (and vice versa) if no matches are found. For example, by typing the word בראשית with an English keyboard I will get crtah,.

https://www.sefaria.org/api/name/crtah,

{
  "lang": "en",
  "is_ref": false,
  "completions": Array[16][
    "בראשית",
    "בראשית רבה",
    "שפת אמת, בראשית, בראשית",
    "פני דוד, בראשית, בראשית",
    "קדושת לוי, בראשית, בראשית",
    "שפת אמת, בראשית, פרשת בראשית",
    "נעם אלימלך, ספר בראשית, בראשית",
    "קדושת לוי, בראשית, פרשת בראשית",
    "נועם אלימלך, ספר בראשית, בראשית",
    "עבודת ישראל, ספר בראשית, בראשית",
    "מי השלוח, חלק א, ספר בראשית, בראשית",
    "מי השלוח, חלק ב, ספר בראשית, בראשית",
    "ספר הישר (מדרש), ספר בראשית, בראשית",
    "נעם אלימלך, ספר בראשית, פרשת בראשית",
    "ספר נועם אלימלך, ספר בראשית, בראשית",
    "נועם אלימלך, ספר בראשית, פרשת בראשית"
  ]
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.