---
updatedAt: 2026-06-02T06:51:34.000Z
agentTools:
  projectIndex: https://developers.sefaria.org/llms.txt
---

# Ref-Topic-Links

An API endpoint where, given a `Ref`, all of the topics linked to that `Ref` are retrieved along with the respective metadata. 

# OpenAPI definition

```json
{
  "openapi": "3.0.2",
  "info": {
    "title": "Sefaria API",
    "version": "1.0.0",
    "description": "The Sefaria API endpoints grant live access to Sefaria's structured database of Jewish texts and their interconnections.",
    "contact": {
      "url": "https://www.sefaria.org",
      "email": "developers@sefaria.org"
    },
    "license": {
      "name": "GNU AGPLv3",
      "url": "https://www.gnu.org/licenses/agpl.txt"
    }
  },
  "servers": [
    {
      "url": "https://www.sefaria.org",
      "description": ""
    }
  ],
  "tags": [
    {
      "name": "Related",
      "description": "Operations related to retrieving links and relationships between texts"
    }
  ],
  "paths": {
    "/api/ref-topic-links/{tref}": {
      "get": {
        "operationId": "get-ref-topic-links",
        "tags": [
          "Related"
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RefTopicLinksJSON"
                },
                "examples": {
                  "Link to Bamidbar": {
                    "value": {
                      "linkType": "about",
                      "class": "refTopic",
                      "dataSource": {
                        "en": "Aspaklaria",
                        "he": "אספקלריא",
                        "slug": "aspaklaria"
                      },
                      "is_sheet": false,
                      "order": {
                        "tfidf": 53.476917039392994,
                        "numDatasource": 2,
                        "availableLangs": [
                          "en",
                          "he"
                        ],
                        "comp_date": -1400,
                        "order_id": "A00000000300280026",
                        "pr": 5.15330629652094,
                        "curatedPrimacy": {
                          "en": 100,
                          "he": 0
                        }
                      },
                      "descriptions": {
                        "en": {
                          "title": "A New Grain Offering",
                          "prompt": "The central ritual of Shavuot as described in the Torah is a special bread offering that was brought to the Temple. This sacrifice marked the beginning of sacrifices that were brought using grain from that year, as opposed to grains from the previous year, as explained in the Book of Numbers."
                        }
                      },
                      "topic": "shavuot",
                      "anchorRef": "Numbers 28:26",
                      "anchorRefExpanded": [
                        "Numbers 28:26"
                      ]
                    }
                  }
                }
              }
            },
            "description": "Successful response"
          }
        },
        "summary": "Ref-Topic-Links",
        "description": "An API endpoint where, given a `Ref`, all of the topics linked to that `Ref` are retrieved along with the respective metadata. "
      },
      "parameters": [
        {
          "examples": {
            "Tanakh": {
              "value": "Genesis"
            },
            "Tanakh Section": {
              "value": "Judges 12"
            },
            "Tanakh Segment": {
              "value": "Esther 4:14"
            },
            "Talmud Segment": {
              "value": "Shabbat 2b.2"
            }
          },
          "name": "tref",
          "description": "A valid Sefaria ref. A Sefaria ref is a human-readable text citation, e.g. `Genesis 1:1`, `Berakhot 2a`, or `Rashi on Genesis 1:1`.",
          "schema": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ref"
              }
            ],
            "default": "Judges 12"
          },
          "in": "path",
          "required": true
        }
      ]
    }
  },
  "components": {
    "schemas": {
      "ref": {
        "description": "A string representing a citation to a Jewish text. \n\nA valid `Ref` consists of a title string followed optionally by a section string or a segment string. \n\nA title string is any one of the known text titles or title variants in the Sefaria Database.",
        "type": "string",
        "example": "Mishnah Peah 4:2"
      },
      "RefTopicLinksJSON": {
        "title": "Root Type for RefTopicLinksJSON",
        "description": "Response from the ref-topic-links endpoint",
        "type": "object",
        "properties": {
          "linkType": {
            "description": "The type of the link, based on the relationship within our ontology. Many links has an `is-a` relationship (such as `Genesis` `is-a` `Book`), but other topic-to-topic links have a variety of other types documented  [here](https://developers.sefaria.org/docs/topic-ontology#overview-of-sefaria-link-types). \n\nSome examples include `child-of`, `parent-of`, `sibling-of` etc. ",
            "type": "string",
            "example": "about"
          },
          "class": {
            "description": "A classification of the link as either `refTopic` (i.e. a ref to a topic) or `intraTopic` (topic-to-topic). In this case, it would be expected that all returned topic links would be of type `refTopic`. ",
            "enum": [
              "refTopic",
              "intraTopic"
            ],
            "type": "string",
            "example": "refTopic"
          },
          "dataSource": {
            "$ref": "#/components/schemas/DataSourceJSON"
          },
          "is_sheet": {
            "description": "Is this ref-to-topic link one that was generated by a user-created source sheet?",
            "type": "boolean",
            "example": false
          },
          "order": {
            "$ref": "#/components/schemas/OrderTopicLinkJSON"
          },
          "descriptions": {
            "description": "JSON containing descriptions for a given topic in various languages. Each language contains a `title` for the topic description, as well as a `prompt` which previews the source and asks questions to help the user engage with the text. ",
            "type": "object",
            "properties": {
              "en": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "prompt": {
                    "type": "string"
                  }
                }
              }
            },
            "example": {
              "title": "A New Grain Offering",
              "prompt": "The central ritual of Shavuot as described in the Torah is a special bread offering that was brought to the Temple. This sacrifice marked the beginning of sacrifices that were brought using grain from that year, as opposed to grains from the previous year, as explained in the Book of Numbers."
            }
          },
          "topic": {
            "description": "The title of the topic. ",
            "type": "string",
            "example": "passover"
          },
          "anchorRef": {
            "description": "The `Ref` the topic is connected to, which should overlap with the requested `Ref` passed through the endpoint. For example, if someone queries for `Bamidbar 28:21`, one of the topics returned is `passover` which has an `anchorRef` of `Numbers 28:16-24` - a range overlapping with our desired `Ref`. ",
            "type": "string",
            "example": "Numbers 28:16-24"
          },
          "anchorRefExpanded": {
            "description": "If the `anchorRef` is a ranged `Ref` (i.e. containing more than a single segment), then this is a list of strings, with each string being one of single segment level `Ref`s that together comprise the range. So for example, the `anchorRefExpanded` of `Exodus 1:1-2` would be `[\"Exodus 1:1\", \"Exodus 1:2\"]`. ",
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "Numbers 28:16",
              "Numbers 28:17",
              "Numbers 28:18",
              "Numbers 28:19",
              "Numbers 28:20",
              "Numbers 28:21",
              "Numbers 28:22",
              "Numbers 28:23",
              "Numbers 28:24"
            ]
          }
        },
        "example": {
          "linkType": "about",
          "class": "refTopic",
          "dataSource": {
            "en": "Aspaklaria",
            "he": "אספקלריא",
            "slug": "aspaklaria"
          },
          "is_sheet": false,
          "order": {
            "tfidf": 53.476917039392994,
            "numDatasource": 2,
            "availableLangs": [
              "en",
              "he"
            ],
            "comp_date": -1400,
            "order_id": "A00000000300280026",
            "pr": 5.15330629652094,
            "curatedPrimacy": {
              "en": 100,
              "he": 0
            }
          },
          "descriptions": {
            "en": {
              "title": "A New Grain Offering",
              "prompt": "The central ritual of Shavuot as described in the Torah is a special bread offering that was brought to the Temple. This sacrifice marked the beginning of sacrifices that were brought using grain from that year, as opposed to grains from the previous year, as explained in the Book of Numbers."
            }
          },
          "topic": "shavuot",
          "anchorRef": "Numbers 28:26",
          "anchorRefExpanded": [
            "Numbers 28:26"
          ]
        }
      },
      "DataSourceJSON": {
        "title": "Root Type for DataSourceJSON",
        "description": "JSON containing the information as to the source of the data for a given ref-to-topic link. ",
        "type": "object",
        "properties": {
          "en": {
            "description": "English title of the data source.",
            "type": "string",
            "example": "Aspaklaria"
          },
          "he": {
            "description": "Hebrew title of the data source.",
            "type": "string",
            "example": "אספקלריא"
          },
          "slug": {
            "description": "Unique slug describing the data source. ",
            "type": "string",
            "example": "aspaklaria"
          }
        },
        "example": {
          "en": "Sheets by Sefaria users",
          "he": "דפי מקורות ממשתמשי ספריא",
          "slug": "sefaria-users"
        }
      },
      "OrderTopicLinkJSON": {
        "title": "Root Type for OrderTopicLinkJSON",
        "description": "This JSON includes the various metrics that are relevant for ordering the link on a topics page. We use these metrics at [Sefaria.org](https://www.sefaria.org) to change the order on the topics page.",
        "type": "object",
        "properties": {
          "tfidf": {
            "format": "double",
            "description": "Results of the [tfidf algorithm](https://en.wikipedia.org/wiki/Tf%E2%80%93idf) run on the `Ref`s within a given topic, as another metric for evaluating the relevance of a given source on a topic page. ",
            "type": "number",
            "example": 53.476917039392994
          },
          "numDatasource": {
            "format": "int32",
            "description": "The number of datasources which connect this `Ref` to the topic. A value of `2` will occur when two sources (i.e. `aspaklaria` and `sefaria sheets` both have connections between this `Ref` and this topic.)",
            "type": "integer",
            "example": 3
          },
          "availableLangs": {
            "description": "This topic is available in a list of languages represented as strings with their language code.",
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "en",
              "he"
            ]
          },
          "comp_date": {
            "format": "int32",
            "description": "The date when the book referenced in the `Ref` was composed. Negative numbers indicate the work was composed BCE, whereas positive numbers indicate the book was composed CE. ",
            "type": "integer",
            "example": -1400
          },
          "order_id": {
            "description": "Unique ID for the `order` JSON.",
            "type": "string",
            "example": "A00000000300280026"
          },
          "pr": {
            "format": "double",
            "description": "`PageRank`. Sefaria calculates `PageRank` for the sources on a given topic page using the internal Sefaria links to create a link graph and then running the [PageRank algorithm](https://en.wikipedia.org/wiki/PageRank) on that. Sources with higher `PageRank` are considered to be more centrally linked and more relevant.",
            "type": "number",
            "example": 5.15330629652094
          },
          "curatedPrimacy": {
            "description": "This field is used for manually ordering a source on a topics page. It has a separate order value for each language.",
            "type": "object",
            "properties": {
              "en": {
                "format": "int32",
                "type": "integer"
              },
              "he": {
                "format": "int32",
                "type": "integer"
              }
            },
            "example": {
              "en": 100,
              "he": 0
            }
          }
        },
        "example": {
          "tfidf": 53.476917039392994,
          "numDatasource": 2,
          "availableLangs": [
            "en",
            "he"
          ],
          "comp_date": -1400,
          "order_id": "A00000000300280026",
          "pr": 5.15330629652094,
          "curatedPrimacy": {
            "en": 100,
            "he": 0
          }
        }
      }
    }
  }
}
```