1.0.6 • Published 2 years ago
easy-github-search v1.0.6
easy-github-search
A much easier way to search for users on GitHub, interacting with the GitHub API.
First steps:
Installation:
To start, we should install the package using npm install easy-github-search
.
npm install easy-github-search
Creating module:
Before using the methods, we will have to create a constructor, with which we will be able to do the searches in GitHub.
const GitHub = require("easy-github-search"); // We define our package.
const search = new GitHub(); // We create our constructor.
With all that, we would already have our initial module.
Documentation:
The package contains some methods to use.
searchUser()
To search for users on GitHub. Example:
search.searchUser("LonelyDeath-VGX").then((res) => { console.log(res); });
- Return
Object
.
getUserRepos()
To get the first repository found from the user. Example:
search.getUserRepos("LonelyDeath-VGX").then((res) => { console.log(res); });
- Return
Object
.
Responses:
Sample response from the searchUser
method:
{
username: "LonelyDeath-VGX",
id: 99565725,
nodeId: "U_kgDOBe9AnQ",
avatarUrl: "https://avatars.githubusercontent.com/u/99565725?v=4",
gravatarId: "",
url: "https://api.github.com/users/LonelyDeath-VGX",
htmlUrl: "https://github.com/LonelyDeath-VGX",
name: "LonelyDeathVGX",
bio: null,
email: null,
followers: 1,
following: 0,
createdAt: "2022-02-12T23:43:49Z",
updatedAt: "2022-09-04T21:39:02Z",
company: null,
location: null,
publicRepos: 1,
publicGists: 0,
twitter: null,
blog: ""
}
Sample response from the getUserRepos
method:
{
owner: {
username: "LonelyDeath-VGX",
id: 99565725,
nodeId: "U_kgDOBe9AnQ",
avatarUrl: "https://avatars.githubusercontent.com/u/99565725?v=4",
gravatarId: "",
url: "https://api.github.com/users/LonelyDeath-VGX"
},
repository: {
info: {
name: "Distube-Bot",
description: "Un bot de música creado con discord.js y distube, soporta spotify y algunas cosas más.",
topics: [],
visibility: "public",
forks: 0,
openIssues: 0,
watchers: 1,
defaultBranch: "main"
},
license: { key: null, name: null, spdxId: null, url: null }
}
}
Types of errors:
Nothing found:
If the search was not found:
{ message: "The search was not found.", severity: "COMMON" }
Method:
if (res.message === "The search was not found." && res.severity === "COMMON") {
return console.log("Nothing was found.");
}
Ratelimit:
If the API got a rate limit:
{ message: "Rate-limit exceeded.", severity: "FAULT" }
Method:
if (res.message === "Rate-limit exceeded." && res.severity === "FAULT") {
return console.log("The API got a rate limit.");
}
Support:
We are open to any questions or suggestions on our Discord server.
Thank you for downloading and using this package!