Welcome to the HIVE API

We provide an API system that you can use to shorten links from your own applications and save them in your account in the process. You can also use the API to fetch data about a link, provided that you have the permission to do so. You can find out more information below.



Registering for an API Key

As before, an API key is required for requests to be processed by the system. Once a user registers, an API key is automatically created for this user. The API key must attached to request via the

Your API Key

						     Log in to see your API key						    						
api

parameter (see full example below).

To send a request, the user must use the following format where the variables

api

and

url

are required. To request a custom alias, simply add

&custom=

at the end.

Parameter Type Input Example Description
api string Log in to view Authorization
url string https://google.com Original link
custom* string google Custom Alias
password* string secretpw Password Access
description* string hello world Description
type* string direct , frame , splash Redirection type
* optional Public API key: spublic

Full example:

						  GET https://hive.am/api?api=APIKEY&url=THELONGLINKTOBESHORTENED&custom=CUSTOMALIAS
						  &password=PASSWORD&description=THEDESCRIPTION&type=DIRECT
						

Server response

As before, the response will encoded in JSON format (default). This is done to facilitate cross-language usage. The first element of the response will always tell if an error has occurred (error: 1) or not (error: 0). The second element will change with respect to the first element. If there is an error, the second element will be named "msg" which contains the source of error, otherwise it will be named "short" which contains the short link. (See below for an example)

						// No errors
						{
						  "error":0,
						  "short":"https:\/\/hive.am\/DkZOb"
						}
						// An error has occurred
						{
						  "error":1,
						  "msg":"Please enter a valid email"
						}
						

Using plain text format

You can request the response to be in plain text by just adding

&format=text

at the end of your request. This will return just

https://hive.am/DkZOb

instead of the JSON response. Note that if an error occurs, it will not output anything.

Users can easily request the long link from a short link. This doesn't require any API key and is free to all users. To unshorten a link, use this format

https://hive.am/api?short=SHORTLINK
 {
						 	"error":"0",
						 	"long":"LONGLINK",
						 } 				
						

Using the API in PHP

To use the API in your PHP application, you have to send a GET request through

file_get_contents

or

cURL

Both are reliable methods. You can see a sample code below using

file_get_contents
						<?php
						  // Using JSON Response
						  $api_url="https://hive.am/api?api=APIKEY&url=THELONGLINKTOBESHORTENED&custom=CUSTOMALIAS";
						  $res= @json_decode(file_get_contents($api_url),TRUE);
						  if($res["error"]){
						    echo $res["msg"];
						  }else{
						    echo $res["short"];
						  }
						
						  // Using Plain Text Response
						  $api_url="https://hive.am/api?api=APIKEY&url=THELONGLINKTOBESHORTENED&custom=CUSTOMALIAS&format=text";
						  $res= @file_get_contents($api_url);
						  if($res){
						    echo $res;
						  }
						?>


REST API

The REST API provides programmatic access to shorten and unshorten hive links. Head over to our REST API Documentation to learn more.