GithubHelp home page GithubHelp logo

scriptex / universal-github-client Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 3.53 MB

A Github API Client for the browser and Node

Home Page: https://atanas.info/portfolio/open-source/universal-github-client

License: MIT License

TypeScript 100.00%
github-api github-client github-api-v3

universal-github-client's Introduction

Travis CI Github Build Codacy Badge Codebeat Badge CodeFactor Badge DeepScan grade Analytics

Universal Github Client

A Github API Client for the browser and Node JS

Visitor stats

GitHub stars GitHub forks GitHub watchers GitHub followers

Code stats

GitHub code size in bytes GitHub repo size GitHub language count GitHub top language GitHub last commit

Installation and getting started

First install the package

npm i universal-github-client

# or

yarn add universal-github-client

Then you need to generate a new token from your Github profile and make sure that this token has access to the relevant scopes that you plan to query the API for.

Then you need to configure and setup your Github Client instance:

In Node

You need to install a fetch polyfill because Node does not include one.

npm i node-fetch

# or

yarn add node-fetch
const fetch = require('node-fetch');
const { GithubClient } = require('universal-github-client');

const client = new GitHubClient({
	base: 'https://api.github.com',
	token: 'YOUR_GITHUB_TOKEN_HERE',
	fetch
});

In browser

Please note that this package is supported by browsers which implement natively the Fetch API and have support for Promises. If you are using an outdated browser, you need to install a polyfill for Fetch and Promises.

import { GithubClient } = from 'universal-github-client';

const client = new GitHubClient({
	base: 'https://api.github.com',
	token: 'YOUR_GITHUB_TOKEN_HERE',
	fetch
});

Usage

When you have installed and configured the client, you can make calls to the Github API:

You can use the paths defined in the Github API documentation.

For example, if you want to get the repositories for a user you need to do the following:

const repos = client.get({ path: '/users/scriptex/repo' }); // scriptex is the Github user name

There are five different instance methods based on the HTTP method required by a particular endpoint in the Github API.

client.get({ path });

client.post({ path, data });

client.delete({ path });

client.put({ path, data });

client.patch({ path, data });

LICENSE

MIT


Connect with me:

                     

Support and sponsor my work:

universal-github-client's People

Contributors

renovate-bot avatar renovate[bot] avatar scriptex avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

universal-github-client's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

This repository currently has no open or pending branches.


  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.