# github-profile-status

> Update the status of your GitHub profile programmatically

Latest version **1.0.0** (published 2019-11-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install github-profile-status
pnpm add github-profile-status
yarn add github-profile-status
bun add github-profile-status
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-11-13 |
| First published | 2019-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 62.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 62 |
| Author | Waseem Dahman |
| Maintainers | wsmd |
| Keywords | github, profile, profile-status, automation, github-api, api, graphql |

## Links

- npm: https://www.npmjs.com/package/github-profile-status
- Repository: https://github.com/wsmd/github-profile-status
- Issues: https://github.com/wsmd/github-profile-status/issues
- npm.io page: https://npm.io/package/github-profile-status

## Dependencies (1)

- [graphql-request](https://npm.io/package/graphql-request.md) ^1.8.2

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-11-13
- 1.0.0-beta.0 (beta) — 2019-11-12
- 0.3.0 — 2019-04-01
- 0.2.0 — 2019-03-31
- 0.1.0 — 2019-03-30

## README

<div align="center">

# github-profile-status <!-- omit in toc -->

[![Current Release](https://img.shields.io/npm/v/github-profile-status.svg)](https://www.npmjs.com/package/github-profile-status)
[![CI Build](https://travis-ci.org/wsmd/github-profile-status.svg?branch=master)](https://travis-ci.org/wsmd/github-profile-status)
[![Coverage Status](https://coveralls.io/repos/github/wsmd/github-profile-status/badge.svg?branch=master)](https://coveralls.io/github/wsmd/github-profile-status?branch=master)
[![Licence](https://img.shields.io/github/license/wsmd/github-profile-status.svg)](https://github.com/wsmd/github-profile-status/blob/master/LICENSE)

</div>

<details>
<summary>📖 Table of Contents</summary>
<p>

- [Motivation](#motivation)
- [Installation](#installation)
- [Example](#example)
- [API](#api)
  - [Constructor](#constructor)
    - [`new GitHubProfileStatus(options: ConstructorOptions)`](#new-githubprofilestatusoptions-constructoroptions)
    - [Constructor Options](#constructor-options)
  - [Methods](#methods)
    - [`get(): Promise<UserStatus | null>`](#get-promiseuserstatus--null)
    - [`getForUser(username?: string): Promise<UserStatus | null>`](#getforuserusername-string-promiseuserstatus--null)
    - [`set(status: ChangeUserStatusInput): Promise<UserStatus | null>`](#setstatus-changeuserstatusinput-promiseuserstatus--null)
    - [`update(status: ChangeUserStatusInput): Promise<UserStatus | null>`](#updatestatus-changeuserstatusinput-promiseuserstatus--null)
    - [`clear(): Promise<boolean>`](#clear-promiseboolean)
  - [`ChangeUserStatusInput`](#changeuserstatusinput)
  - [`UserStatus`](#userstatus)
- [Licence](#licence)

</p>
</details>

## Motivation

GitHub introduced a [new feature](https://github.blog/changelog/2019-01-09-set-your-status/) that allows you to set your status on your profile!

<div align="center">
<img src="https://user-images.githubusercontent.com/2100222/55207714-ba68c380-51b1-11e9-9283-d11e4265a827.png" width="482" />
<br />
<br />
</div>

This library gives you the ability to programmatically update your GitHub profile status. With this, you can do really interesting stuff, like [displaying what you're listening to](https://github.com/wsmd/github-now-playing) right on GitHub! The possibilities are endless!

## Installation

This library is available on the [npm](https://www.npmjs.com/package/github-profile-status) registry as a [node](https://nodejs.org/en/) module and can be installed by running:

```sh
# via npm
npm install --save github-profile-status

# via yarn
yarn add github-profile-status
```

## Example

```js
import { GitHubProfileStatus } from 'github-profile-status';

async function main() {
  const profileStatus = new GitHubProfileStatus({
    token: process.env.GITHUB_ACCESS_TOKEN,
  });

  // set your the github profile status
  await profileStatus.set({
    emoji: ':wave:',
    message: 'Hello, world!',
    limitedAvailability: true,
  });

  // update your the github profile status
  await profileStatus.update({
    message: 'Howdy!',
  });

  // get your github profile status
  const status = await profileStatus.get();

  // clears your github profile status
  const success = await profileStatus.clear();
}
```

## API

### Constructor

#### `new GitHubProfileStatus(options: ConstructorOptions)`

Creates a new github profile status instance.

#### Constructor Options

An object with the following keys:

- `token: string`: a [personal access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) with the **user** scope.

### Methods

Instances have the following methods:

#### `get(): Promise<UserStatus | null>`

Retrieves the status of the authenticated user.

Returns a Promise that resolves with the [user status](#userstatus) object, or `null` if the user does not have a status set.

#### `getForUser(username?: string): Promise<UserStatus | null>`

Retrieves the status of the provided user.

Returns a Promise that resolves with the [user status](#userstatus) object, or `null` if the user does not have a status set.

#### `set(status: ChangeUserStatusInput): Promise<UserStatus | null>`

Sets the user status using the provided [`status`](#changeuserstatusinput).

Note that attributes omitted from `status` will be cleared. If you only want to update the specified attributes without affecting any existing ones, consider using the [`update()`](#updatestatus-changeuserstatusinput-promiseuserstatus--null) method instead.

Returns a Promise that resolves with the [user status](#userstatus) object, or `null` if the status was cleared (e.g. providing an empty message).

#### `update(status: ChangeUserStatusInput): Promise<UserStatus | null>`

Partially updates the status with the provided attributes. All attributes of [`status`](#changeuserstatusinput) are optional. Attributes omitted from the `status` object will remain as they are.

Returns a Promise that resolves with the [user status](#userstatus) object, or `null` if the status was cleared (e.g. providing empty attributes).

#### `clear(): Promise<boolean>`

Clears the user profile status.

Returns a Promise that resolves to a boolean indicating a successful operation.

### `ChangeUserStatusInput`

```ts
interface ChangeUserStatusInput {
  /**
   * The emoji to represent your status. Can either be a native Unicode emoji or
   * an emoji name with colons, e.g., :wave:
   */
  emoji?: string | null;
  /**
   * If set, the user status will not be shown after this date. The value can be
   * either a Date object or an ISO-8601 encoded UTC date string.
   */
  expiresAt?: Date | string | null;
  /**
   * Whether this status should indicate you are not fully available on GitHub,
   * e.g., you are away.
   */
  limitedAvailability?: boolean;
  /**
   * A short description of your current status.
   */
  message?: string | null;
}
```

### `UserStatus`

The status object has the following keys:

```ts
interface UserStatus {
  /**
   * An emoji summarizing the user's status.
   */
  emoji: string | null;
  /**
   * If set, the status will not be shown after this date.
   */
  expiresAt: string | null;
  /**
   * Whether this status indicates the user is not fully available on GitHub.
   */
  limitedAvailability: boolean;
  /**
   * A brief message describing what the user is doing.
   */
  message: string | null;
}
```

## Licence

MIT

---
_Source: https://npm.io/package/github-profile-status · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
