Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searching users docs #954

Merged
merged 2 commits into from
Oct 31, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion docs/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,52 @@ var request = new SearchRepositoriesRequest("mvc client side framework")

## Search Users

**TODO**
To search for users using Octokit you need to create a `SearchUsersRequest` and populate it with the search criteria.

```csharp
// Initialize a new instance of the SearchUsersRequest class with a search term
var request = new SearchUsersRequest("dhh");

var result = await githubClient.Search.SearchUsers(request);
```

Now we can further filter our search.

```csharp
var request = new SearchUsersRequest("dhh")
{
// lets find user with over 1k followers
Followers = Range.GreaterThan(1000),

// find a user created after the date
Created = DateRange.GreaterThan(new DateTime(2015, 1, 1)),

// we can search the location of a user, found a martian anyone?
Location = "Mars",

// find a user that has over 100 repos
Repositories = Range.GreaterThan(100),

// how about we find users that have a repo that match a certain language
Language = Language.JavaScript,

// we may want to restrict to orgs or users only
AccountType = AccountSearchType.Org,

// maybe we want to peek the username only?
In = new[] { UserInQualifier.Username },

// or go all out and search username, email and fullname?
In = new[] { UserInQualifier.Username, UserInQualifier.Email, UserInQualifier.Fullname },
};
```

We can also sort our results, by Followers, Repositories, Joined or leave as null for best match.

```csharp
var request = new SearchUsersRequest("dhh")
{
// sort by the number of followers
SortField = UsersSearchSort.Followers
}
```