Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Raju_6952
Creator III
Creator III

App metadata using api call

Hi.

I need to fetch the metadata of each application like file size and other details in qlik cloud analytics using api call but I am only getting 1 line of data using below api call

GET /api/v1/apps/{appId}/metadata

.is there a way to Loop through all other apps metadata using the same api call to fecth the data mentioned above?

 

Regards,

Raju

 

 
Labels (2)
1 Solution

Accepted Solutions
marksouzacosta

Hi @Raju_6952,

If you are looking only for App Size, you can use the Get Items API Endpoint.

If you need the App Metadata, you'll have to use a combination of Get Items (or Get App) Endpoint, loop through the returned App IDs, and then the metadata from Get App Metadada Endpoint for each listed app.

I'll assume that you need the App Metadata, so in this case you can do this code - this may take some time to reload depending on the number of apps you have on your Tenant:

LIB CONNECT TO 'Get Apps';

// Get the list of Apps
[AppList]:
LOAD
	[id] AS [AppID],
    [id] AS [AppLoopID], // just for looping purposes in the next step
	[name] AS [AppName],
	[ownerId] AS [OwnerID],
	[spaceId] AS [SpaceID]
WHERE
	NOT IsNull([__FK_attributes])
;
SQL SELECT 
	"__KEY_root",
	(SELECT 
		"__FK_data",
		"__KEY_data",
		(SELECT 
			"id",
			"name",
			"ownerId",
			"spaceId",
			"__FK_attributes",
			"__KEY_attributes"
		FROM "attributes" PK "__KEY_attributes" FK "__FK_attributes")
	FROM "data" PK "__KEY_data" FK "__FK_data")
FROM JSON (wrap on) "root" PK "__KEY_root";


// For each app previously loaded, get the metadata
For Each vAppID in FieldValueList('AppLoopID')

	// Dynamically sets the URL to use in the REST Connector
	LET vGetAppMetadataUrl = 'https://your-tenant.us.qlikcloud.com/api/v1/apps/$(vAppID)/data/metadata';
    
    LIB CONNECT TO 'Get App Metadata';

	// Your query and sub-tables will change according to the fields you need to load
    [TempAppMetadata]:
    SQL SELECT 
        "static_byte_size",
        "__KEY_root",
        (SELECT 
            "cpu_time_spent_ms",
            "peak_memory_bytes",
            "fullReloadPeakMemoryBytes",
            "__FK_reload_meta",
            "__KEY_reload_meta"
        FROM "reload_meta" PK "__KEY_reload_meta" FK "__FK_reload_meta")
    FROM JSON (wrap on) "root" PK "__KEY_root"
    WITH CONNECTION (
    	Url "$(vGetAppMetadataUrl)"
    )
    ;

    [AppReloadMetadata]:
    LOAD
        '$(vAppID)' AS [AppID],
        [cpu_time_spent_ms],
        [peak_memory_bytes],
        [fullReloadPeakMemoryBytes]
    RESIDENT
        [TempAppMetadata]
    WHERE
        NOT IsNull([__FK_reload_meta])
    ;

    [AppSize]:
    LOAD
        '$(vAppID)' AS [AppID],
        [static_byte_size]
    RESIDENT
        [TempAppMetadata]
    WHERE
        NOT IsNull([__KEY_root])
    ;

    DROP TABLE [TempAppMetadata];
    
Next vAppID

These are the two REST Connections needed:

The first one is to return the list of Applications - with a few more info if needed. The green arrows are the things you need to adjust. This connection requires pagination:

marksouzacosta_0-1739471925198.png

 

The second REST Connection returns the Metadata. Enter the URL to collect the metadata for one application where you know its ID. Don't worry about it, in the Load Script we will dynamically overwrite the URL from this REST Connection. That is why the Allow WITH Connection is mandatory for this connection. Pagination is NOT required on this connection:

marksouzacosta_2-1739472067117.png

This is everything. I hope it helps!

Regards,

Mark Costa

 

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

View solution in original post

7 Replies
marksouzacosta

Hi @Raju_6952,

If you are looking only for App Size, you can use the Get Items API Endpoint.

If you need the App Metadata, you'll have to use a combination of Get Items (or Get App) Endpoint, loop through the returned App IDs, and then the metadata from Get App Metadada Endpoint for each listed app.

I'll assume that you need the App Metadata, so in this case you can do this code - this may take some time to reload depending on the number of apps you have on your Tenant:

LIB CONNECT TO 'Get Apps';

// Get the list of Apps
[AppList]:
LOAD
	[id] AS [AppID],
    [id] AS [AppLoopID], // just for looping purposes in the next step
	[name] AS [AppName],
	[ownerId] AS [OwnerID],
	[spaceId] AS [SpaceID]
WHERE
	NOT IsNull([__FK_attributes])
;
SQL SELECT 
	"__KEY_root",
	(SELECT 
		"__FK_data",
		"__KEY_data",
		(SELECT 
			"id",
			"name",
			"ownerId",
			"spaceId",
			"__FK_attributes",
			"__KEY_attributes"
		FROM "attributes" PK "__KEY_attributes" FK "__FK_attributes")
	FROM "data" PK "__KEY_data" FK "__FK_data")
FROM JSON (wrap on) "root" PK "__KEY_root";


// For each app previously loaded, get the metadata
For Each vAppID in FieldValueList('AppLoopID')

	// Dynamically sets the URL to use in the REST Connector
	LET vGetAppMetadataUrl = 'https://your-tenant.us.qlikcloud.com/api/v1/apps/$(vAppID)/data/metadata';
    
    LIB CONNECT TO 'Get App Metadata';

	// Your query and sub-tables will change according to the fields you need to load
    [TempAppMetadata]:
    SQL SELECT 
        "static_byte_size",
        "__KEY_root",
        (SELECT 
            "cpu_time_spent_ms",
            "peak_memory_bytes",
            "fullReloadPeakMemoryBytes",
            "__FK_reload_meta",
            "__KEY_reload_meta"
        FROM "reload_meta" PK "__KEY_reload_meta" FK "__FK_reload_meta")
    FROM JSON (wrap on) "root" PK "__KEY_root"
    WITH CONNECTION (
    	Url "$(vGetAppMetadataUrl)"
    )
    ;

    [AppReloadMetadata]:
    LOAD
        '$(vAppID)' AS [AppID],
        [cpu_time_spent_ms],
        [peak_memory_bytes],
        [fullReloadPeakMemoryBytes]
    RESIDENT
        [TempAppMetadata]
    WHERE
        NOT IsNull([__FK_reload_meta])
    ;

    [AppSize]:
    LOAD
        '$(vAppID)' AS [AppID],
        [static_byte_size]
    RESIDENT
        [TempAppMetadata]
    WHERE
        NOT IsNull([__KEY_root])
    ;

    DROP TABLE [TempAppMetadata];
    
Next vAppID

These are the two REST Connections needed:

The first one is to return the list of Applications - with a few more info if needed. The green arrows are the things you need to adjust. This connection requires pagination:

marksouzacosta_0-1739471925198.png

 

The second REST Connection returns the Metadata. Enter the URL to collect the metadata for one application where you know its ID. Don't worry about it, in the Load Script we will dynamically overwrite the URL from this REST Connection. That is why the Allow WITH Connection is mandatory for this connection. Pagination is NOT required on this connection:

marksouzacosta_2-1739472067117.png

This is everything. I hope it helps!

Regards,

Mark Costa

 

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

diegozecchini
Specialist
Specialist

Following thanks @marksouzacosta 

Raju_6952
Creator III
Creator III
Author

Hi @marksouzacosta ,

Many thanks for sharing the inputs here to fix this issue on my end.

Regards,

Raju

marksouzacosta

No problem @Raju_6952, it is my pleasure.
Let us know if you have any other questions.

Regards,

Mark Costa

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

Raju_6952
Creator III
Creator III
Author

Hi @marksouzacosta ,

just wanted to check is there a way to track the RAM usage details consumed by user and use b

consider like we have one text app and it has some concurrent users which are accessing the system simultaneously and RAM required for making the selection state and other stuff.

currently I am able to fetch Static file size and App reload statiscs data using Rest api connection.

Regards,

Raju

TejalJadhav92
Partner - Contributor II
Partner - Contributor II

@marksouzacosta  can you please ex;plain how to automate exporting Qlik SaaS app scripts using qlik
and the Qlik REST APIs

marksouzacosta

Hi @TejalJadhav92 I see your question on this link: to automate exporting Qlik SaaS app scripts using ... - Qlik Community - 2516785

I'll try to help you from there. 

 

Thank you!

Mark Costa

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com