---
title: "Random By Topic"
method: GET
path: "/api/texts/random-by-topic"
tags: ["Topic"]
---

# Random By Topic

`GET /api/texts/random-by-topic`

Returns Texts API data for a random text taken from popular topic tags.

## Response `200`

Successful response

- RandomByTopicJSON — Response to the random-by-topic API endpoint.
  - `ref` string — The `Ref` of the text randomly selected, which is connected to one of the recently popular topics.
  - `topic` RandomByTopicTopicJSON — Topic JSON for the `random-by-topic/` endpoint.
    - `slug` string, required — The unique slug for a given topic.
    - `titles` TitlesJSON[]
      - `text` string — The text of the title
      - `lang` string — The language of the title, either `en` or `he`.
      - `Primary` boolean — A field depicting whether or not the title is the primary title. Note: For any given topics, one should expect two titles with this field present and set to `true`, an English and a Hebrew primary title. The English value with `primary` set to `true` will match the string value of the `primaryTitle` field on topic.
    - `alt_ids` string — This is a dictionary containing the keys of naming schemes, and ids of this topic represented in that naming scheme. It’s used both for canonical names in other naming schemes and temporary storage of names when renaming slugs. All of the data here is for internal use, with the exception of the values `bfo` and `wikidata`. `bfo` refers to [basic formal ontology](https://github.com/BFO-ontology/BFO#implementations), and `wikidata` to the wikidata ontology of topics.
    - `categoryDescription` string — A description of the category of this topic
    - `numSources` integer — The number of text sources associated with a topic.
    - `description_published` boolean — A boolean representing whether or not the description was published.
    - `data_source` string — How the topic was generated, whether by Sefaria, a user on a source sheet, or some other source.
    - `primary_title` BillingualJSON — A JSON object containing billingual text, both `he` and `en` parallel texts.
      - `en` union — The English field for a JSON object representing billingual text.
        - string
        - boolean
      - `he` union — The Hebrew field for a JSON object representing billingual text.
        - string
        - boolean
    - `description` BillingualJSON — A JSON object containing billingual text, both `he` and `en` parallel texts.
      - `en` union — The English field for a JSON object representing billingual text.
        - string
        - boolean
      - `he` union — The Hebrew field for a JSON object representing billingual text.
        - string
        - boolean
  - `url` string — The `Ref` in a format appropriate for a URL, with spaces replaced with `.` etc.

---

[API](https://skmtc.net/sefaria/apis/sefaria-api.md) · [All operations](https://skmtc.net/sefaria/apis/sefaria-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/sefaria/sefaria-api/revisions/d29296717011/schema)
