Snippr

Mobile navigation menu

API Documentation

Snippr API

The Snippr API allows you to programmatically create, manage, and analyze short links.

Authentication

All API requests require authentication using an API key. You can create an API key in your dashboard.

Include your API key in the Authorization header of your requests:

Authorization: Bearer your_api_key

Code Examples

const API_KEY = 'your_api_key';
const API_URL = 'https://snppr.vercel.app/api/v1';

// Create a short link
async function createShortLink(url, options = {}) {
  const response = await fetch(`${API_URL}/links`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      url,
      ...options,
    }),
  });
  
  return response.json();
}

// Example usage
createShortLink('https://example.com', {
  customAlias: 'my-link',
  expiresAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString(), // 30 days
})
  .then(data => console.log(data))
  .catch(error => console.error(error));