Skip to main content
All CollectionsReports
Use AGR's API to get data into PowerBI or Excel reports
Use AGR's API to get data into PowerBI or Excel reports
Updated over a week ago

Overview

The AGR Public API allows you to fetch forecast data and other calculations that AGR generates, enabling you to perform analysis using a BI tool of your choice.

This article covers how to get Forecast and Item data since they depend on each other.

Below is a step-by-step guide on connecting to your data feed using PowerBI, although it is applicable in Excel too.

  1. Open AGR and ask for an access token to the AGR Public API through the help chat.

  2. A Customer Success Manager will supply you with a very long jumble of characters. This is your API token.

  3. Open PowerBI, click Get Data and select Web:

    <a href="https://downloads.intercomcdn.com/i/o/949969185/ab8089dcaf7aa221261bdf08/image.png?expires=1725894000&amp;signature=2b71f14e7c0c16c389194182671dba25ecb48cc7a3b0d1bd549f660313d78ea1&amp;req=fSQuH893nIlaFb4X1HO4gTsWi0p0RioAuBUyxmF65JjtKnRRu5afSjNxJyQ4%0A" target="_blank" rel="nofollow noopener noreferrer">https://downloads.intercomcdn.com/i/o/949969185/ab8089dcaf7aa221261bdf08/image.png?expires=1717672500&amp;signature=da497f8aef9c2b8fe39486402b869c2bde03e2bbd78912b9923d0a93621f5790</a>

    We will start by getting the forecast values and then the Items.

  4. In the window that pops up, select Advanced.

    • Paste the following URL into the URL parts text box (https://api.agrinventory.net/api/Forecast/values/all/stream).

    • Write "Authorization" into the HTTP request header parameters text box.

    • Write "Bearer " into the text box to the right.

    • Finally, paste the API token you received in step 2 behind the Bearer keyword. Your window should look like this:

    <a href="https://downloads.intercomcdn.com/i/o/949979979/773088a4ed3331eeb7e1b325/image.png?expires=1725894000&amp;signature=b51447a67028c65eeea4c6e00230085f526f5cbccc339036333736607b43d467&amp;req=fSQuH853lIZWFb4X1HO4gSSt9TvKM9I7Ksb%2BEGrUXD4hQ4Ybvu1ycPzjMBNM%0A" target="_blank" rel="nofollow noopener noreferrer">https://downloads.intercomcdn.com/i/o/949979979/773088a4ed3331eeb7e1b325/image.png?expires=1717672500&amp;signature=786e2939469f0952decd90ce4765b9ec94ee1e62f4e4184311f996883a9ad24b</a>

    Note that it is important to have a space between the "Bearer" keyword and your API token!

  5. Press OK to get another modal. Select Anonymous in the top left and press Connect.

  6. A Power Query Editor window will open. You should see something like the image below:

    <a href="https://downloads.intercomcdn.com/i/o/949987744/903b87b56a0fafea8743e915/image.png?expires=1725894000&amp;signature=e42250a71e1480008a4c6c0979bebc8c1b5939df2e51e50e1ab0f637e6588917&amp;req=fSQuH8F5moVbFb4X1HO4gavwPlzgn7wbsedyWMyRxiqFgsIyx8Evr8%2BnHecX%0A" target="_blank" rel="nofollow noopener noreferrer">https://downloads.intercomcdn.com/i/o/949987744/903b87b56a0fafea8743e915/image.png?expires=1717672500&amp;signature=991449254b8e4839a70a66524d71e3fcaa78d990a87b00c2400d77b98f2fe141</a>

    For this example, we won't transform or modify the data. Click Close & Apply in the top left. You now have a data stream for forecast values generated by AGR.

  7. To get the Item list and supporting information, in the same PowerBI window, repeat steps 3. to 5. but put the following URL into the URL parts textbox (https://api.agrinventory.net/api/Item/stream).

  8. A Power Query Editor window will open. This one should look like the image below:

    <a href="https://downloads.intercomcdn.com/i/o/950000081/15e65bcca7b207f395d76fb9/image.png?expires=1725894000&amp;signature=a61478fb455bec6785402db0024ebc7cc32def4cab23e82bc8f1725a97388c27&amp;req=fSUnFsl%2BnYleFb4X1HO4gZtLDm%2BUW8qX8Gsnl2%2FaukjIABbSUsLUQn1oe1ZT%0A" target="_blank" rel="nofollow noopener noreferrer">https://downloads.intercomcdn.com/i/o/950000081/15e65bcca7b207f395d76fb9/image.png?expires=1717672500&amp;signature=cb0ad5f3ea0c5a06cbd63309013b23702bee14eeb417350350364f745f0c63ed</a>

    Now is a good time to rename the two queries we have set up to something more descriptive.

    In this example, we have renamed the Forecast and Items queries to ForecastValues and ItemInfo, respectively. When done, press Close & Apply in the top left.

  9. If you click on the Model View in the left sidebar, you can see a small model for the two previously created queries. PowerBI usually creates relationships automatically, so your model will look similar to the image below.

    <a href="https://downloads.intercomcdn.com/i/o/950004592/7892516f2688fe24ed192a41/image.png?expires=1725894000&amp;signature=9cf84b6bd4586df2b0f1bf0228898d17641680ce34587ab0993dbf414a792d97&amp;req=fSUnFsl6mIhdFb4X1HO4gXbCYRuQpBYs61TpKw1Ue2aCEk0OW%2B2hj8W6q8Aq%0A" target="_blank" rel="nofollow noopener noreferrer">https://downloads.intercomcdn.com/i/o/950004592/7892516f2688fe24ed192a41/image.png?expires=1717672500&amp;signature=7671fb95d3305ee00357349055742627ec8f984d3776a7551fa9b688f914f868</a>

You should now have a functioning data set in PowerBI and can start analyzing!

Please note that the refresh schedule needs to be set to once per day.

Did this answer your question?