EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

Introducing “mstrio” – Python and R wrappers for the MicroStrategy REST APIs


Community Admin

• Strategy


Introducing “mstrio” – Python and R wrappers for the MicroStrategy REST APIs

This Knowledge Base article introduces "mstrio," Python and R packages which provide an interface for the Strategy REST APIs. With a few lines of code, data scientists can extract data from cubes and reports and publish entirely new datasets for consumption by other analysts. 
This provides data scientists access to trusted, operational business data using Python and R, which is used in an overwhelming number of data science projects today. With mstrio, data scientists can quickly push their findings into a Strategy dataset, enabling decision-makers to act on the insights. The mstrio packages are supported in Strategy 10.10 and later.

Connecting to Strategy 

Create a connection to the Intelligence Server using

Connection()
 and  
connect()
 in Python and R, respectively. Required arguments for the  
Connection()
 function are the URL for the Strategy REST API server, Strategy Intelligence Server username and password, as well as the Strategy project name. By default, the  
connect()
 function anticipates your Strategy Intelligence Server username and password. LDAP authentication is also supported. Use the optional argument  
login_mode=16
  in the  
connect()
 function for LDAP authentication. 

Extract data from cubes and reports 

To extract data from Strategy cubes and reports, use the  

get_cube() 
and  
get_report()
 functions. Use your connection object and the ID for the cube or report that you are fetching. You can get the ID by navigating to the cube or report within Strategy Web, right-clicking on the desired cube, and selecting Properties. Alternatively, you can use Strategy Developer in a similar manner.  The  
get_cube()
 and  
get_report() 
functions will return a data frame with the requested data. 

Upload data to Strategy 

Create a new in-memory dataset with the 

create_dataset()
 function. You'll need to provide a name for your cube, as well as a name for the table that will contain the data. At this time, only one table per cube is supported. The 
create_cube() 
function will return the
datasetID
and
tableID
, which can be used to update a dataset with new data. 

Add or update a dataset with new data 

Once a dataset has been created, you can both update the data within the cube and add new data to it with the  

update_dataset()
 function. Note that you'll need to pass in both the
datasetID
and
tableID
for the target dataset and table within the dataset, respectively. These are returned by the  
create_dataset()
 function. 
The  
update_policy
  parameter controls the update behavior. Currently supported update operations are: 

  • add (inserts entirely new data) 
  • update (updates existing data) 
  • upsert (simultaneously updates existing data and inserts new data) 
  • replace (truncates and replaces the data)

Comment

0 comments

Details

Knowledge Article

Published:

July 19, 2018

Last Updated:

November 26, 2018