The Tiny1z API Client is a powerful and lightweight npm package designed to simplify the integration of Tiny1z URL Shortener API into your applications. This client provides functions to create short URLs, retrieve user-specific URLs, get information about a single URL, and fetch all created URLs.
Features
- Create Single URL: Shorten a single URL with optional settings like password protection and expiry.
- Create Bulk URL: Shorten multiple URLs in bulk.
- Get User URLs: Retrieve URLs created by a specific user reference.
- Single URL Info: Get detailed information about a specific short URL.
- Get All URLs: Fetch all URLs created by the authenticated user.
Installation
npm install tiny1z
Get a Tiny1z API Key
To integrate the Tiny1z API into your applications, you'll need a Tiny1z API key. Follow these steps to obtain your API key:
-
Sign up for a Tiny1z account:
- If you don't already have a Tiny1z account, sign up by visiting Tiny1z Signup.
-
Access your developer dashboard:
-
Retrieve your API key:
- In the developer dashboard, locate the section that provides your API key.
- Copy the API key; you will need it for making requests to the Tiny1z API.
Now you are ready to start using the Tiny1z api.
Example:
import { createSingleUrl } from 'tiny1z';
const apiKey = 'your-api-key';
const data = {
originalUrl: 'https://www.example.com',
};
const response = await createSingleUrl(data, apiKey);
Usage
import { createSingleUrl, createBulkUrl, getUserUrls, singleUrlInfo, getAllUrls } from 'tiny1z';
const apiKey = 'your-api-key';
const singleUrlData = {
"original_url": "https://www.example.com",
"alias": "alias-example",
"password": "123456",
"expiry_duration": 5,
"expiry_unit": "hours",
"user_reference": "adam"
};
const singleUrlResponse = await createSingleUrl(singleUrlData, apiKey);
const bulkData = {
"original_urls": [
{
"url": "https://www.example.com",
"alias": "alias-example",
"password": "123456",
"expiry_duration": 5,
"expiry_unit": "hours",
},
{
"url": "https://www.example.com"
}
],
"global_password": null,
"global_expiry_duration": null,
"global_expiry_unit": null,
"user_reference": "ali"
};
const bulkUrlResponse = await createBulkUrl(bulkData, apiKey);
const userReference = 'user_reference';
const userUrls = await getUserUrls(userReference, apiKey);
const slug = 'alias-example';
const singleUrlInfoResponse = await singleUrlInfo(slug, apiKey);
const offset = 0;
const limit = 10;
const sort = 'desc';
const allUserUrls = await getAllUrls(offset, limit, sort, apiKey);
API Documentation
For detailed information on API endpoints, parameters, and response formats, refer to the Tiny1z API Documentation.
Rate and Usage Limits
Be aware of the rate and usage limits when using the Tiny1z API. Ensure you include your API key in the Authorization header for each request.
Contributing
If you'd like to contribute to the development of this package, feel free to submit pull requests or open issues on the GitHub repository.