Sefaria / Sefaria-Project

New Interfaces for Jewish Texts
https://www.sefaria.org
653 stars 265 forks source link

Parsha API Call #153

Closed adammlevy closed 9 years ago

adammlevy commented 9 years ago

I noticed that it's possible to fetch a parsha with the following API: http://www.sefaria.org/api/texts/[parsha name] where [parsha name] can be any parshot. Using a single word parsha like noach, balak, etc. works however any parsha name that consists of two words like "lech lecha", "Va'etchanan" doesn't work. What is the correct way to retrieve all parshot just by the parsha name?

EliezerIsrael commented 9 years ago

For parsha names with internal spaces, the spaces need to be encoded in the URL as %20.

So "Lech Lecha" can be retrieved with: http://www.sefaria.org/api/texts/Lech%20Lecha

If you don't need all of the commentary, I recommend using the commentary option. It will give you a much more manageable result. E.g: http://www.sefaria.org/api/texts/Lech%20Lecha?commentary=0

Here's a list of all of the canonical English Parsha names that we use:

For those interested in the internals - these names are instances of the Term class, and are used as sharedTitles on the alternate structures of the books of Torah. http://www.sefaria.org/api/v2/raw/index/Genesis should give you an idea of how they're used.

Bereshit Noach Lech Lecha Vayera Chayei Sara Toldot Vayetzei Vayishlach Vayeshev Miketz Vayigash Vayechi Shemot Vaera Bo Beshalach Yitro Mishpatim Terumah Tetzaveh Ki Tisa Vayakhel Pekudei Vayikra Tzav Shmini Tazria Metzora Achrei Mot Kedoshim Emor Behar Bechukotai Bamidbar Nasso Beha'alotcha Sh'lach Korach Chukat Balak Pinchas Matot Masei Devarim Vaetchanan Eikev Re'eh Shoftim Ki Teitzei Ki Tavo Nitzavim Vayeilech Ha'Azinu V'Zot HaBerachah

adammlevy commented 9 years ago

Thanks for the fast response! This is great!

adammlevy commented 9 years ago

I noticed that when trying to get the first parsha of each book (Bereshit, Shamot, Vayikra, Bamidbar, Devarim) only the first chapter is returned and not the whole parsha. For example when using http://www.sefaria.org/api/texts/Devarim?commentary=0 which should return 1:1 to 3:22 I only get 1:1 to 1:46.

shelfgot commented 9 years ago

That's because the api structure is modeled after the site structure (or maybe vice versa, I'm not the engineer,) which, recognizing "Devarim" or "Bereshit" as a book without a chapter, marks it as an incomplete response. The api simply returns the first chapter since it views the call as an incomplete one.

EliezerIsrael commented 9 years ago

Yup - you found an ambiguity here. Does "Shemot" mean the book or the Parasha?

In order to allow unambiguous calls to the Parasha, we just added alternate names to these Parashot. You can now get these with calls to "Parashat Bereshit", "Parashat Shemot", etc.

e.g. http://www.sefaria.org/api/texts/Parashat%20Bamidbar?commentary=0

adammlevy commented 9 years ago

Thanks!