Now that we know how to use Postman to send an API request to SAP Datasphere and receive data. We can now take a closer look at the API and what we can do with it. At api.sap.com we get different API endpoints, I want to focus on the consumption part. The API reference for the consumption part allows us to consume relational and analytical models.
Let's start with the relational models and retrieve the data with Postman to see some results. The relational API endpoint can be accessed at this URL
https://xyz.eu10.hcs.cloud.sap/api/v1/dwc/consumption/relational/{space}/{asset}/{technical_object}
You can find the exact description in the API catalog. So I won't copy and paste the content here. Now let's get the data with the above URL. My view is called DBV_BIKE_DELIVERY. If I now use my OAuth from the last post, I get the data directly in Postman.
As you can see, it is very easy to retrieve the data from the API. To make it more flexible, the URL can have different parameters like
- select
- filter
- order by
- top
- skip
This can be really interesting when we use this URL later with Python to get more flexible data. For example, if we use the $top parameter, we can display only the top 3 records.
Now you can use Postman to access relational views and retrieve the data. The next step is to retrieve data from analytical objects such as an analytical model. The URL is almost the same:
https://xyz.eu10.hcs.cloud.sap/api/v1/dwc/consumption/analytical/{space}/{asset}/{technical_object}
As you can see, the only difference is the word relational to analytical.
With the analytic URL, we get data from an analytic model. The advantage of the analytic model is that we also get data from associated dimensions in the result. So the result can be very large because all active dimension attributes are now displayed. So be careful what you select.
To reduce the dimensions you want to consume, we can add the parameter $select and get only the columns we need.
So now we only get the 4 columns I added to the URL. The columns are
- CALWEEK
- PARTNERID
- PRODUCTID__PRODCATEGORYID
- QUANTITY
As you can see, I get different columns. The CALWEEK column from the associated time dimension, the PARTNERID and Quantity from the fact view, and the PRODUCTCATEGORYID from the product dimension.
I think this offers a lot of possibilities for getting data out of Datasphere.
Conclusion
In this post, I looked deeper into the SAP Datasphere API to get data directly from the system. You can access relational views or analytical models and consume them in other tools. Prerequisite is the OAuth we created in the previous post. What do you think about accessing the data via API?
In the next post we will switch to Python and try to get the data we have consumed with post in Python.
author.
Hi,
I am Tobias, I write this blog since 2014, you can find me on Twitter, Facebook and YouTube. I work as a Senior Business Warehouse Consultant. In 2016, I wrote the first edition of Analysis Office - The Comprehensive Guide. If you want, you can leave me a PayPal coffee donation. You can also contact me directly if you want.
Subscribe
- In my newsletter, you get informed about new topics
- You learn how to use Analysis Office
- You get tips and tricks about SAP BI topics
- You get the first 3 chapters of my e-book Analysis Office - The Comprehensive Guide for free
You want to know SAP Analysis Office in a perfect detail?
You want to know how to build an Excel Dashboard with your Query in Analysis Office?
You want to know how functions in SAP Analysis Office works?
Then you have to take a look into Analysis Office - The Comprehensive Guide. Either as a video course or as an e-book.
Write a comment