Skip to main content
Glama

ratings

Retrieve app ratings distribution data from app stores to analyze user feedback patterns and performance metrics.

Instructions

Get app ratings distribution

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNoiTunes trackId of the app
appIdNoBundle ID of the app
countryNoTwo-letter country code (default: us)us

Implementation Reference

  • The handler function that executes the 'ratings' tool logic: fetches app data via App Store API, parses it, extracts ratings using parseRatings helper, and returns JSON response.
    /** * Ratings tool - Get app ratings distribution */ async function handleRatings(args) { try { const { id, appId, country = 'us' } = args; if (!id && !appId) { throw new Error('Either id or appId must be provided'); } const url = buildRatingsUrl({ id, appId, country }); const data = await fetchJSON(url); const app = parseApp(data); if (!app) { return { content: [ { type: 'text', text: JSON.stringify({ error: 'App not found' }, null, 2), }, ], }; } const ratings = parseRatings(app); return { content: [ { type: 'text', text: JSON.stringify(ratings, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: JSON.stringify({ error: error.message }, null, 2), }, ], isError: true, }; } }
  • Input schema definition for the 'ratings' tool, defining parameters: id (number), appId (string), country (string, default 'us'). Provided in ListTools response.
    name: 'ratings', description: 'Get app ratings distribution', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'iTunes trackId of the app', }, appId: { type: 'string', description: 'Bundle ID of the app', }, country: { type: 'string', description: 'Two-letter country code (default: us)', default: 'us', }, }, }, },
  • Registration of the 'ratings' tool handler in the CallToolRequestSchema switch statement, mapping tool name to handleRatings function.
    case 'ratings': return await handleRatings(args);
  • Helper function to parse ratings data from app object, extracting count and average (histogram unavailable from API, defaults to zeros).
    export function parseRatings(appData) { if (!appData || !appData.rating) { return { ratings: 0, histogram: { '1': 0, '2': 0, '3': 0, '4': 0, '5': 0, }, }; } // iTunes API doesn't provide histogram directly // We can only return the average and count // For histogram, we'd need to scrape the web page, which is more complex // For now, return what we have return { ratings: appData.rating.count || 0, average: appData.rating.average || null, histogram: { '1': 0, // Not available from API '2': 0, '3': 0, '4': 0, '5': 0, }, }; }
  • Helper function to build the API URL for ratings data (reuses the app detail endpoint).
    export function buildRatingsUrl(params) { return buildAppUrl(params); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MiguelAlvRed/mobile-store-scraper-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server