🧩 ListPackagesByType
Fetches all package names of a given type, such as composer-plugin, library.
When to use
🧩 List all composer-plugin packages for plugin discovery; 🏗️ break down the ecosystem composition by type; 🔍 filter candidate packages in specialized tools (e.g. only project templates).
Signature
go
func (c *ComposerClient) ListPackagesByType(packageType string) (*domain.PackageListResponse, error)Parameters
| Parameter | Type | Description |
|---|---|---|
packageType | string | Package type, e.g. library, composer-plugin, project |
Return value
| Value | Type | Description |
|---|---|---|
| Result | *domain.PackageListResponse | PackageNames is the list of package names of that type |
| Error | error | Returned on HTTP failure, non-200 status, or JSON parse failure |
Corresponding endpoint: GET https://packagist.org/packages/list.json?type={type}. The SDK automatically URL-encodes packageType.
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.ListPackagesByType("composer-plugin")
if err != nil {
log.Fatal(err)
}
fmt.Printf("composer-plugin package count: %d\n", len(resp.PackageNames))
for _, name := range resp.PackageNames[:5] {
fmt.Println(" -", name)
}
}Advanced
- 🏢 To filter by vendor, use
ListPackagesByVendor. - 🔍 To search by type + keyword, use
SearchPackagesByType(search results include metrics such as download counts). - 📋 To get the full list of package names, use
ListPackages.