Get list of ion assets in cesium

735 views
Skip to first unread message

leh...@gmail.com

unread,
Mar 7, 2019, 7:49:14 AM3/7/19
to cesium-dev
Is there a way to get a list of Cesium Ion assets for display in a popup on a Cesium application? Minimally, I need the asset ID and name so when users select an item in the list it can be displayed on the globe. We've searched the API and other sources and have been unable to find any discussion of this. Thank you.

Omar Shehata

unread,
Mar 8, 2019, 9:39:24 AM3/8/19
to cesium-dev
There does exist an ion API, but it's not documented yet. I'm not sure what the exact route would be for this, but I'm bumped this issue here which has some more info:


Feel free to follow up there too. 

Dale Lehman

unread,
Mar 8, 2019, 10:05:27 AM3/8/19
to cesium-dev
Thank you, Omar. I actually had found that post the other day, but I'm not sure I understand how it addresses what we're trying to do. We are currently creating a Cesium.Ion object with our access token. We can then display assets using Cesium.IonResource.fromAssetId() so long as we know the asset IDs.

The missing piece is this: How do we retrieve a list of available asset IDs and their associated asset names from Ion? We want to present this list to the user, who can then select which assets to show. We would use Cesium.IonResource.fromAssetId() to display the selected assets. The reason we want to do this is that users will be able to add assets to Ion, so we can't hard code the IDs. The only other alternative I see is to create a tool for adding asset IDs and names to our database, which is doable but requires users to do double-entry when creating assets (once in Ion, once in our DB).

If there isn't any available documentation, might there be a code snippet showing how to get the asset list, assuming it's possible? Thank you again.

--Dale

Omar Shehata

unread,
Mar 8, 2019, 10:49:23 AM3/8/19
to cesium-dev
What you need is:

How do we retrieve a list of available asset IDs and their associated asset names from Ion

This is exactly what the ion API would allow you to do (in addition to programmatically creating, deleting, or modifying assets). For example, I did some digging, and the route you want is:


This will give you a list of ion assets with some information on each one, for whatever access token is currently authenticate. Matt mentions several ways to authenticate via the thread linked in the GitHub issue there. One way is to add the token in the URL:


You can make this request from any application, not just CesiumJS/not just JavaScript, but in CesiumJS it would be:

Cesium.Resource.fetchJson('https://api.cesium.com/assets?access_token=<your token>')
    .then(function(result){
        // `result` is all available asset IDs and their names
        console.log(result);
    });

Dale Lehman

unread,
Mar 8, 2019, 11:04:55 AM3/8/19
to cesium-dev
Hi Omar,

Ah, okay, that makes sense now. I'll give it a try. Thank you!

--Dale
Message has been deleted

rohit.chou...@gmail.com

unread,
Apr 24, 2019, 4:18:17 AM4/24/19
to cesium-dev
Hi Omar,

I am using https://api.cesium.com/assets?access_token=<your token here> API in my application and it works fine.

But today it stopped working. I am getting CORS Policy issue on API.

Access to XMLHttpRequest at 'https://api.cesium.com/assets?access_token=<access-token>' from origin 'http://localhost:38389' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Can you please help on this?


Thanks
Rohit

Omar Shehata

unread,
Apr 24, 2019, 9:10:38 AM4/24/19
to cesium-dev
I think this route might have been updated to https://api.cesium.com/v1/assets (you can see this when opening your ion dashboard).

Also, if you're using the default ion token, it won't have access to this route. You need to make sure your token has the "assets:list" scope. That way you can control exactly how much permission each token has. Let me know if that works for you.

rohit.chou...@gmail.com

unread,
Apr 24, 2019, 9:52:14 AM4/24/19
to cesium-dev
Thanks Omar. There is an issue with api route, which has been changed now.

On Wednesday, April 24, 2019 at 6:40:38 PM UTC+5:30, Omar Shehata wrote:
> I think this route might have been updated to https://api.cesium.com/v1/assets (you can see this when opening your ion dashboard).
>
>
> Also, if you're using the default ion token, it won't have access to this route. You need to make sure your token has the "assets:list" scope. That way you can control exactly how much permission each token has. Let me know if that works for you.
>
> On Wednesday, April 24, 2019 at 4:18:17 AM UTC-4, rohit.cho...@gmail.com wrote:Hi Omar,

Omar Shehata

unread,
Apr 25, 2019, 2:08:15 PM4/25/19
to cesium-dev
The ion REST API is officially out! Check it out, let me know if you have any feedback:

Reply all
Reply to author
Forward
0 new messages