Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.

Commit 3887980

Browse files
committed
Update README.md
1 parent bcae68d commit 3887980

File tree

3 files changed

+140
-62
lines changed

3 files changed

+140
-62
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
path: '.'
3737

3838
build:
39-
name: Build & Publish
39+
name: Build
4040
runs-on: ubuntu-latest
4141
needs: test
4242
steps:

README.md

Lines changed: 138 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,187 @@
11
# PyDepsDev
22

3-
A Python library for interacting with the Deps.dev API. Easily fetch package, version, and project data from the API.
3+
A Python library for interacting with Open Source Insights API (deps.dev).
4+
Easily fetch package, version, project, advisory, container, and PURL data—and leverage automatic name normalization and hash encoding.
45

56
## Table of Contents
6-
- [Installation](#installation)
7-
- [Usage](#usage)
8-
- [Initialization](#initialization)
9-
- [Fetching Data](#fetching-data)
10-
- [Contributing](#contributing)
11-
- [License](#license)
127

13-
## Installation
8+
- [Installation](#installation)
9+
- [Quick Start](#quick-start)
10+
- [Name Normalization & Hash Encoding](#name-normalization--hash-encoding)
11+
- [Endpoints](#endpoints)
12+
- [Package & Version](#package--version)
13+
- [Batch Version Queries](#batch-version-queries)
14+
- [Requirements, Dependencies & Dependents](#requirements-dependencies--dependents)
15+
- [Capabilities & Similarly-Named](#capabilities--similarly-named)
16+
- [Project](#project)
17+
- [Advisories](#advisories)
18+
- [PURL Lookup](#purl-lookup)
19+
- [Container Images](#container-images)
20+
- [Contributing](#contributing)
21+
- [License](#license)
1422

15-
To install `pydepsdev`, simply run:
23+
## Installation
1624

1725
```bash
18-
pip3 install pydepsdev
26+
pip install pydepsdev
1927
```
2028

21-
## Usage
29+
## Quick Start
30+
31+
```python
32+
import asyncio
33+
from pydepsdev.api import DepsdevAPI
34+
35+
async def main():
36+
# Simple init
37+
api = DepsdevAPI()
38+
39+
# …use api methods…
2240

23-
### Initialization
41+
await api.close()
42+
43+
asyncio.run(main())
44+
```
2445

25-
Start by importing the library and initializing the main class:
46+
Or use as an async context manager:
2647

2748
```python
28-
from pydepsdev import DepsdevAPI
49+
import asyncio
50+
from pydepsdev.api import DepsdevAPI
2951

30-
api = DepsdevAPI()
52+
async def main():
53+
async with DepsdevAPI() as api:
54+
pkg_info = await api.get_package("npm", "foo")
55+
print(pkg_info)
56+
57+
asyncio.run(main())
3158
```
3259

33-
### Fetching Data
60+
## Name Normalization & Hash Encoding
61+
62+
- **System names** are case‐insensitive but always sent uppercase.
63+
- **NuGet** package names are lowercased.
64+
- **PyPI** package names are normalized per [PEP 503].
65+
- When you call `query_package_versions(hash_type, hash_value, …)`, your `hash_value` is automatically Base64‐encoded before sending.
66+
67+
## Endpoints
68+
69+
### Package & Version
3470

35-
The library provides methods that correspond to different endpoints in the Deps.dev API. Here's a breakdown of each method and how to use them:
71+
```python
72+
# Get basic package info + versions list
73+
await api.get_package(system_name: str, package_name: str)
74+
75+
# Get metadata for a specific version
76+
await api.get_version(system_name: str, package_name: str, version: str)
77+
```
3678

37-
1. **Get Package Information**
79+
### Batch Version Queries
3880

39-
Fetch package details including available versions.
81+
```python
82+
# One page (up to 5000) of versions
83+
await api.get_version_batch(
84+
[(system, pkg, ver), …],
85+
page_token: Optional[str] = None
86+
)
87+
88+
# Retrieve ALL pages for a batch
89+
await api.get_all_versions_batch(
90+
[(system, pkg, ver), …]
91+
)
92+
```
4093

41-
```python
42-
package_info = await api.get_package("system_name", "package_name")
43-
```
94+
### Requirements, Dependencies & Dependents
4495

45-
2. **Get Version Information**
96+
```python
97+
# NuGet only
98+
await api.get_requirements("NuGet", "package_name", "version")
4699

47-
Fetch detailed information about a specific package version.
100+
# Any supported system
101+
await api.get_dependencies(system_name, package_name, version)
48102

49-
```python
50-
version_info = await api.get_version("system_name", "package_name", "version_number")
51-
```
103+
# Dependent counts
104+
await api.get_dependents(system_name, package_name, version)
105+
```
52106

53-
3. **Get Requirements**
107+
### Capabilities & Similarly-Named
54108

55-
Return the requirements for a specific package version. (Note: Only available for NuGet.)
109+
```python
110+
# Go only
111+
await api.get_capabilities("Go", "module_path", "version")
56112

57-
```python
58-
requirements = await api.get_requirements("NuGet", "package_name", "version_number")
59-
```
113+
# Find similarly-named packages
114+
await api.get_similarly_named_packages(system_name, package_name)
115+
```
60116

61-
4. **Get Dependencies**
117+
### Query Package Versions
62118

63-
Fetch the resolved dependency graph for a specific package version.
119+
```python
120+
# By hash (hash.value is auto base64‐encoded)
121+
await api.query_package_versions(
122+
hash_type: str, # e.g. "SHA256"
123+
hash_value: str, # raw hex or bytes
124+
version_system: Optional[str] = None,
125+
version_name: Optional[str] = None,
126+
version: Optional[str] = None,
127+
)
128+
```
64129

65-
```python
66-
dependencies = await api.get_dependencies("system_name", "package_name", "version_number")
67-
```
130+
### Project
68131

69-
5. **Get Project Information**
132+
```python
133+
# Single project metadata
134+
await api.get_project(project_id: str)
70135

71-
Retrieve details about projects hosted by platforms like GitHub, GitLab, or BitBucket.
136+
# One page of project batch
137+
await api.get_project_batch(
138+
[project_id1, project_id2, …],
139+
page_token: Optional[str] = None
140+
)
72141

73-
```python
74-
project_info = await api.get_project("project_id")
75-
```
142+
# Retrieve all pages
143+
await api.get_all_projects_batch([…])
76144

77-
6. **Get Project Package Versions**
145+
# List package versions derived from a project
146+
await api.get_project_package_versions(project_id: str)
147+
```
78148

79-
Fetch the package versions created from a specified source code repository.
149+
### Advisories
80150

81-
```python
82-
project_package_versions = await api.get_project_package_versions("project_id")
83-
```
151+
```python
152+
# Fetch OSV advisory details
153+
await api.get_advisory(advisory_id: str)
154+
```
84155

85-
7. **Get Advisory Details**
156+
### PURL Lookup
86157

87-
Fetch information about a security advisory from OSV.
158+
```python
159+
# Single purl
160+
await api.get_purl_lookup(purl: str)
88161

89-
```python
90-
advisory_info = await api.get_advisory("advisory_id")
91-
```
162+
# One page of PURL batch
163+
await api.get_purl_lookup_batch(
164+
[purl1, purl2, …],
165+
page_token: Optional[str] = None
166+
)
92167

93-
8. **Query Package Versions**
168+
# Retrieve all pages
169+
await api.get_all_purl_lookup_batch([…])
170+
```
94171

95-
Query package versions based on content hash or version key.
172+
### Container Images
96173

97-
```python
98-
package_versions = await api.query_package_versions(hash_type="type", hash_value="value", version_system="system_name", version_name="name", version="version_number")
99-
```
174+
```python
175+
# Query container images by OCI chain ID
176+
await api.query_container_images(chain_id: str)
177+
```
100178

101-
Get more informating about the query parameters and response values on the [official API documentation](https://docs.deps.dev/api/v3alpha)
179+
For full details on parameters and response schemas, see the [Deps.dev API docs](https://docs.deps.dev/api/v3alpha).
102180

103181
## Contributing
104182

105-
We welcome contributions! If you find a bug or have suggestions, feel free to open an issue or submit a pull request.
183+
Contributions, issues and feature requests are welcome!
184+
Feel free to check [issues page](https://github.com/eclipseo/pydepsdev/issues) or submit a pull request.
106185

107186
## License
108-
109187
This project is licensed under the Apache Software License 2.0.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pydepsdev"
7-
version = "0.2.0"
7+
version = "0.2.1"
88
authors = [
99
{ name = "Robert-André Mauchin", email = "[email protected]" }
1010
]

0 commit comments

Comments
 (0)