Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/dashlog/fetch-github-repositories

Fetch github repositories for a given user (or organization)
https://github.com/dashlog/fetch-github-repositories

fetch github nodejs repository

Last synced: 3 months ago
JSON representation

Fetch github repositories for a given user (or organization)

Lists

README

        

# Fetch-github-repositories
![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/dashlog/fetch-github-repositories/master/package.json&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/dashlog/fetch-github-repositories/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)
![dep](https://img.shields.io/david/dashlog/fetch-github-repositories)
![size](https://img.shields.io/github/languages/code-size/dashlog/fetch-github-repositories)

Fetch github repositories for a given user (or an organization).

## Requirements
- [Node.js](https://nodejs.org/en/) v16 or higher

## Why ?

- Fast and light (With a lazy API if required).
- Support both `users` and `orgs` endpoints with the **kind** option.
- Replacement for [repos](https://github.com/jonschlinkert/repos) which introduce dozen of dependencies.
- TypeScript support.

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @dashlog/fetch-github-repositories
# or
$ yarn add @dashlog/fetch-github-repositories
```

## Usage example
```js
import { fetch, fetchLazy } from "@dashlog/fetch-github-repositories";

const repos = await fetch("fraxken", {
fetchUserOrgs: true // if you want an equivalent of "repos"
});

// or use lazy API
for await (const repo of fetchLazy("fraxken")) {
console.log(repo.full_name);
}
```

## API

### fetch(namespace: string, options?: FetchOptions): Promise< Repository[] >
Return an Array of repositories (the interface can be found in index.d.ts).

```ts
export interface FetchOptions {
/**
* @default fetch-github-repo
*/
agent?: string;
token?: string | null;
/**
* @default users
*/
kind?: "users" | "orgs";
/**
* Fetch the repositories of all orgs for a given user
* @default false
*/
fetchUserOrgs?: boolean;
}
```

### fetchLazy(namespace: string, options?: FetchOptions): AsyncIterableIterator< Repository >
Same arguments as **fetch**.

## Contributors ✨

[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Gentilhomme

💻 🐛 📖 🛡️

## License
MIT