API usage example in JavaScript
To help you get started with using Feature Upvote’s public REST API, here’s an example in Vanilla JavaScript you can copy and paste. It will list all of your feedback boards.
Make sure to add your own API key! It’s found here, in your Account profile.
// Base URL for the Feature Upvote API v1
const BASE_URL = 'https://api.featureupvote.com/api/v1';
// Replace this value with your actual Feature Upvote API key
const API_KEY = 'YOUR_API_KEY_HERE';
/**
* Fetches boards from the Feature Upvote API.
*/
async function fetchBoardsList() {
// Construct the API endpoint for listing boards
const endpoint = `${BASE_URL}/boards`;
try {
// Perform standard network fetch with authorization headers
const response = await fetch(endpoint, {
method: 'GET',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
}
});
// Check for HTTP errors (e.g. 401 Unauthorized, 404 Not Found)
if (!response.ok) {
throw new Error(`HTTP Error: ${response.status} - ${response.statusText}`);
}
// Parse the JSON data stream
const boardsData = await response.json();
// Output the results
console.log(`Successfully retrieved ${boardsData.length} boards`);
console.log(boardsData);
} catch (error) {
console.error('Failed to communicate with Feature Upvote API:', error);
}
}
fetchBoardsList();