|
| 1 | +# Technology Reports API (Node.js) |
| 2 | + |
| 3 | +This is a unified Google Cloud Run function that provides technology metrics and information via various endpoints. |
| 4 | + |
| 5 | +## Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Node.js 18+ |
| 10 | +- npm |
| 11 | +- Google Cloud account with necessary permissions |
| 12 | + |
| 13 | +### Local Development |
| 14 | + |
| 15 | +1. Install dependencies: |
| 16 | +```bash |
| 17 | +npm install |
| 18 | +``` |
| 19 | + |
| 20 | +2. Set environment variables: |
| 21 | +```bash |
| 22 | +export PROJECT=your-gcp-project-id |
| 23 | +export DATABASE=your-firestore-database |
| 24 | +``` |
| 25 | + |
| 26 | +3. Run the application locally: |
| 27 | +```bash |
| 28 | +npm start |
| 29 | +``` |
| 30 | + |
| 31 | +The API will be available at http://localhost:8080 |
| 32 | + |
| 33 | +## Deployment |
| 34 | + |
| 35 | +### Using Google Cloud Build |
| 36 | + |
| 37 | +```bash |
| 38 | +gcloud builds submit --tag gcr.io/PROJECT_ID/tech-report-api |
| 39 | +gcloud run deploy tech-report-api --image gcr.io/PROJECT_ID/tech-report-api --platform managed |
| 40 | +``` |
| 41 | + |
| 42 | +## API Endpoints |
| 43 | + |
| 44 | +### `GET /technologies` |
| 45 | + |
| 46 | +Lists available technologies with optional filtering. |
| 47 | + |
| 48 | +#### Parameters |
| 49 | + |
| 50 | +- `technology` (optional): Filter by technology name(s) - comma-separated list |
| 51 | +- `category` (optional): Filter by category - comma-separated list |
| 52 | +- `onlyname` (optional): If present, returns only technology names |
| 53 | + |
| 54 | +### `GET /categories` |
| 55 | + |
| 56 | +Lists available categories. |
| 57 | + |
| 58 | +#### Parameters |
| 59 | + |
| 60 | +- `category` (optional): Filter by category name(s) - comma-separated list |
| 61 | +- `onlyname` (optional): If present, returns only category names |
| 62 | + |
| 63 | +### `GET /adoption` |
| 64 | + |
| 65 | +Provides technology adoption data. |
| 66 | + |
| 67 | +#### Parameters |
| 68 | + |
| 69 | +- `technology` (required): Filter by technology name(s) - comma-separated list |
| 70 | +- `start` (optional): Filter by date range start (YYYY-MM-DD or 'latest') |
| 71 | +- `end` (optional): Filter by date range end (YYYY-MM-DD) |
| 72 | +- `geo` (optional): Filter by geographic location |
| 73 | +- `rank` (optional): Filter by rank |
| 74 | + |
| 75 | +### `GET /cwvtech` (Core Web Vitals) |
| 76 | + |
| 77 | +Provides Core Web Vitals metrics for technologies. |
| 78 | + |
| 79 | +#### Parameters |
| 80 | + |
| 81 | +- `technology` (required): Filter by technology name(s) - comma-separated list |
| 82 | +- `geo` (required): Filter by geographic location |
| 83 | +- `rank` (required): Filter by rank |
| 84 | +- `start` (optional): Filter by date range start (YYYY-MM-DD or 'latest') |
| 85 | +- `end` (optional): Filter by date range end (YYYY-MM-DD) |
| 86 | + |
| 87 | +### `GET /lighthouse` |
| 88 | + |
| 89 | +Provides Lighthouse scores for technologies. |
| 90 | + |
| 91 | +#### Parameters |
| 92 | + |
| 93 | +- `technology` (required): Filter by technology name(s) - comma-separated list |
| 94 | +- `geo` (required): Filter by geographic location |
| 95 | +- `rank` (required): Filter by rank |
| 96 | +- `start` (optional): Filter by date range start (YYYY-MM-DD or 'latest') |
| 97 | +- `end` (optional): Filter by date range end (YYYY-MM-DD) |
| 98 | + |
| 99 | +### `GET /page-weight` |
| 100 | + |
| 101 | +Provides Page Weight metrics for technologies. |
| 102 | + |
| 103 | +#### Parameters |
| 104 | + |
| 105 | +- `technology` (required): Filter by technology name(s) - comma-separated list |
| 106 | +- `geo` (optional): Filter by geographic location |
| 107 | +- `rank` (optional): Filter by rank |
| 108 | +- `start` (optional): Filter by date range start (YYYY-MM-DD or 'latest') |
| 109 | +- `end` (optional): Filter by date range end (YYYY-MM-DD) |
| 110 | + |
| 111 | +### `GET /ranks` |
| 112 | + |
| 113 | +Lists all available ranks. |
| 114 | + |
| 115 | +### `GET /geos` |
| 116 | + |
| 117 | +Lists all available geographic locations. |
| 118 | + |
| 119 | +## Response Format |
| 120 | + |
| 121 | +All API responses follow this format: |
| 122 | + |
| 123 | +```json |
| 124 | +{ |
| 125 | + "success": true, |
| 126 | + "result": [ |
| 127 | + // Array of data objects |
| 128 | + ] |
| 129 | +} |
| 130 | +``` |
| 131 | + |
| 132 | +Or in case of an error: |
| 133 | + |
| 134 | +```json |
| 135 | +{ |
| 136 | + "success": false, |
| 137 | + "errors": [ |
| 138 | + {"key": "error message"} |
| 139 | + ] |
| 140 | +} |
| 141 | +``` |
0 commit comments