Skip to content

Commit 21f9faa

Browse files
committed
Fix Grafana test and more details on RapidAPI hosted option
1 parent a7759a6 commit 21f9faa

File tree

2 files changed

+119
-7
lines changed

2 files changed

+119
-7
lines changed

docs/api.md

+117-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
## `lastversion` public API
22

33
You don't need to use `lastversion` as a command line tool or install it as a
4-
package to use it. You can use the public web API at `lastversion-api.getpagespeed.com`.
4+
package to use it.
55

6-
### Usage
6+
You can consume `lastversion` functionality through **two** API offerings:
77

8-
Make a GET request to `https://lastversion-api.getpagespeed.com/<github-repo>` to get the latest version of the repository in JSON format.
8+
1. **Free Public API** at `lastversion-api.getpagespeed.com`
9+
2. **Production-Ready Commercial API** on [RapidAPI](https://rapidapi.com/ciapnz/api/lastversion)
10+
11+
### 1. Public API (Limited, Best for Small Usage)
12+
13+
**Free API has Limited SLA and Rate Limits:** It’s free, so heavier usage or production traffic may see performance
14+
or reliability constraints. For use in automated workflows, we highly recommend the commercial API below.
15+
16+
For casual or small usage scenarios, you can directly query this free public endpoint:
17+
18+
https://lastversion-api.getpagespeed.com/<github-repo>
19+
20+
Make a GET request to the endpoint to get the latest version of the repository in JSON format.
921

1022
To get only the version number, append `?version` to the URL.
1123

@@ -21,12 +33,10 @@ GitHub repo that points to:
2133

2234
https://lastversion-api.getpagespeed.com/hooks/github
2335

24-
## Badges with the latest version
36+
#### Badges with the latest version
2537

2638
You can use the following badges in your project's `README.md` to show the latest version of your project:
2739

28-
### For GitHub projects
29-
3040
```markdown
3141
![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Flastversion-api.getpagespeed.com%2Fdvershinin%2Flastversion&query=version&label=Release)
3242
```
@@ -44,3 +54,104 @@ Alternatively, head to [Shields.io dynamic page configurator](https://shields.io
4454
* Set label to `Release` or whatever you want, and set other settings as desired.
4555

4656
Click `Execute` to verify results and copy Markdown or desired format.
57+
58+
### 2. Production-Ready Commercial API on RapidAPI
59+
60+
Subscribe to the commercial API on RapidAPI for higher rate limits, guaranteed performance, or advanced features:
61+
- [LastVersion API on RapidAPI](https://rapidapi.com/ciapnz/api/lastversion)
62+
63+
For **production** use, higher rate limits, guaranteed performance, or advanced features, check out our hosted API on RapidAPI:
64+
- Flexible Endpoints: Fetch just the `version`, list of `assets`, or full release details via different routes.
65+
- Scalable Billing Plans: **Start free**, upgrade as your usage grows.
66+
67+
**Why RapidAPI?**
68+
- Easier Integration: The platform handles billing, usage metrics, and rate limiting in a clear manner.
69+
- Global Infrastructure: Your requests route quickly from anywhere in the world.
70+
- Stable for Production: More robust than the free endpoint, guaranteed uptime, and no 2-hour forced cache if you need fresh data.
71+
72+
Secure your requests with API Keys provided by RapidAPI.
73+
74+
* Header Name: `X-RapidAPI-Key`
75+
* Required: Yes
76+
77+
📌 **Endpoints**
78+
79+
* `/version?project=project_id` returns only the version string, corresponding to the latest release
80+
* `/source?project=project_id` returns URL to download source tarball corresponding to the latest release
81+
* `/release?project=project_id` returns various information about the latest release with mandatory `version` field
82+
* `/assets?project=project_id` returns URLs corresponding to downloadable executable or other assets for the latest release
83+
84+
The `project_id` can be a single identifier like `linux` or `nginx` or a GitHub repository name, or you can even supply a URL where a project is hosted.
85+
86+
**Example Requests**:
87+
88+
Fetch Nginx Latest Version (GET):
89+
90+
```
91+
curl -X GET "https://lastversion.p.rapidapi.com/release?project=nginx" \
92+
-H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
93+
-H "X-RapidAPI-Host: lastversion.p.rapidapi.com"
94+
```
95+
96+
Response:
97+
98+
```
99+
{
100+
"version": "1.27.3",
101+
"type": "release",
102+
...
103+
}
104+
```
105+
106+
If you want to get just the version, use the `/version` endpoint URL.
107+
108+
109+
Fetch Linux Latest Version (GET) with Version Only:
110+
111+
```
112+
curl -X GET "https://lastversion.p.rapidapi.com/version?project=torvalds/linux" \
113+
-H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
114+
-H "X-RapidAPI-Host: lastversion.p.rapidapi.com"
115+
```
116+
117+
Response: `6.12`
118+
119+
Every endpoint supports `major` parameter, allowing you to answer questions like:
120+
121+
&gt; What was the last 4.x Linux version?
122+
123+
```
124+
curl -X GET "https://lastversion.p.rapidapi.com/version?project=torvalds/linux&major=4" \
125+
-H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
126+
-H "X-RapidAPI-Host: lastversion.p.rapidapi.com"
127+
```
128+
129+
Response: `4.20`
130+
131+
Fetch the latest release data of WordPress:
132+
133+
```
134+
curl -X GET "https://lastversion.p.rapidapi.com/release?project=WordPress/WordPress" \
135+
-H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
136+
-H "X-RapidAPI-Host: lastversion.p.rapidapi.com"
137+
```
138+
139+
Response will include `version:` field as well as a lot of other useful information about the latest release.
140+
141+
Fetch downoad URL of latest WordPress:
142+
143+
```
144+
curl -X GET "https://lastversion.p.rapidapi.com/source?project=WordPress/WordPress" \
145+
-H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
146+
-H "X-RapidAPI-Host: lastversion.p.rapidapi.com"
147+
```
148+
149+
Response: `https://github.com/WordPress/WordPress/archive/6.7.1/WordPress-6.7.1.tar.gz`
150+
151+
The creative and useful application of this API is in fact unlimited, when you pair it with external tools like `curl` or `wget`.
152+
153+
For example, download the latest WordPress release:
154+
155+
```bash
156+
wget $(curl -X GET "https://lastversion.p.rapidapi.com/source?project=WordPress/WordPress" -H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" -H "X-RapidAPI-Host: lastversion.p.rapidapi.com")
157+
```

tests/test_lastversion.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test lastversion."""
2+
23
import os
34

45
import subprocess
@@ -102,7 +103,7 @@ def test_grafana():
102103
"""Test Grafana at GitHub."""
103104
repo = "grafana/grafana"
104105

105-
output = latest(repo)
106+
output = latest(repo, exclude="lib")
106107

107108
assert output >= version.parse("6.2.2")
108109

0 commit comments

Comments
 (0)