Skip to content

Latest commit

 

History

History
307 lines (200 loc) · 9.33 KB

README.md

File metadata and controls

307 lines (200 loc) · 9.33 KB

karix-api

PayPal Ask me anything Version Downloads Get help on Codementor

Karix.io API wrapper for Node.js

The Karix.io API V2 Reference is a good resource to learn more about these APIs.

☁️ Installation

# Using npm
npm install --save karix-api

# Using yarn
yarn add karix-api

📋 Example

const Karix = require("karix-api");

var client = new Karix({
    accountId: process.env.KARIX_ACCOUNT_ID
  , accountToken: process.env.KARIX_ACCOUNT_TOKEN

    // This is optional
  , host: process.env.KARIX_HOST || "https://api.karix.io/"
});

client.getSubaccount((err, data) => {
    console.log(err || data);
    // =>
    // {
	//	"objects": [
	//		{
	//		"name": "Beth Smith",
	//		"status": "enabled",
	//		"uid": "7fea9708-ea28-42e9-871f-a07fe7cef72f",
	//		"token": "e664221d-4aed-415b-929b-7edf887e4680",
	//		"is_parent": false,
	//		"created_time": "2017-08-04T09:59:29.660Z",
	//		"updated_time": "2017-08-05T09:59:29.660Z",
	//		"account_type": "prepaid",
	//		"credit_balance": "127.33",
	//		"auto_recharge": false
	//		}
	//	],
	//	"meta": {
	//		"request_uuid": "e54b13f5-0831-40f1-959f-e9c5a8ff2957",
	//		"next": "https://api.karix.co/<resource>/?limit=10&offset=10",
	//		"previous": "string",
	//		"total": 1
	//	}
	//	}
});

client.getSubaccountById({ uid: "7fea9708-ea28-42e9-871f-a07fe7cef72f" }, (err, data) => {
    console.log(err || data);
    // =>
	//	{
	//		"meta": {
	//			"request_uuid": "e54b13f5-0831-40f1-959f-e9c5a8ff2957"
	//		},
	//		"data": {
	//			"name": "Beth Smith",
	//			"status": "enabled",
	//			"uid": "7fea9708-ea28-42e9-871f-a07fe7cef72f",
	//			"token": "e664221d-4aed-415b-929b-7edf887e4680",
	//			"is_parent": false,
	//			"created_time": "2017-08-04T09:59:29.660Z",
	//			"updated_time": "2017-08-05T09:59:29.660Z",
	//			"account_type": "prepaid",
	//			"credit_balance": "127.33",
	//			"auto_recharge": false
	//		}
	//	}
});

❓ Get Help

There are few ways to get help:

  1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.

  2. For bug reports and feature requests, open issues. 🐛

  3. For direct and quick help, you can use Codementor. 🚀

📝 Documentation

Karix(options)

Creates the instance of the Karix class.

Params

  • Object options: An object containing:
  • accountId (String): Karix Account ID (mandatory).
  • accountToken (String): Karix Account Token (mandatory)
  • host (String): The karix.io host (default: https://api.karix.io/).

createSubaccount(data, cb)

Create a new subaccount

Params

  • Object data: The Subaccount object as documented here.
  • Function cb: The callback function.

getSubaccount(params, cb)

Get a list of details of all subaccounts, including the main account.

Params

  • Object params: The query params as documented here.
  • Function cb: The callback function.

getSubaccountById(uid, cb)

Get details of an account by its uid. Both main account and subaccounts can be fetched using their uids.

Params

  • String uid: Alphanumeric ID of the subaccount to get.
  • Function cb: The callback function.

patchSubaccount(uid, data, cb)

Edit details of your account or its subaccount

Params

  • String uid: Alphanumeric ID of the subaccount to edit.
  • Object data: The Subaccount object (documented here).
  • Function cb: The callback function.

sendMessage(data, cb)

Send a message to a list of destinations.

Params

  • Object data: The Create Message object data (documented here).
  • Function cb: The callback function.

getMessage(params, cb)

Get list of messages sent or received. Sorted by descending order of created_time (latest messages are first)

Params

  • Object params: The query params (documented here).
  • Function cb: The callback function.

getMessageById(uid, cb)

Get message details by id.

Params

  • String uid: Alphanumeric ID of the message to get.
  • Function cb: The callback function.

getMedia(uid, cb)

Download or Stream media by id

Params

  • String uid: Alphanumeric ID of the media to get.
  • Function cb: The callback function.

createWebhook(data, cb)

Create webhooks to receive Message

Params

  • Object data: The Create Webhook object (documented here).
  • Function cb: The callback function.

getWebhook(params, cb)

Get a list of your webhooks

Params

  • Object params: The query params (documented here).
  • Function cb: The callback function.

getWebhookById(uid, cb)

Get a webhook by ID

Params

  • Object params: Alphanumeric ID of the webhook to get.
  • Function cb: The callback function.

patchWebhook(uid, data, cb)

Edit a webhook

Params

  • String uid: Alphanumeric ID of the webhook to edit.
  • Object data: The request body (documented here).
  • Function cb: The callback function.

deleteWebhookById(uid, cb)

Delete a webhook by ID

Params

  • String uid: Alphanumeric ID of the webhook to delete.
  • Function cb: The callback function.

numberSearch(params, cb)

Query for phone numbers in our inventory.

Params

  • Object params: The query params (documented here).
  • Function cb: The callback function.

rentNumber(data, cb)

Rent a phone number

Params

  • Object data: The Rent Details object (documented here).
  • Function cb: The callback function.

getNumber(params, cb)

Get details of all phone numbers linked to your account.

Params

  • Object params: The query params data (documented here).
  • Function cb: The callback function.

number(number, cb)

Get details of a number

Params

  • Integer number: Number for which details need to be fetched.
  • Function cb: The callback function.

patchNumber(number, data, cb)

Edit phone number belonging to your account

Params

  • Integer number: Number which needs to be edited.
  • Object data: The request body object (documented here).
  • Function cb: The callback function.

unrentNumber(number, cb)

Unrent number from your account

Params

  • Integer number: Number which needs to be unrented.
  • Function cb: The callback function.

😋 How to contribute

Have an idea? Found a bug? See how to contribute.

💖 Support my projects

I do web services and open-source my used projects as much as I can. I will try to reply to everyone needing help using these projects. It consumes a lot of time and hardwork. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:

  • PayPal—You can make one-time donations via PayPal. I'll probably buy a coffee tea. 🍵

  • Support me on Patreon—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).

  • Bitcoin—You can send me bitcoins at this address (or scanning the code below): 344FWmvxDt6FFFoYoFjftiT3gGus68AqNw

Thank you! ❤️

📜 License

[MIT][license]