appurl
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

Official AppURL API for NodeJS

About

This module provides easy access to the AppURL API for NodeJS.

The AppURL API requires an API key / access token. To get your access token, visit https://docs.appurl.com/api/get-access-token.

For more information on the API structure, check out the AppURL API Docs.

Installation

NPM

npm install appurl

YARN

yarn add appurl

Usage:

Remember, this library uses an API key provided by AppURL. To get your access token check out docs.appurl.com/api/get-access-token.

If you would like more info on the underlying API check out docs.appurl.com.

Example:

import { AppUrlClient } from 'appurl';

const appurl = AppUrlClient('TOKEN');

 async function getShortedUrl(url) {
  let result;
  try {
    result = await appurl.shorten(url);
  } catch (err) {
    throw err;
  }

  return result;
}

getShortenedUrl('https://google.com');

Additional Features

Because the AppURL API is protected by an API key which you are responsible for we are able to offer more access.

Image Upload

The AppURL API and this Module accept image uploads. This allows for very specific control of how your link preview looks when shared across a variety of mobile devices and apps.

To use the image upload you must for BASE64 encode your image, then pass that string as the second argument of your shorten function call. Here is an example.

Example:

import { AppUrlClient } from 'appurl';

const appurl = AppUrlClient('TOKEN');
const base64EncodedImage = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=';

 async function getShortedUrl(url, base64EncodedImage) {
  let result;
  try {
    result = await appurl.shorten(url, base64EncodedImage);
  } catch (err) {
    throw err;
  }

  return result;
}

getShortenedUrl('https://google.com', base64EncodedImage);

The code above will upload the image at set it as your preview image. This is extremely handy for sharing.

Optional Properties

Optional properties are one more way you have complete control over your AppURL. The third optional argument of the shorten function is an object containing a very specific list of settings for your AppURL allowing you to control every aspect of it's functionality.

Properties

    'appName'
    'fallbackUrl'
    'iosIphoneAppUrl'
    'iosIphoneFallbackUrl'
    'iosIpadFallbackUrl'
    'iosIpadAppUrl'
    'androidAppPackage'
    'androidAppScheme'
    'androidFallbackUrl'
    'windowsPhoneAppUrl'
    'windowsPhoneFallbackUrl'
    'blackberryFallbackUrl'
    'clickSendUsername'
    'clickSendApiKey'
    'googleAnalyticId'
    'ogDescription'
    'ogImageUrl'

This example would upload the custom preview image and set the redirect landing page title to "My App" and the share preview description to "This is my amazing app!".

Example:

import { AppUrlClient } from 'appurl';

const appurl = AppUrlClient('TOKEN');
const base64EncodedImage = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=';

 async function getShortedUrl(url, base64EncodedImage, props) {
  let result;
  try {
    result = await appurl.shorten(url, base64EncodedImage);
  } catch (err) {
    throw err;
  }

  return result;
}

getShortenedUrl('https://google.com', base64EncodedImage, {
  appName: 'My App',
  ogDescription: 'This is my amazing app!'
});

Contact us

We are proud of the products we are making! If you have any questions please don't hesitate to reach out to AppURL Support.

Package Sidebar

Install

npm i appurl

Weekly Downloads

1

Version

1.0.6

License

MIT

Unpacked Size

10.7 kB

Total Files

10

Last publish

Collaborators

  • joshjensen