Access Star Trek content from Memory Alpha.




character, See details.


a data frame


The content returned is always a data frame. The structure changes slightly depending on the nature of the endpoint, but results from different endpoints can be merged easily.


At the highest level, passing endpoint = "portals" returns a data frame listing the available Memory Beta portals supported by rtrek. A column of relative URLs is also included for reference, but can be ignored. Compared to Memory Alpha, Memory Beta does not technically offer "portals", but for consistency in rtrek, several high level categories on Memory Beta are treated as portal options. See memory_alpha() for comparison.

Portal Categories

In all other cases, the endpoint string must begin with one of the valid portal IDs. Passing only the ID returns a data frame with IDs and relative URLs associated with the available categories in the specific portal. Unlike memory_alpha, there are no group or subgroup columns. Memory Beta offers a more consistent reliance on the simple hierarchy of categories and articles.

Selecting a specific category within a portal is done by appending the portal ID in endpoint with the category ID, separated by a forward slash. You can append nested subcategory IDs with forward slashes, provided the subcategories exist.


When the endpoint is neither a top-level portal or one of a portal's categories (or subcategories, if available), it is an article. An article is a terminal node, meaning you cannot nest further. An article will be any entry whose URL does not begin with Category:. In this case, the content returned is still a data frame for consistency, but differs substantially from the results of non-terminal endpoints.

Memory Beta is not a database containing convenient tables. Articles comprise the bulk of what Memory Beta has to offer. They are not completely unstructured text, but are loosely structured. Some assumptions are made and memory_beta returns a data frame containing article text and links. It is up to the user what to do with this information, e.g., performing text analyses.

Additional Notes

The url column included in results for context uses relative paths to save space. The full URLs all begin the same. To visit a URL directly, prepend it with

Also note that once you know the relative URL for an article, e.g., "Worf", you do not need to traverse through one of the portals using an endpoint string to retrieve its content. You can instead use mb_article("Worf").

memory_beta provides an overview perspective on how content available at Memory Beta is organized and can be searched for through a variety of hierarchical layouts. And in some cases this structure that can be obtained in table form can be useful as data or metadata in itself. Alternatively, mb_article() is focused exclusively on pulling back content from known articles.


memory_beta("portals") # show available portals
#> # A tibble: 13 × 2
#>    id         url                              
#>    <chr>      <chr>                            
#>  1 books      Category:Books                   
#>  2 comics     Category:Comics                  
#>  3 characters Category:Characters              
#>  4 culture    Category:Culture                 
#>  5 games      Category:Games                   
#>  6 geography  Category:Geography               
#>  7 locations  Category:Locations               
#>  8 materials  Category:Materials_and_substances
#>  9 politics   Category:Politics                
#> 10 science    Category:Science                 
#> 11 starships  Category:Starships               
#> 12 technology Category:Technology              
#> 13 timeline   Category:Timeline                
endpoint <- "characters/Characters by races and cultures/Klingonoids/Klingons"
# \donttest{
x <- memory_beta(endpoint)
x <- x[grep("Worf", x$Klingons), ]
#> # A tibble: 8 × 2
#>   Klingons             url                  
#>   <chr>                <chr>                
#> 1 K'Dhan, son of Worf  K%27Dhan,_son_of_Worf
#> 2 Mogh, son of Worf    Mogh,_son_of_Worf    
#> 3 Worf                 Worf                 
#> 4 Worf (1ST)           Worf_(1ST)           
#> 5 Worf (alternates)    Worf_(alternates)    
#> 6 Worf (mirror)        Worf_(mirror)        
#> 7 Worf's family        Worf%27s_family      
#> 8 Worf, father of Mogh Worf,_father_of_Mogh 
memory_beta(paste0(endpoint, "/Worf")) # return terminal article content
#> # A tibble: 1 × 4
#>   title content    metadata          categories       
#>   <chr> <list>     <list>            <list>           
#> 1 Worf  <xml_ndst> <tibble [1 × 17]> <tibble [49 × 2]>
# }