Improving available API Resources

I’m developing a Desktop widget for ‘Homepage’ and I will need some more variable available by default.
I’m using connected_sites_count and disconnected_sites_count which are great.

What I can also use under Sites
update_available_plugin_count
update_available_theme_count
update_available_wordpress_count
etc.
Is there any chance these could be added in?

Thank you
Sandor Gera

Hi @gerasandor,

Do you need this info per site or in total?

If you need these counts in total, you can use the /available-updates endpoint, and use count() to count results.
For example, to get count of available plugin updates, you can use count($response['plugins'])

If you need per site level, you can do the same, just use /site-available-updates endpoint.

2 Likes

@gerasandor Here is the endpoint documentation that @bogdan is recommending.

https://mainwp.dev/rest-api/#elementor-toc__heading-anchor-63

Simply replace “plugins” with the folowing:

wp_core
themes
translation

In order to get a list of individual sites you will need to first access the /all-sites endpoint and then loop over the returned data and pass the site ID over to /site-available-updates as @bogdan recommends & then do your counting.

1 Like

Thank you for your help. It was really useful.
It is getting a bit more complicated as there are some sites where the following switches are ON:

  • Ignore core updates
  • Ignore plugin updates
  • Ignore theme updates
    With these listed as well the calculations are not the same as it is on the actual website.
    I know this is there for each individual site but I would not do around 2-300 API request to get the correct numbers.
    Would it be possible to go back to the original idea to add these numbers into the API as they are calculated on the main page?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.