Skip to content
Get started

Applying Filters to Included Attributes

Automatically apply repository search filters to included user attributes using field mapping.

When searching repositories, you can include user attributes (such as DevRank data) in the results via includeAttributes. By default, your repo filters only apply to the repository search itself. With applyFiltersToIncludeAttributes, the API automatically converts your repo filters into equivalent user filters and applies them to the included user data.

Repository and user data live in separate tables with different field names. For example, ownerLogin on a repo corresponds to login on the user table. When you search for repos owned by developers in San Francisco and want to include contributor data, you’d normally need to write a second set of filters targeting the user table. applyFiltersToIncludeAttributes handles this conversion for you.

The API maps repo filter fields to their user table equivalents:

Repo Filter FieldUser Field
ownerLoginlogin
ownerLocationlocation
loginlogin
locationlocation
companycompany
displayNamedisplayName
biobio
resolvedCountryresolvedCountry
resolvedStateresolvedState
resolvedCityresolvedCity

Repo-only fields like stargazerCount, language, or totalIssuesOpen have no user equivalent and are ignored when filtering included attributes.

Find popular Python repos with San Francisco contributors, and include DevRank data only for contributors who match the location filter:

const response = await client.searchRepos.search({
query: "machine learning",
filters: {
op: "And",
filters: [
{ field: "language", op: "Eq", value: "Python" },
{ field: "stargazerCount", op: "Gte", value: 1000 },
{
field: "resolvedCity",
op: "ContainsAllTokens",
value: "San Francisco",
},
],
},
includeAttributes: {
devrank: true,
},
applyFiltersToIncludeAttributes: true,
});
// The resolvedCity filter is mapped and applied to contributors,
// so only San Francisco-based contributors have DevRank data included.
// language and stargazerCount have no user equivalent and are skipped.
  • You want contributor/owner data that matches the same geographic or identity constraints as your repo search.
  • You want to avoid a separate user search call to filter the included attributes yourself.