docs

git clone https://github.com/notamitgamer/docs.git
· rebuilt hourlyOpen on GitHub
root / osma / quickstart.mdx

quickstart.mdx (2510B)


      1 ---
      2 title: "Quick Start"
      3 ---
      4 
      5 import Copyright from "/snippets/copyright.mdx";
      6 
      7 OSMA has fully open CORS and requires no authentication keys, so you can start fetching package data immediately — from a backend script, a CLI tool, or directly inside a browser application.
      8 
      9 ## JavaScript (browser & Node.js)
     10 
     11 CORS is fully open (`Access-Control-Allow-Origin: *`), so you can use the native `fetch` API directly. This example queries the NPM snapshot for `react`:
     12 
     13 ```javascript
     14 async function getPackageVersion(query) {
     15   const url = `https://notamitgamer-osma-npm-api.hf.space/search?q=${encodeURIComponent(query)}&limit=1`;
     16 
     17   try {
     18     const response = await fetch(url);
     19     if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
     20 
     21     const data = await response.json();
     22     if (data.results && data.results.length > 0) {
     23       const pkg = data.results[0];
     24       console.log(`${pkg.name} | Version: ${pkg.version} | Rank: ${pkg.rank}`);
     25       console.log(`Registry Link: ${pkg.url}`);
     26     } else {
     27       console.log("Package not found in the April 2026 snapshot.");
     28     }
     29   } catch (error) {
     30     console.error("Failed to fetch OSMA data:", error);
     31   }
     32 }
     33 
     34 getPackageVersion("react");
     35 ```
     36 
     37 ## Python
     38 
     39 For Python apps, tools, or data analysis scripts, `requests` makes querying the PyPI snapshot simple:
     40 
     41 ```python
     42 import requests
     43 
     44 def get_package_version(query):
     45     url = f"https://notamitgamer-osma-pypi-api.hf.space/search?q={query}&limit=1"
     46     try:
     47         response = requests.get(url)
     48         response.raise_for_status()
     49         data = response.json()
     50 
     51         if data.get("results"):
     52             pkg = data["results"][0]
     53             print(f"{pkg['name']} | Version: {pkg['version']} | Rank: {pkg['rank']}")
     54             print(f"Registry Link: {pkg['url']}")
     55         else:
     56             print("Package not found in the April 2026 snapshot.")
     57 
     58     except requests.exceptions.RequestException as e:
     59         print(f"Failed to fetch OSMA data: {e}")
     60 
     61 if __name__ == "__main__":
     62     get_package_version("requests")
     63 ```
     64 
     65 ## Command line (cURL)
     66 
     67 Fastest way to test an endpoint from your terminal:
     68 
     69 ```bash
     70 curl -s "https://notamitgamer-osma-npm-api.hf.space/search?q=express&limit=3" | jq
     71 ```
     72 
     73 <Info>
     74 **Rate limits apply**
     75 
     76 These endpoints are subject to the standard free-tier rate limits (10 requests/minute, 100/hour). If you're writing a script that loops through hundreds of packages, you'll need an `X-Bypass-Token` — see [Utility Endpoints](/osma/utility).
     77 </Info>
     78 
     79 <Copyright />