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

https://github.com/anshsinghsonkhia/github-version-fetcher

NPM Package to fetch all semantically versioned tags of a GitHub repository using your own GitHub API token.
https://github.com/anshsinghsonkhia/github-version-fetcher

npm-package

Last synced: 7 months ago
JSON representation

NPM Package to fetch all semantically versioned tags of a GitHub repository using your own GitHub API token.

Awesome Lists containing this project

README

          

# github-version-fetcher
Fetch all semantically versioned tags of a GitHub repository using your own GitHub API token.


# Features
✅ Fetches **release tags** from a GitHub repo.
✅ Filters **only semantic versions** (e.g., `v1.2.3`).
✅ Returns sorted versions **from latest to oldest**.
✅ Uses **GitHub API v3** for fetching data.

# Installation

```shell
npm i github-version-fetcher
```

# Importing

### Importing in CommonJS (Node.js Default)
```js
const getVersions = require('github-version-fetcher');
```

### Importing in ES Modules (ECMAScript Imports)

```js
import getVersions from 'github-version-fetcher';
```

# Usage

```js
// Replace with your GitHub Personal Access Token
const GITHUB_TOKEN = 'your_personal_access_token';

(async () => {
try {
const versions = await getVersions('github-username/repo-name', GITHUB_TOKEN);
console.log('Versions:', versions);
} catch (error) {
console.error('Error fetching versions:', error);
}
})();

```

## Example Usage

```js
// Replace with your GitHub Personal Access Token
const GITHUB_TOKEN = 'your_personal_access_token';

(async () => {
try {
const versions = await getVersions('facebook/react', GITHUB_TOKEN);
console.log('Versions:', versions);
} catch (error) {
console.error('Error fetching versions:', error);
}
})();

```

# GitHub Authentication
GitHub limits API requests for unauthenticated users. To prevent failures, use a GitHub Personal Access Token (PAT).

### How to Get a GitHub Token?

- Go to [GitHub Developer Settings](https://github.com/settings/tokens)
- Click "Generate new token (classic)".
- Select public_repo scope.
- Copy the token and use it in your code.