📋 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
| Value | Type | Description |
|---|---|---|
| Result | *domain.PackageListResponse | PackageNames is a []string of package names |
| Error | error | Returned 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.
- 🏢 To filter by vendor, use
ListPackagesByVendor. - 🧩 To filter by type, use
ListPackagesByType. - 📦 To also get fields such as repository / type, use
ListPackagesWithData.