google / deps.dev

Resources for the deps.dev API
https://deps.dev
Apache License 2.0
258 stars 20 forks source link

Add dependent counts to the API #95

Closed mudongliang closed 4 months ago

mudongliang commented 5 months ago

Hi there,

we are trying to use deps.dev free API to replace bigquery in the criticality_score. The GCP configuration is not easy to use.

However, the current API only provides the dependency packages a specified package A depends on, other than the dependents which depends on the specified package A. So if we can collect the dependency graphs for all packages from deps.dev, we can calculate the count of dependents which depends on a specified package A.

Please correct us if we make any misunderstanding. Or if there is any convenience way to retrieve the dependents count.

sarnesjo-google commented 5 months ago

Hi @mudongliang! Dependent counts are not currently available from the API, but I'll take this feature request to the team. Please let me know if I've misunderstood your request.

Do note that we can't make the API return actual list of dependents, as it can be very large (100k+). For that you would still need to use the BigQuery dataset.

mudongliang commented 5 months ago

I see. Thanks very much.

sarnesjo-google commented 4 months ago

Hi again! There is now a GetDependents endpoint in the v3alpha API, which serves the same dependent counts as the deps.dev website. Please take a look and let us know if you have any questions or spot any issues.

mudongliang commented 4 months ago

Thanks, I will check it ASAP.

mudongliang commented 4 months ago

I have several questions about this API result.

{"dependentCount":303716, "directDependentCount":148783, "indirectDependentCount":156509}

sarnesjo-google commented 4 months ago

I checked the react package, its office webpage shows 226195 dependents, meanwhile, the API result shows 303716 dependents.

The dependent counts served by deps.dev are derived from the dependency graphs computed by deps.dev. They differ from the counts produced by npmjs.com in a few ways:

Please note that neither the dependent counts served by deps.dev nor by npmjs.com is the "actual" number of dependents, as neither count includes non-public usage. As mentioned in the documentation, dependent counts should be treated as indicative of relative popularity rather than precisely accurate.

From the API result, the total dependentCount != directDependentCount + indirectDependentCount.

As mentioned in the documentation, the total dependent count may be less than the sum of the direct and indirect dependent counts. The reason for this is that some dependents are both direct and indirect.

mudongliang commented 4 months ago

Thanks for your kind explanation. My problems are all solved.