Sisense Community logo
     
    • Community Feedback
    • Chapters
    • Events
    • Forums
      • Help and How To
      • Product Feedback Forum
      • Strategy & Use Cases
    • Blogs
    • KB Docs
      • KB Docs
      • Add-Ons & Plug-Ins
      • APIs
      • Best Practices
      • Blox
      • CDT
      • Cloud Managed Service
      • Data Models
      • Data Sources
      • Embedding Analytics
      • How-Tos & FAQs
      • Onboarding
      • PySisense
      • Security
      • Sisense Administration
      • Sisense Intelligence & AI
      • Troubleshooting
      • Widget & Dashboard Scripts
    • Support
    • Learning
      • Sisense Academy: Free Courses and Certifications
      • Official Developer Documentation
      • Official Product Documentation
      • Official Sisense Youtube Channel
      • Sisense Compose SDK Playground
      • Official Sisense Discord
    • Use Case Gallery
    •      
    Discussions
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
    •                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    Discussions
    • TagsChevronRightIcon
    Developers: REST API
      • Product Feedback ForumChevronRightIcon
      Allow API searching for dashboards by any data source used within it (filter or widget), and/or allow searching for widgets that use a provided data source across all dashboards (without providing a dashboardId)
                               
      Chris Wallingford
      Chris WallingfordPosted 1 week ago • Last reply 1 week ago
               
      1
               
      • APIsChevronRightIcon

      Get Widget’s Values Directly From The ElastiCube (API Request)

               

      Description Shifting between external sources that are based on different scripting languages is not an easy task. When there is a requirement to query a secured widget's data to an external source (Such as JQuery, JavaScript,HTTP etc.), you will need to utilize the REST API.  A quick example will be grabbing a widget's data to a public website or a customized company's mail report. Prerequisites  Sisense Admin permission REST API Access  ElastiCube and linked dashboard with widgets PostMan application installed -  https://www.getpostman.com/apps Granted access to the machine (IP) that is going to execute the API request against the Sisense Server - Check that the dashboard is accessible from the external machine that execute the API request. Steps a. Widget's JAQL Preparation and Save it Make the the JAQL code as short as possible by "starring" the formulas that are used in the widget -  https://docs.sisense.com/main/SisenseLinux/reusing-formulas.htm To get the widget's JAQL code - Edit Widget > Click on F12 to open developer tools > Open Console > Clear Content > type - prism.debugging.GetJaql(prism.activeWidget).replace(/(\r\n|\n|\r|\t)/gm, ""); and then hit enter 3. Copy the JAQL code to notepad - without the quotes b. Create the Curl and URL Request        1. Go to the Admin Page > Click on REST API reference > Open REST API 0.9 (top right of the screen)       2. Go to - Post> elasticubes/{elasticube}/jaql       3. Copy the JAQL code into the request's body        4. Copy the ElastiCube ID from the JAQL code (data source section) into the ElastiCube input without the quotes. For example: 5. Hit Run and validate the response. A correct response will appear in bottom: 6. Copy the Curl and Request URL to notepad:  c. Create authentication token to query the ElastiCube       1. Go to the Admin Page > Click on REST API reference >  Open REST API 1.0 (top right of the screen)       2. Go to - Post> authentication/login       3. Insert your username/password and hit execute  4. Copy the given access token from the response section without quotes to notepad  d. Generate the Final API Request           1. Open PostMan and create a new POST request          2. Enter the Request URL - Place Sisense Request URL and ElastiCube ID taken from the step B.          3. Copy the the body tab (choose raw option) the entire JAQL code from step A. 4. Open Authorization tab > choose Bearer type > Insert your authentication token from Step C. 5. Open Headers section and add: Content-Type, application/json  Accept, application/json 6. Hit send to get the API call response that will include your widget data values Response Example: 7. Click on "code" (right side of the page), to covert the API request to any scripting language that is required.

      intapiuser
      intapiuserPosted 3 years ago • Last reply 1 year ago
      2
               
      • APIsChevronRightIcon

      REST API - Adding Data Level Security

                               

      When building code to automate the process of adding users (or groups), it may be beneficial to add security around those users. Follow the steps below to learn how to add data level security through the REST API:  Step 1 From your SiSense home page, navigate to the Manage tab and choose the option for REST API.  From here, click on the link to the REST API Reference interface.     Step 2 From here, choose the 0.9 version and expand the Elasticube section and scroll down to the  POST /elasticubes/datasecurity section.   Step 3 The sample code below shows a valid JSON object to use as part of the REST API request. Starting from the sample code, replace the value for party with a user identifier that already exists in your system. Then paste the code into the REST API interface and click run. You should see a response of 200, which indicates a successful operation. [{ "server": "LocalHost", "elasticube": "Sample Lead Generation", "table": "Lead Generation", "column": "Country", "datatype": "text", "shares": [{ "party": "5c0f85690ca2f66cc242e266", "type": "user" }], "members": [ "United States", "England" ] }] Notes The server name value is case sensitive, so make sure it matches with your system. The sample provided is specific to one of the sample databases that comes with SiSense.  To modify this to a different system, just update necessary fields to include your specifications. The sample provided is an array that consists of a single element.  This could be modified to contain several entries all sent at once.

      intapiuser
      intapiuserPosted 3 years ago • Last reply 1 year ago
      2
               
      • APIsChevronRightIcon

      Using the Datasources API to Execute SQL Query and Download Data into a Python Dataframe

               

      Using the Datasources API to Execute SQL Query and Download Data into a Python Dataframe Summary This article guides how to use the Datasources API to execute an SQL query and download data from a cube into a Python data frame. The issue arises when a user cannot find the API in the REST API tab and encounters difficulties in downloading the data into a Python data frame. Main Content Step-by-step instructions: To use the Datasources API and execute an SQL query, you can refer to the following documentation link for more details on this endpoint usage: Sisense SQL API Documentation To obtain a data frame from the Sisense SQL endpoint response, you typically follow these steps: Make the API Call : Use a library like `requests` to send the SQL query to the Sisense API endpoint. Parse the Response : Convert the API response (usually in JSON format) to a format suitable for creating a data frame. Create the DataFrame : Use the `pandas` library to create a DataFrame from the parsed response. Here’s a step-by-step example in Python: Step 1 : Import Libraries First, ensure you have the necessary libraries installed:   pip install requests pandas   Then, import them in your Python script:   import requests import pandas as pd   Step 2 : Define the API Call Set up the API endpoint, headers, and SQL query:     url = "https://example.com/api/datasources/laptopsales/sql" query = "select sales.city, count(*) from sales group by sales.city" # If authentication is needed, you can add headers. For example: headers = { "Content-Type": "application/json", "Authorization": "Bearer YOUR_ACCESS_TOKEN" # replace with your actual token } # Send the request response = requests.get(url, headers=headers, params={"query": query}) # Check if the request was successful if response.status_code != 200: raise Exception(f"Error: {response.status_code}, {response.text}")   Step 3: Parse the Response Assume the response is in JSON format:   data = response.json()   Step 4 : Convert to DataFrame Assuming `data` contains a list of dictionaries, you can directly convert it to a DataFrame:   # Check the structure of the data print(data) # Convert to DataFrame df = pd.DataFrame(data) # Display the DataFrame print(df)   Full Script Example Combining all the steps into one script:   import requests import pandas as pd # Define the endpoint and query url = "https://example.com/api/datasources/laptopsales/sql" query = "select sales.city, count(*) from sales group by sales.city" # Define headers if needed headers = { "Content-Type": "application/json", "Authorization": "Bearer YOUR_ACCESS_TOKEN" # replace with your actual token } # Send the request response = requests.get(url, headers=headers, params={"query": query}) # Check if the request was successful if response.status_code != 200: raise Exception(f"Error: {response.status_code}, {response.text}") # Parse the response data = response.json() # Convert to DataFrame df = pd.DataFrame(data) # Display the DataFrame print(df)   Notes: Authorization : Adjust the headers to include any necessary authentication tokens or credentials. Error Handling : Enhance error handling as per your requirements. Data Structure : The structure of the JSON response might vary, so adjust the DataFrame creation accordingly. Troubleshooting tips or alternative solutions If you encounter any issues with the above steps, ensure that: The URL in the Python code matches the URL of your Sisense platform. The SQL query is correctly formatted and valid. The access token in the headers is valid and has the necessary permissions to access the data. Supplementary Information The Datasources API allows you to interact with your data sources and execute SQL queries directly. This can be particularly useful for automating data extraction and manipulation tasks. The Python code provided in this article uses the requests library to send a GET request to the API and the pandas library to convert the response into a DataFrame for easier data manipulation. Disclaimer: Please note that this blog post contains one possible custom workaround solution for users with similar use cases. We cannot guarantee that the custom code solution described in this post will work in every scenario or with every Sisense software version. As such, we strongly advise users to test solutions in their environment before deploying them to ensure that the solutions proffered function as desired in their environment. For the avoidance of doubt, the content of this blog post is provided to you "as-is" and without warranty of any kind, express, implied, or otherwise, including without limitation any warranty of security and or fitness for a particular purpose. The workaround solution described in this   post incorporates custom coding, which is outside the Sisense product development environment and is, therefore, not covered by Sisense warranty and support services.

      Taras Skvarko
      Taras SkvarkoPosted 1 year ago
      0
               
      • APIsChevronRightIcon

      Beginner Sisense REST API Tips

               

      Three tips for new users working with Sisense's REST API for the first time. 1. If you're running API calls through our Swagger UI (ie, by going to Admin -> REST API -> REST API Reference), you do not need to generate and pass an authentication token. You only need the token when running a call from an outside application. 2. If you receive a 500 response code with an error message of "Internal Server Error" to your POST/PATCH call, that typically indicates there is a syntax error in the payload. To confirm and troubleshoot this, use an online JSON validator (such as JSONLint -  https://jsonlint.com/ ) to review your syntax and identify errors. 3. If you're incorporating our REST API within a program, one tip to accelerate the development process is to use a third-party API tool such as Postman. You can copy the cURL our Swagger UI outputs and paste it in Postman (Import -> Paste Raw Text) to build your API call - just add the Authentication header before running. Once you've verified your call is set up correctly, click Code, then select your language from the dropdown. This will automatically give you a script for the API call in your language.

      intapiuser
      intapiuserPosted 3 years ago • Last reply 2 years ago
      1
               
      • APIsChevronRightIcon

      Hierarchies API

               

      Disclaimer: This is not a documented endpoint and thus might be changed in future versions. If this does not work, do not bother filing a support ticket. This is unsupported behavior. This API overview was generated based on L8.2.1. Your mileage may vary.  Get Hierarchies GET /api/elasticubes/hierarchies?elasticube=<elasticube title>&server=localhost Sample Return: Add a new level to an existing hierarchy POST /api/elasticubes/localhost/<cube title>/hierarchies/<hierarchy id>/level Sample Payload Delete Hierachy DELETE /api/elasticubes/localhost/<cube title>/hierarchies/<hierarchy id> Create new hierarchy POST /api/elasticubes/localhost/<cube title/hierarchies To attach a hierarchy you must manually update the widget with the hierarchy and update the widget This is the modification: widget_json["metadata"]["panels"][0]["items"][i]["hierarchies"] = [<hierarchy id>,....] i = Which dimension you want to attach the category to, 0 being the top dimension The assignment is an array of hierarchy ids

      intapiuser
      intapiuserPosted 3 years ago
      0
               
      • APIsChevronRightIcon

      Manage Color Palettes

               

      Introduction This step-by-step article explains how to change the color palette so that you can use custom colors for elements of the Sisense dashboards. (This will work in V5.7.5 and higher).   How to get your existing palettes 1. Go to v0.9  GET / palettes and hit “RUN” How to create a new schema 1. Go to POST / palettes and insert the required schema into the “Value” input box and hit “RUN”. 2. Use the following syntax and update the “colors” and “name” parameters according to your needs. You can add up to 16 colors in a custom palette. In addition, you can modify the following parameters:   'isDefault' = true means that new dashboards will be created with this palette by default. There can only be one default palette at any time.  'sortOrder' - determines the order of the palette in the palettes list displayed in the dashboard drop-down { "colors": [ "#ff0000", "#001c5a", "#cfeb00", "#2dff00", "#00a79b", "#218A8C" ], "name": "MyPalette", "isDefault": true, "sortOrder": 10 } 3. The new palette will be added to your Dashboard Palettes. How to delete a palette: 1. Go to Delete / palettes / {name} and insert the required schema into the “Value” input box 2. Insert the name of the Palette you wish to delete into the Value input box and hit “RUN” 3. The Palette will be deleted from the Dashboard Palettes

      intapiuser
      intapiuserPosted 3 years ago
      0
               
      • APIsChevronRightIcon

      Data Dictionary Rest API V2.0

               

      Using the API we can retrieve the descriptions the users write in the elasticube for tables and columns. Edit the following: 1. Type username, password, server 2. Update the oid with the desired model you would like to run the script against. Script can be provided if descriptions from all models is needed. 3. Define the output. Current script writes to a csv but this can be easily updated to insert data into a db. Full python script below: https://codeshare.io/GbMdjb  

      intapiuser
      intapiuserPosted 3 years ago
      0
               
      • APIsChevronRightIcon

      Modifying Sign-in Cookie Expiration in REST API

               

      It is possible to modify the cookie expiration period and by that to determine how for how long the user will remained logged in when checking the "Remember Me". When a user logs in to Sisense and does not check the “Remember Me” check-box a session cookie is created leaving the user logged in, it will be automatically deleted when closing the browser.    When checking the  “Remember me”, a cookie called prism will be created. This cookie expires after 30 days by default but this parameter can be easily modified using the REST API under “settings\security”.     Posting the following syntax will determine the number of days until the cookie expires.   The following syntax will set the cookie expiration to one day:   {  "cookieExp": 1 } Please note that the parameter has to be an integer. Posting a decimal value (i.e. 0.5) will cause a “Redirect Loop” error which can be solved by deleting the configuration from the MongoDB with a MongoDB GUI tool. Restarting the IIS will be required.   

      intapiuser
      intapiuserPosted 3 years ago
      0
               
      • How-Tos & FAQsChevronRightIcon

      Curl Setup steps

                       

      Download and run the Exe and Pem files The directory to extract it to should be - C:\Curl Using the exe file by holding shift + right-click:

      intapiuser
      intapiuserPosted 3 years ago
      0