
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
A comprehensive API toolkit for various services including YouTube, Spotify, Valorant, DeepSeek, and ChatGPT.
A comprehensive API toolkit for various services including YouTube, Spotify, Valorant, DeepSeek, and ChatGPT.
npm install macro_api
or
yarn add macro_api
Monitor a YouTube channel for new videos and send notifications to Discord:
import { YouTubeNotify } from 'macro_api';
// Create a new YouTube notification monitor
const ytNotifier = new YouTubeNotify({
channelId: 'UC_x5XG1OV2P6uZZ5FSM9Ttw', // Google Developers channel
apiKey: 'YOUR_YOUTUBE_API_KEY',
checkIntervalMs: 600000 // 10 minutes
});
// Set up Discord webhook
ytNotifier.setWebhook('https://discord.com/api/webhooks/your-webhook-url');
// Start monitoring
ytNotifier.startMonitoring();
// To stop monitoring
// ytNotifier.stopMonitoring();
// To manually check for new videos
const newVideos = await ytNotifier.manualCheck();
console.log(`Found ${newVideos.length} new videos`);
Interact with Spotify API to get tracks, create playlists, and more:
import { SpotifyAPI } from 'macro_api';
// Create a new Spotify API client
const spotify = new SpotifyAPI({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
redirectUri: 'YOUR_REDIRECT_URI'
});
// Get authorization URL
const authUrl = spotify.getAuthorizationUrl([
'user-read-private',
'playlist-modify-public'
]);
console.log(`Please authorize the app: ${authUrl}`);
// Exchange authorization code for access token
await spotify.exchangeCode('AUTHORIZATION_CODE');
// Get the current user
const user = await spotify.getCurrentUser();
console.log(`Logged in as: ${user.display_name}`);
// Search for tracks
const searchResults = await spotify.search('Metallica', ['track'], { limit: 5 });
// Create a playlist and add tracks
const playlist = await spotify.createPlaylist(user.id, 'Awesome Playlist', true, 'Created with macro_api');
await spotify.addTracksToPlaylist(
playlist.id,
searchResults.tracks.items.map((track: any) => track.uri)
);
Get player statistics and information from Valorant:
import { Valorant } from 'macro_api';
// Create a new Valorant API client
const valorant = new Valorant();
// Get player account details
const account = await valorant.getAccount('Username', 'Tag');
console.log(`Player ID: ${account.puuid}`);
// Get player MMR details
const mmr = await valorant.getMMR('Username', 'Tag');
console.log(`Current Rank: ${mmr.currenttierpatched}`);
// Get player's match history
const matches = await valorant.getMatchHistory('na', 'Username', 'Tag', { queue: 'competitive' });
console.log(`Last ${matches.length} matches:`);
// Get player's comprehensive stats
const stats = await valorant.getPlayerStats('na', 'Username', 'Tag');
console.log(`Win Rate: ${stats.overview.winRate}`);
console.log(`K/D Ratio: ${stats.combat.kd}`);
console.log(`Favorite Agent: ${stats.favorites.agents[0]?.agent}`);
Interact with DeepSeek AI models:
import { DeepSeek } from 'macro_api';
// Create a new DeepSeek API client
const deepseek = new DeepSeek({
apiKey: 'YOUR_DEEPSEEK_API_KEY'
});
// Simple chat with DeepSeek
const response = await deepseek.chat(
'What are the main differences between TypeScript and JavaScript?',
'You are a helpful programming assistant'
);
console.log(response);
// Generate code with DeepSeek
const code = await deepseek.generateCode(
'Write a function to calculate the Fibonacci sequence'
);
console.log(code.choices[0]?.text);
// Full conversation
const conversation = await deepseek.conversation([
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is the capital of France?' },
{ role: 'assistant', content: 'The capital of France is Paris.' },
{ role: 'user', content: 'And what is the population of Paris?' }
]);
console.log(conversation);
Interact with OpenAI's models:
import { ChatGPT } from 'macro_api';
// Create a new ChatGPT API client
const chatgpt = new ChatGPT({
apiKey: 'YOUR_OPENAI_API_KEY'
});
// Simple chat with ChatGPT
const response = await chatgpt.chat(
'Explain the concept of quantum computing in simple terms',
'You are a helpful assistant that explains complex topics in simple language'
);
console.log(response);
// Using function calling
const functionCall = await chatgpt.withFunctions(
'What is the weather like in Berlin today?',
[
{
name: 'get_weather',
description: 'Get the current weather in a location',
parameters: {
type: 'object',
properties: {
location: {
type: 'string',
description: 'The city and state, e.g., San Francisco, CA'
}
},
required: ['location']
}
}
]
);
console.log(functionCall);
// Generate embeddings
const embeddings = await chatgpt.embed('Hello world');
console.log(`Embedding dimension: ${embeddings[0].embedding.length}`);
The YouTube notification system monitors YouTube channels for new videos and sends notifications via Discord webhooks.
new YouTubeNotify(options: {
channelId: string; // YouTube channel ID to monitor
apiKey: string; // YouTube Data API key
checkIntervalMs?: number; // Check interval in milliseconds (default: 600000 - 10 minutes)
maxResults?: number; // Maximum number of videos to fetch (default: 5)
includeDescription?: boolean; // Include video description in notifications (default: false)
mentionEveryone?: boolean; // Mention @everyone in notifications (default: false)
})
setWebhook(url: string)
: Set the Discord webhook URL for notificationsstartMonitoring()
: Start monitoring the channel for new videosstopMonitoring()
: Stop monitoring the channelmanualCheck()
: Manually check for new videos and return any foundComplete wrapper for the Spotify API to interact with all endpoints.
new SpotifyAPI(options: {
clientId: string; // Spotify API client ID
clientSecret: string; // Spotify API client secret
redirectUri?: string; // OAuth redirect URI (required for authorization)
})
getAuthorizationUrl(scopes: string[], state?: string)
: Get the authorization URL for OAuth loginexchangeCode(code: string)
: Exchange authorization code for access tokensetAccessToken(token: string, expiresIn: number, refreshToken?: string)
: Set access token manuallyrefreshAccessToken()
: Refresh the access token using the refresh tokengetCurrentUser()
, getUser(userId: string)
getTrack(trackId: string)
, getTracks(trackIds: string[])
getAlbum(albumId: string)
, getAlbumTracks(albumId: string, params?)
getArtist(artistId: string)
, getArtistAlbums(artistId: string, params?)
, getArtistTopTracks(artistId: string, market?)
getPlaylist(playlistId: string)
, getPlaylistTracks(playlistId: string, params?)
, createPlaylist(userId: string, name: string, isPublic?, description?)
, addTracksToPlaylist(playlistId: string, trackUris: string[], position?)
getCurrentlyPlaying()
, getPlaybackState()
, controlPlayback(action: 'play' | 'pause' | 'next' | 'previous', deviceId?)
search(query: string, types: Array<'album' | 'artist' | 'playlist' | 'track'>, params?)
getRecommendations(params)
API client for retrieving Valorant player statistics and game data.
new Valorant(apiKey?: string) // Optional API key for Henrik's Valorant API
getAccount(name: string, tag: string)
getMMR(name: string, tag: string, options?: { region?: string })
getMatchHistory(region: string, name: string, tag: string, options?)
getLifetimeStats(region: string, name: string, tag: string)
, getPlayerStats(region: string, name: string, tag: string, mode?)
getMatch(matchId: string)
getLeaderboard(options: { region: string, size?: number, startIndex?: number })
getAgents(language?)
, getWeapons(language?)
, getMaps(language?)
, getStatus(region?)
Client for interacting with DeepSeek's AI models.
new DeepSeek(config: {
apiKey: string; // DeepSeek API key
baseUrl?: string; // API base URL (default: 'https://api.deepseek.com/v1')
})
createChatCompletion(options)
, createStreamingChatCompletion(options, onData, onError?, onEnd?)
createCompletion(options)
createEmbeddings(options)
chat(prompt, systemPrompt?, model?)
, conversation(messages, model?)
, generateCode(prompt, options?)
listModels()
Client for interacting with OpenAI's models.
new ChatGPT(config: {
apiKey: string; // OpenAI API key
organizationId?: string; // OpenAI organization ID
baseUrl?: string; // API base URL (default: 'https://api.openai.com/v1')
})
createChatCompletion(options)
, createStreamingChatCompletion(options, onData, onError?, onEnd?)
createEmbeddings(options)
, embed(text, model?)
chat(prompt, systemPrompt?, model?)
, conversation(messages, model?)
, withFunctions(prompt, functions, model?)
, withTools(prompt, tools, model?)
listModels()
Apache License 2.0. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
A comprehensive, production-ready API toolkit for various services including Stripe, Slack, SendGrid, Vercel, AWS S3, Docker Hub, and more.
The npm package macro_api receives a total of 102 weekly downloads. As such, macro_api popularity was classified as not popular.
We found that macro_api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.