|
| 1 | +# Devup API |
| 2 | + |
| 3 | +**A fully typed API client generator powered by OpenAPI. |
| 4 | +Fetch-compatible, auto-generated types, zero generics required.** |
| 5 | + |
| 6 | +Devup API reads your `openapi.json` file and automatically generates a fully typed client that behaves like an ergonomic, type-safe version of `fetch()`. |
| 7 | +No manual type declarations. No generics. No SDK boilerplate. |
| 8 | +Just write API calls — the types are already there. |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## ✨ Features |
| 13 | + |
| 14 | +### **🔍 OpenAPI-driven type generation** |
| 15 | +- Reads `openapi.json` and transforms every path, method, schema into typed API functions. |
| 16 | +- Parameters, request bodies, headers, responses — all typed automatically. |
| 17 | +- No need to write or maintain separate TypeScript definitions. |
| 18 | + |
| 19 | +### **🪝 Fetch-compatible design** |
| 20 | +Devup API feels like using `fetch`, but with superpowers: |
| 21 | + |
| 22 | +- Path params automatically replaced |
| 23 | +- Query/body/header types enforced |
| 24 | +- Typed success & error responses |
| 25 | +- Optional runtime schema validation |
| 26 | +- Minimal abstraction over standard fetch |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## 🚀 Quick Start |
| 31 | + |
| 32 | +### **1. Initialize the client** |
| 33 | + |
| 34 | +```ts |
| 35 | +import { devupApi } from "devup-api"; |
| 36 | + |
| 37 | +// create api instance |
| 38 | +const api = await devupApi("https://api.example.com"); |
| 39 | +``` |
| 40 | + |
| 41 | +### **2. Call endpoints — types are automatic** |
| 42 | + |
| 43 | +```ts |
| 44 | +const user = await api.get("/users/{id}", { |
| 45 | + params: { id: "123" }, |
| 46 | + headers: { |
| 47 | + Authorization: "Bearer TOKEN" |
| 48 | + } |
| 49 | +}); |
| 50 | + |
| 51 | +const user = await api.get("getUser", { |
| 52 | + params: { id: "123" }, |
| 53 | + headers: { |
| 54 | + Authorization: "Bearer TOKEN" |
| 55 | + } |
| 56 | +}); |
| 57 | +``` |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## 📦 Installation |
| 62 | + |
| 63 | +```bash |
| 64 | +npm install @devup-api/fetch |
| 65 | + |
| 66 | +npm install @devup-api/next-plugin |
| 67 | +npm install @devup-api/webpack-plugin |
| 68 | +npm install @devup-api/rsbuild-plugin |
| 69 | +npm install @devup-api/vite-plugin |
| 70 | +``` |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## 📚 API Usage |
| 75 | + |
| 76 | +### **GET Example** |
| 77 | + |
| 78 | +```ts |
| 79 | +await api.get("/posts", { |
| 80 | + query: { page: 1, limit: 20 } |
| 81 | +}); |
| 82 | +``` |
| 83 | + |
| 84 | +### **POST Example** |
| 85 | + |
| 86 | +```ts |
| 87 | +await api.post("/posts", { |
| 88 | + body: { |
| 89 | + title: "Hello World", |
| 90 | + content: "This is a typed API request." |
| 91 | + } |
| 92 | +}); |
| 93 | +``` |
| 94 | + |
| 95 | +### **Path Params Example** |
| 96 | + |
| 97 | +```ts |
| 98 | +await api.get("/posts/{id}", { |
| 99 | + params: { id: "777" } |
| 100 | +}); |
| 101 | +``` |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | +## ⚙️ How It Works |
| 106 | + |
| 107 | +1. Download `openapi.json` |
| 108 | +2. Extract paths, methods, schemas, parameters, bodies |
| 109 | +3. Generate TypeScript types automatically |
| 110 | +4. Build a typed wrapper around `fetch()` |
| 111 | +5. Expose methods based on the API structure |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +## 🎯 Why Devup API? |
| 116 | + |
| 117 | +- No code generators |
| 118 | +- No build steps |
| 119 | +- No boilerplate |
| 120 | +- Uses OpenAPI schema directly |
| 121 | +- Works in Next.js, Bun, Vite, rsbuild |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## 🛠️ Roadmap |
| 126 | + |
| 127 | +- [ ] Typescript interface generation |
| 128 | +- [ ] Zod schema generation |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +## 📄 License |
| 133 | + |
| 134 | +Apache 2.0 |
0 commit comments