Skip to content

📋 ListPackages

Fetches the list of all package names on Packagist.

When to use

📋 Build a local package name index or search engine; 🛠️ initialize the full list for a self-hosted mirror; 🔍 combine with GetPackage to batch-pull details.

Signature

go
func (c *ComposerClient) ListPackages() (*domain.PackageListResponse, error)

Parameters

This method takes no parameters.

Return value

ValueTypeDescription
Result*domain.PackageListResponsePackageNames is a []string of package names
ErrorerrorReturned on HTTP failure, non-200 status, or JSON parse failure

Corresponding endpoint: GET https://packagist.org/packages/list.json.

Example

go
package main

import (
	"fmt"
	"log"
	"time"

	"github.com/scagogogo/composer-skills/pkg/client"
)

func main() {
	c := client.NewComposerClient(30 * time.Second)

	resp, err := c.ListPackages()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Total packages: %d\n", len(resp.PackageNames))
	for _, name := range resp.PackageNames[:3] {
		fmt.Println("  -", name)
	}
}

Advanced

Data volume

This endpoint returns the full set of package names (hundreds of thousands of entries), so the response body is large. If you need to filter, prefer the more targeted variants below instead of pulling the full list and filtering locally.

Released under the MIT License