# refir

> Add referral to your app with ease. With refir you can grow your user-base by aloowing your users to refer friends

Latest version **1.0.4** (published 2023-11-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install refir
pnpm add refir
yarn add refir
bun add refir
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2023-11-30 |
| First published | 2023-09-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | cirlorm |
| Maintainers | cirlorm_io |
| Keywords | refir, referral, refer |

## Links

- npm: https://www.npmjs.com/package/refir
- Repository: https://github.com/champ3oy/refir.js
- Homepage: https://github.com/champ3oy/refir.js#readme
- Issues: https://github.com/champ3oy/refir.js/issues
- npm.io page: https://npm.io/package/refir

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.5.0

## Recent versions

- 1.0.4 (latest) — 2023-11-30
- 1.0.3 — 2023-10-03
- 1.0.2 — 2023-09-20
- 1.0.1 — 2023-09-20
- 1.0.0 — 2023-09-20

## README

# Refir - Grow your user-base with referrals

Refir is a Node.js library that simplifies the management of referral programs for startups. With Refir, you can easily integrate referral functionality into your application, allowing you to track referrals, assign referral codes, and more.

## Prerequisites

Before you can start using Refir, you'll need to complete the following steps:

1. **Sign Up at Our Website**: To access the Refir API and obtain an API key, you must first sign up at our website [refir](https://refir.vercel.app). Once you've signed up, you'll be able to log in to your dashboard to manage your referral program, track users, and access insights and reports.

2. **Obtain Your API Key**: After signing up and logging in to your dashboard, you'll find your unique API key in the campaign settings or API section of your dashboard. This API key is required to configure Refir and make API requests.

## Table of Contents

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
  - [Adding a User](#adding-a-user)
  - [Getting a User by ID](#getting-a-user-by-id)
- [Error Handling](#error-handling)
- [Contributing](#contributing)
- [License](#license)

## Installation

To get started with Refir, you can install it using npm or yarn:

```bash
npm install refir
# or
yarn add refir
```

## Configuration

Before using Refir, you need to configure it with your API key. You can do this as follows:

```javascript
const Refir = require("refir");

const refir = new Refir();
refir.configure({ apiKey: "your-api-key" });
```

## Usage

### Adding a User

You can use Refir to add a user to your referral program. The following example demonstrates how to do this:

```javascript
const user = {
  userId: "unique-user-id",
  name: "John Doe",
  email: "johndoe@example.com",
};

const user = await refir.addUser(user);

if (user.status) {
  console.log(user);
  console.log("User added successfully.");
} else {
  console.error("Failed to add user.");
}
```

### Getting a User by ID

You can retrieve a user's referral code by their unique ID using Refir. Here's an example of how to do it:

```javascript
const userId = "unique-user-id";

const referral = await refir.getUserById(userId);

if (referral.status) {
  console.log(`User's referral code and link: ${referralCode.data}`);
} else {
  console.error("Failed to get user referral code.");
}
```

## Error Handling

Refir provides basic error handling for API requests. If an error occurs during an API request, an error message will be logged to the console, and the function will return `false`. You can customize error handling to suit your application's needs.

## Contributing

Contributions are welcome! If you have suggestions, bug reports, or want to contribute to the development of Refir, please check out our [contribution guidelines](CONTRIBUTING.md).

## License

Refir is licensed under the [MIT License](LICENSE).

---

Feel free to customize this documentation to match your package's specific features and requirements. Make sure to include relevant information about how to use your library and any additional functionality it provides.

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