Skip to main content
Glama

mcp-appstore

by appreply-co
common.js2.87 kB
'use strict'; const request = require('request'); const debug = require('debug')('app-store-scraper'); const c = require('./constants'); function cleanApp (app) { return { id: app.trackId, appId: app.bundleId, title: app.trackName, url: app.trackViewUrl, description: app.description, icon: app.artworkUrl512 || app.artworkUrl100 || app.artworkUrl60, genres: app.genres, genreIds: app.genreIds, primaryGenre: app.primaryGenreName, primaryGenreId: app.primaryGenreId, contentRating: app.contentAdvisoryRating, languages: app.languageCodesISO2A, size: app.fileSizeBytes, requiredOsVersion: app.minimumOsVersion, released: app.releaseDate, updated: app.currentVersionReleaseDate || app.releaseDate, releaseNotes: app.releaseNotes, version: app.version, price: app.price, currency: app.currency, free: app.price === 0, developerId: app.artistId, developer: app.artistName, developerUrl: app.artistViewUrl, developerWebsite: app.sellerUrl, score: app.averageUserRating, reviews: app.userRatingCount, currentVersionScore: app.averageUserRatingForCurrentVersion, currentVersionReviews: app.userRatingCountForCurrentVersion, screenshots: app.screenshotUrls, ipadScreenshots: app.ipadScreenshotUrls, appletvScreenshots: app.appletvScreenshotUrls, supportedDevices: app.supportedDevices }; } // TODO add an optional parse function const doRequest = (url, headers, requestOptions) => new Promise(function (resolve, reject) { debug('Making request: %s %j %o', url, headers, requestOptions); requestOptions = Object.assign({ method: 'GET' }, requestOptions); request(Object.assign({ url, headers }, requestOptions), (error, response, body) => { if (error) { debug('Request error', error); return reject(error); } if (response.statusCode >= 400) { return reject({ response }); } debug('Finished request'); resolve(body); }); }); const LOOKUP_URL = 'https://itunes.apple.com/lookup'; function lookup (ids, idField, country, lang, requestOptions) { idField = idField || 'id'; country = country || 'us'; const langParam = lang ? `&lang=${lang}` : ''; const joinedIds = ids.join(','); const url = `${LOOKUP_URL}?${idField}=${joinedIds}&country=${country}&entity=software${langParam}`; return doRequest(url, {}, requestOptions) .then(JSON.parse) .then((res) => res.results.filter(function (app) { return typeof app.wrapperType === 'undefined' || app.wrapperType === 'software'; })) .then((res) => res.map(cleanApp)); } function storeId (countryCode) { const markets = c.markets; const defaultStore = '143441'; return (countryCode && markets[countryCode.toUpperCase()]) || defaultStore; } module.exports = { cleanApp, lookup, request: doRequest, storeId };

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/appreply-co/mcp-appstore'

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