itunes

package
v1.260504.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package itunes provides a client for the iTunes Lookup API.

Index

Constants

This section is empty.

Variables

View Source
var CountryNames = map[string]string{}/* 115 elements not displayed */

CountryNames maps country codes with custom display-name handling. Public-only countries not listed here fall back to CLDR English names.

View Source
var Storefronts = map[string]string{}/* 115 elements not displayed */

Storefronts maps a subset of public App Store country codes to Apple storefront IDs. These IDs are required for the X-Apple-Store-Front header when fetching ratings histograms.

Functions

func AllCountries

func AllCountries() []string

AllCountries returns a sorted list of the histogram storefront countries.

func AllPublicCountries

func AllPublicCountries() []string

AllPublicCountries returns a sorted list of all public App Store country codes.

func NormalizeCountryCode

func NormalizeCountryCode(country string) (string, error)

NormalizeCountryCode validates and normalizes a storefront country code.

Types

type App

type App struct {
	AppID                int64    `json:"appId"`
	Name                 string   `json:"name"`
	BundleID             string   `json:"bundleId"`
	Country              string   `json:"country,omitempty"`
	CountryName          string   `json:"countryName,omitempty"`
	URL                  string   `json:"url"`
	ArtworkURL           string   `json:"artworkUrl"`
	SellerName           string   `json:"sellerName"`
	PrimaryGenreName     string   `json:"primaryGenreName"`
	Genres               []string `json:"genres,omitempty"`
	Version              string   `json:"version"`
	Description          string   `json:"description"`
	Price                float64  `json:"price"`
	FormattedPrice       string   `json:"formattedPrice"`
	Currency             string   `json:"currency"`
	AverageRating        float64  `json:"averageRating"`
	RatingCount          int64    `json:"ratingCount"`
	CurrentVersionRating float64  `json:"currentVersionRating"`
	CurrentVersionCount  int64    `json:"currentVersionCount"`
}

App contains public App Store storefront metadata for a single app.

type AppRatings

type AppRatings struct {
	AppID                int64         `json:"appId"`
	AppName              string        `json:"appName"`
	Country              string        `json:"country"`
	CountryName          string        `json:"countryName,omitempty"`
	AverageRating        float64       `json:"averageRating"`
	RatingCount          int64         `json:"ratingCount"`
	CurrentVersionRating float64       `json:"currentVersionRating,omitempty"`
	CurrentVersionCount  int64         `json:"currentVersionCount,omitempty"`
	Histogram            map[int]int64 `json:"histogram,omitempty"`
}

AppRatings contains rating statistics for an app in a single country.

type Client

type Client struct {
	HTTPClient *http.Client
	BaseURL    string
}

Client is an iTunes public API client.

func NewClient

func NewClient() *Client

NewClient creates a new iTunes API client.

func (*Client) GetAllRatings

func (c *Client) GetAllRatings(ctx context.Context, appID string, workers int) (*GlobalRatings, error)

GetAllRatings fetches rating statistics for an app across all supported countries.

func (*Client) GetRatings

func (c *Client) GetRatings(ctx context.Context, appID, country string) (*AppRatings, error)

GetRatings fetches rating statistics for an app in a specific country.

func (*Client) LookupApp

func (c *Client) LookupApp(ctx context.Context, appID string, opts LookupOptions) (*App, error)

LookupApp fetches public App Store metadata for a single app ID.

func (*Client) LookupApps

func (c *Client) LookupApps(ctx context.Context, ids []string, opts LookupOptions) (map[string]App, error)

LookupApps fetches public App Store metadata for one or more app IDs.

func (*Client) SearchApps

func (c *Client) SearchApps(ctx context.Context, term, country string, limit int) ([]SearchResult, error)

SearchApps searches the public App Store in a single storefront.

type GlobalRatings

type GlobalRatings struct {
	AppID         int64         `json:"appId"`
	AppName       string        `json:"appName"`
	AverageRating float64       `json:"averageRating"`
	TotalCount    int64         `json:"totalCount"`
	CountryCount  int           `json:"countryCount"`
	Histogram     map[int]int64 `json:"histogram,omitempty"`
	ByCountry     []AppRatings  `json:"byCountry"`
}

GlobalRatings contains aggregated rating statistics across all countries.

type LookupOptions

type LookupOptions struct {
	Country               string
	IncludeSoftwareEntity bool
}

LookupOptions controls /lookup behavior.

type SearchResult

type SearchResult struct {
	AppID            int64   `json:"appId"`
	Name             string  `json:"name"`
	BundleID         string  `json:"bundleId"`
	SellerName       string  `json:"sellerName"`
	Country          string  `json:"country"`
	CountryName      string  `json:"countryName,omitempty"`
	URL              string  `json:"url"`
	ArtworkURL       string  `json:"artworkUrl"`
	PrimaryGenreName string  `json:"primaryGenreName"`
	FormattedPrice   string  `json:"formattedPrice"`
	Currency         string  `json:"currency"`
	AverageRating    float64 `json:"averageRating"`
	RatingCount      int64   `json:"ratingCount"`
}

SearchResult contains public App Store search data for a single app result.

type Storefront

type Storefront struct {
	Country      string `json:"country"`
	CountryName  string `json:"countryName"`
	StorefrontID string `json:"storefrontId"`
}

Storefront contains public storefront metadata for a single country.

func ListStorefronts

func ListStorefronts() []Storefront

ListStorefronts returns storefront metadata in deterministic country order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL