api-hub-client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,180 @@
1
+ <h1 align="center">api-hub-client</h1>
2
+
3
+ <p align="center">
4
+ <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"/>
5
+ <img src="https://img.shields.io/badge/npm-v1.0.0-blue.svg" alt="npm version"/>
6
+ <img src="https://img.shields.io/badge/build-passing-brightgreen.svg" alt="build status"/>
7
+ <img src="https://img.shields.io/badge/coverage-95%25-yellow.svg" alt="coverage"/>
8
+
9
+ </p>
10
+
11
+ <p align="center">
12
+ A TypeScript client library for consuming the API Hub backend with full type support.
13
+ </p>
14
+
15
+ <p align="center">
16
+ <em>Companion package to <strong>api-hub</strong> in the monorepo</em>
17
+ </p>
18
+
19
+ ---
20
+
21
+ ## Overview
22
+
23
+ `api-hub-client` provides a **developer-friendly TypeScript interface** to interact with the `api-hub` server.
24
+ It simplifies API calls by handling requests, responses, and type definitions automatically, enabling **type-safe and maintainable integration** in frontend or Node.js applications.
25
+
26
+ ---
27
+
28
+ ## Features
29
+
30
+ - Fully typed TypeScript API for IntelliSense and compile-time safety
31
+ - Async/await interface for all requests
32
+ - Supports all endpoints exposed by the `api-hub` server
33
+ - Easy configuration with `baseUrl`
34
+ - Handles errors and responses consistently
35
+
36
+ ---
37
+
38
+ ## Supported API Endpoints
39
+
40
+ | Module | Endpoint | Description | Example Method |
41
+ |------------|----------|------------|----------------|
42
+ | [GitHub](../api-hub/src/routes/github.ts) | `/github/repos/:username` | Fetch GitHub repositories for a given username | `client.github.getRepos(username)` |
43
+ | [YouTube](../api-hub/src/routes/youtube.ts) | `/youtube/search/:query` | Search YouTube videos by query | `client.youtube.search(query)` |
44
+ | [TheMealDB](../api-hub/src/routes/mealdb.ts) | `/mealdb/search/:query` | Search for meals and recipes | `client.mealdb.search(query)` |
45
+ | [NewsAPI](../api-hub/src/routes/newsapi.ts) | `/newsapi/top-headlines` | Fetch latest news articles | `client.newsapi.topHeadlines(country)` |
46
+ | [Weather](../api-hub/src/routes/weather.ts) | `/weather/current/:city` | Get current weather info for a city | `client.weather.getCurrent(city)` |
47
+
48
+ > Click the module name to view the corresponding backend route implementation.
49
+
50
+ ---
51
+
52
+ ## Project Structure
53
+
54
+ ```text
55
+ api-hub-client/
56
+ ├── src/
57
+ │ ├── index.ts # Entry point exporting ApiHubClient class
58
+ │ ├── client.ts # HTTP client implementation
59
+ │ └── types/ # TypeScript types for requests and responses
60
+ ├── package.json
61
+ ├── tsconfig.json
62
+ ├── README.md
63
+ └── .env.example
64
+ ````
65
+
66
+ ---
67
+
68
+ ## Prerequisites
69
+
70
+ * Node.js **v18 or later**
71
+ * npm, yarn, or pnpm
72
+ * Access to a running `api-hub` server
73
+
74
+ ---
75
+
76
+ ## Installation
77
+
78
+ Install the package in your project:
79
+
80
+ ```bash
81
+ npm install api-hub-client
82
+ # or
83
+ yarn add api-hub-client
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Configuration
89
+
90
+ Create an instance of the client with your API Hub server base URL:
91
+
92
+ ```ts
93
+ import { ApiHubClient } from "api-hub-client";
94
+
95
+ const client = new ApiHubClient({
96
+ baseUrl: "http://localhost:8080",
97
+ });
98
+ ```
99
+
100
+ ---
101
+
102
+ ## Usage Examples
103
+
104
+ ### Fetch GitHub Repositories
105
+
106
+ ```ts
107
+ const repos = await client.github.getRepos("facebook");
108
+ console.log(repos);
109
+ ```
110
+
111
+ ### Search TheMealDB
112
+
113
+ ```ts
114
+ const recipes = await client.mealdb.search("carbonara");
115
+ console.log(recipes);
116
+ ```
117
+
118
+ ### Search YouTube
119
+
120
+ ```ts
121
+ const videos = await client.youtube.search("nextjs tutorial");
122
+ console.log(videos);
123
+ ```
124
+
125
+ ---
126
+
127
+ ## TypeScript Support
128
+
129
+ Provides types for:
130
+
131
+ * Request parameters
132
+ * API responses
133
+ * Error handling
134
+ * Optional pagination helpers
135
+
136
+ This ensures **full IntelliSense and compile-time safety**.
137
+
138
+ ---
139
+
140
+ ## Development
141
+
142
+ ```bash
143
+ cd api-hub-client
144
+ npm install
145
+ npm run build
146
+ ```
147
+
148
+ Link the client locally for testing:
149
+
150
+ ```bash
151
+ npm link
152
+ ```
153
+
154
+ > Ensure the `api-hub` server is running for real-time testing.
155
+
156
+ ---
157
+
158
+ ## Scripts
159
+
160
+ | Command | Description |
161
+ | --------------- | --------------------------------- |
162
+ | `npm run dev` | Start development with watch mode |
163
+ | `npm run build` | Compile TypeScript to JavaScript |
164
+ | `npm test` | Run unit tests (if available) |
165
+
166
+ ---
167
+
168
+ ## Contributing
169
+
170
+ This package follows the monorepo contribution guidelines.
171
+
172
+ Please review [`CONTRIBUTING.md`](../CONTRIBUTING.md) before submitting a pull request.
173
+
174
+ ---
175
+
176
+ ## License
177
+
178
+ MIT
179
+
180
+
@@ -0,0 +1,184 @@
1
+ type FlixquestProvider = "showbox" | "vidsrcto";
2
+
3
+ declare class ApiHubClient {
4
+ github: {
5
+ getUser(username: string): Promise<any>;
6
+ getRepo(username: string, repository: string): Promise<any>;
7
+ searchUsers(username: string): Promise<any>;
8
+ searchRepos(repository: string): Promise<any>;
9
+ };
10
+ crypto: {
11
+ getMarket(): Promise<any>;
12
+ };
13
+ flixquest: {
14
+ getMovieStreamingLinks(tmdbID: string, provider?: FlixquestProvider): Promise<any>;
15
+ getTvEpisodeStreamingLinks(tmdbID: string, season: string | number, episode: string | number, provider?: FlixquestProvider): Promise<any>;
16
+ };
17
+ googlebooks: {
18
+ search(book: string): Promise<any>;
19
+ getVolume(id: string): Promise<any>;
20
+ searchAdvanced(params: {
21
+ q: string;
22
+ startIndex?: number;
23
+ maxResults?: number;
24
+ orderBy?: string;
25
+ langRestrict?: string;
26
+ printType?: string;
27
+ projection?: string;
28
+ }): Promise<any>;
29
+ };
30
+ hackernews: {
31
+ newStories(limit?: number): Promise<any>;
32
+ topStories(limit?: number): Promise<any>;
33
+ bestStories(limit?: number): Promise<any>;
34
+ askStories(limit?: number): Promise<any>;
35
+ showStories(limit?: number): Promise<any>;
36
+ jobStories(limit?: number): Promise<any>;
37
+ getItem(id: string): Promise<any>;
38
+ getUser(id: string): Promise<any>;
39
+ updates(): Promise<any>;
40
+ maxItem(): Promise<any>;
41
+ };
42
+ jsonplaceholder: {
43
+ getPosts(page?: number, limit?: number): Promise<any>;
44
+ getPost(id: number | string): Promise<any>;
45
+ getPostComments(id: number | string): Promise<any>;
46
+ getComments(): Promise<any>;
47
+ getAlbums(page?: number, limit?: number): Promise<any>;
48
+ getAlbum(id: number | string): Promise<any>;
49
+ getAlbumPhotos(id: number | string): Promise<any>;
50
+ getPhotos(page?: number, limit?: number): Promise<any>;
51
+ getPhoto(id: number | string): Promise<any>;
52
+ getTodos(): Promise<any>;
53
+ getUsers(page?: number, limit?: number): Promise<any>;
54
+ getUser(id: number | string): Promise<any>;
55
+ getUserPosts(id: number | string): Promise<any>;
56
+ getUserTodos(id: number | string): Promise<any>;
57
+ getUserAlbums(id: number | string): Promise<any>;
58
+ };
59
+ youtube: {
60
+ search(videoTitle: string): Promise<any>;
61
+ };
62
+ apicagent: {
63
+ getUserAgent(): Promise<any>;
64
+ };
65
+ apotd: {
66
+ getToday(): Promise<any>;
67
+ getRandom(amount: number): Promise<any>;
68
+ getWeekly(): Promise<any>;
69
+ getMonthly(): Promise<any>;
70
+ getSpecific(year: number | string, month: number | string, day: number | string): Promise<any>;
71
+ };
72
+ bible: {
73
+ getBooks(): Promise<any>;
74
+ getChapter(book: string, chapter: number | string): Promise<any>;
75
+ getVerses(book: string, chapter: number | string, from: number | string, to: number | string): Promise<any>;
76
+ getVerse(book: string, chapter: number | string, verse: number | string): Promise<any>;
77
+ };
78
+ chucknorris: {
79
+ getRandom(): Promise<any>;
80
+ getCategories(): Promise<any>;
81
+ getRandomByCategory(category: string): Promise<any>;
82
+ search(query: string): Promise<any>;
83
+ };
84
+ randomuser: {
85
+ getUser(): Promise<any>;
86
+ getUserNoInfo(): Promise<any>;
87
+ getUsers(count: number): Promise<any>;
88
+ getByGender(gender: string): Promise<any>;
89
+ getByNat(nat: string): Promise<any>;
90
+ exclude(fields: string): Promise<any>;
91
+ include(fields: string): Promise<any>;
92
+ format(fmt: string): Promise<any>;
93
+ password(strength: string): Promise<any>;
94
+ };
95
+ lyrics: {
96
+ getLyrics(artist: string, title: string): Promise<any>;
97
+ };
98
+ mealdb: {
99
+ search(searchQuery: string): Promise<any>;
100
+ getMeal(mealID: string): Promise<any>;
101
+ getCategories(): Promise<any>;
102
+ getByCategory(category: string): Promise<any>;
103
+ };
104
+ moviedb: {
105
+ discoverMovies(page?: number): Promise<any>;
106
+ searchMovies(title: string, year?: string, page?: number): Promise<any>;
107
+ getMovieDetails(movieId: string): Promise<any>;
108
+ getTrendingMovies(page?: number): Promise<any>;
109
+ getTopRatedMovies(page?: number): Promise<any>;
110
+ discoverTV(page?: number): Promise<any>;
111
+ searchTV(title: string, year?: string, page?: number): Promise<any>;
112
+ getTVDetails(id: string): Promise<any>;
113
+ getTVSeasonDetails(id: string, seasonNumber: string): Promise<any>;
114
+ getTVEpisodeDetails(id: string, seasonNumber: string, episodeNumber?: string): Promise<any>;
115
+ getTrendingTV(page?: number): Promise<any>;
116
+ getTopRatedTV(page?: number): Promise<any>;
117
+ };
118
+ news: {
119
+ search(term: string): Promise<any>;
120
+ getHeadlines(category?: string, country?: string): Promise<any>;
121
+ };
122
+ newyorktimes: {
123
+ getArchive(year: number, month: number): Promise<any>;
124
+ searchArticles(q: string, options?: {
125
+ fq?: string;
126
+ begin_date?: string;
127
+ end_date?: string;
128
+ facet?: string;
129
+ facet_fields?: string;
130
+ facet_filter?: string;
131
+ sort?: string;
132
+ fl?: string;
133
+ page?: string;
134
+ }): Promise<any>;
135
+ getBestsellerBooks(listName: string, options?: {
136
+ bestsellers_date?: string;
137
+ published_date?: string;
138
+ offset?: string;
139
+ }): Promise<any>;
140
+ getBestsellerBooksByDate(bestsellerDate: string, listName: string, offset?: string): Promise<any>;
141
+ getBestsellerListNames(): Promise<any>;
142
+ getBooksOverview(publishedDate?: string): Promise<any>;
143
+ getTop5BestsellerBooks(publishedDate?: string): Promise<any>;
144
+ getPopularViewed(period: string): Promise<any>;
145
+ getPopularShared(period: string): Promise<any>;
146
+ getPopularSharedBySource(period: string, source: string): Promise<any>;
147
+ getTopStories(section: string): Promise<any>;
148
+ };
149
+ restcountries: {
150
+ getAll(): Promise<any>;
151
+ getByName(name: string): Promise<any>;
152
+ getByCode(code: string): Promise<any>;
153
+ getByCodes(codes: string): Promise<any>;
154
+ getByCurrency(currency: string): Promise<any>;
155
+ getByLanguage(language: string): Promise<any>;
156
+ getByCapital(capital: string): Promise<any>;
157
+ getByRegion(region: string): Promise<any>;
158
+ getBySubregion(subregion: string): Promise<any>;
159
+ };
160
+ tvmaze: {
161
+ searchShows(query: string): Promise<any>;
162
+ getShow(showId: number): Promise<any>;
163
+ getSeasons(showId: number): Promise<any>;
164
+ getSeasonEpisodes(seasonId: number): Promise<any>;
165
+ getEpisode(episodeId: number): Promise<any>;
166
+ };
167
+ weather: {
168
+ forecastByLocation(location: string, days: number): Promise<any>;
169
+ forecastByCoords(latitude: number, longitude: number): Promise<any>;
170
+ search(location: string): Promise<any>;
171
+ };
172
+ reddit: {
173
+ getSubreddit(subreddit: string, options?: {
174
+ listing?: "new" | "hot" | "rising" | "best" | "random" | "top";
175
+ time?: "hour" | "day" | "week" | "month" | "year" | "all";
176
+ limit?: number;
177
+ }): Promise<any>;
178
+ };
179
+ constructor({ baseUrl }: {
180
+ baseUrl: string;
181
+ });
182
+ }
183
+
184
+ export { ApiHubClient };
package/dist/index.js ADDED
@@ -0,0 +1,752 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ ApiHubClient: () => ApiHubClient
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/httpClient.ts
28
+ var HttpClient = class {
29
+ constructor(baseUrl) {
30
+ this.baseUrl = baseUrl;
31
+ }
32
+ async request(path, options) {
33
+ const res = await fetch(`${this.baseUrl}${path}`, {
34
+ headers: {
35
+ "Content-Type": "application/json"
36
+ },
37
+ ...options
38
+ });
39
+ if (!res.ok) {
40
+ const error = await res.text();
41
+ throw new Error(error || "API request failed");
42
+ }
43
+ return res.json();
44
+ }
45
+ get(path) {
46
+ return this.request(path);
47
+ }
48
+ };
49
+
50
+ // src/github.ts
51
+ var githubApi = (client) => ({
52
+ /**
53
+ * Get GitHub user profile + repositories
54
+ */
55
+ getUser(username) {
56
+ return client.get(`/github/user/${username}`);
57
+ },
58
+ /**
59
+ * Get a specific GitHub repository
60
+ */
61
+ getRepo(username, repository) {
62
+ return client.get(`/github/repo/${username}/${repository}`);
63
+ },
64
+ /**
65
+ * Search GitHub users
66
+ */
67
+ searchUsers(username) {
68
+ return client.get(`/github/search/users/${username}`);
69
+ },
70
+ /**
71
+ * Search GitHub repositories
72
+ */
73
+ searchRepos(repository) {
74
+ return client.get(`/github/search/repos/${repository}`);
75
+ }
76
+ });
77
+
78
+ // src/crypto.ts
79
+ var cryptoApi = (client) => ({
80
+ /**
81
+ * Get current crypto market prices (USD)
82
+ */
83
+ getMarket() {
84
+ return client.get("/crypto/market");
85
+ }
86
+ });
87
+
88
+ // src/youtube.ts
89
+ var youtubeApi = (client) => ({
90
+ /**
91
+ * Search YouTube videos by title
92
+ */
93
+ search(videoTitle) {
94
+ return client.get(`/youtube/search/${encodeURIComponent(videoTitle)}`);
95
+ }
96
+ });
97
+
98
+ // src/apicagent.ts
99
+ var apicagentApi = (client) => ({
100
+ /**
101
+ * Get user-agent information as seen by the server
102
+ */
103
+ getUserAgent() {
104
+ return client.get(`/apicagent/user-agent`);
105
+ }
106
+ });
107
+
108
+ // src/apotd.ts
109
+ var apotdApi = (client) => ({
110
+ getToday() {
111
+ return client.get(`/apotd/today`);
112
+ },
113
+ getRandom(amount) {
114
+ return client.get(`/apotd/random/${amount}`);
115
+ },
116
+ getWeekly() {
117
+ return client.get(`/apotd/weekly`);
118
+ },
119
+ getMonthly() {
120
+ return client.get(`/apotd/monthly`);
121
+ },
122
+ getSpecific(year, month, day) {
123
+ return client.get(`/apotd/specific/${year}/${month}/${day}`);
124
+ }
125
+ });
126
+
127
+ // src/bible.ts
128
+ var bibleApi = (client) => ({
129
+ getBooks() {
130
+ return client.get(`/bible/books`);
131
+ },
132
+ getChapter(book, chapter) {
133
+ return client.get(`/bible/${encodeURIComponent(book)}/${chapter}`);
134
+ },
135
+ getVerses(book, chapter, from, to) {
136
+ return client.get(`/bible/${encodeURIComponent(book)}/${chapter}/${from}/${to}`);
137
+ },
138
+ getVerse(book, chapter, verse) {
139
+ return client.get(`/bible/${encodeURIComponent(book)}/${chapter}/${verse}`);
140
+ }
141
+ });
142
+
143
+ // src/chucknorris.ts
144
+ var chucknorrisApi = (client) => ({
145
+ getRandom() {
146
+ return client.get(`/chucknorris/jokes/random`);
147
+ },
148
+ getCategories() {
149
+ return client.get(`/chucknorris/jokes/categories`);
150
+ },
151
+ getRandomByCategory(category) {
152
+ return client.get(`/chucknorris/jokes/random/${encodeURIComponent(category)}`);
153
+ },
154
+ search(query) {
155
+ return client.get(`/chucknorris/jokes/search/${encodeURIComponent(query)}`);
156
+ }
157
+ });
158
+
159
+ // src/randomuser.ts
160
+ var randomuserApi = (client) => ({
161
+ getUser() {
162
+ return client.get(`/randomuser/user`);
163
+ },
164
+ getUserNoInfo() {
165
+ return client.get(`/randomuser/user/data`);
166
+ },
167
+ getUsers(count) {
168
+ return client.get(`/randomuser/users/${count}`);
169
+ },
170
+ getByGender(gender) {
171
+ return client.get(`/randomuser/user/${encodeURIComponent(gender)}`);
172
+ },
173
+ getByNat(nat) {
174
+ return client.get(`/randomuser/country/${encodeURIComponent(nat)}`);
175
+ },
176
+ exclude(fields) {
177
+ return client.get(`/randomuser/exclude/${encodeURIComponent(fields)}`);
178
+ },
179
+ include(fields) {
180
+ return client.get(`/randomuser/include/${encodeURIComponent(fields)}`);
181
+ },
182
+ format(fmt) {
183
+ return client.get(`/randomuser/format/${encodeURIComponent(fmt)}`);
184
+ },
185
+ password(strength) {
186
+ return client.get(`/randomuser/password/${encodeURIComponent(strength)}`);
187
+ }
188
+ });
189
+
190
+ // src/lyrics.ts
191
+ var lyricsApi = (client) => ({
192
+ /**
193
+ * Get lyrics for a song by artist and title
194
+ */
195
+ getLyrics(artist, title) {
196
+ return client.get(`/lyrics/${encodeURIComponent(artist)}/${encodeURIComponent(title)}`);
197
+ }
198
+ });
199
+
200
+ // src/mealdb.ts
201
+ var mealdbApi = (client) => ({
202
+ /**
203
+ * Search for meals by query
204
+ */
205
+ search(searchQuery) {
206
+ return client.get(`/mealdb/search/${encodeURIComponent(searchQuery)}`);
207
+ },
208
+ /**
209
+ * Get a specific meal by ID
210
+ */
211
+ getMeal(mealID) {
212
+ return client.get(`/mealdb/meal/${encodeURIComponent(mealID)}`);
213
+ },
214
+ /**
215
+ * Get all categories
216
+ */
217
+ getCategories() {
218
+ return client.get("/mealdb/categories");
219
+ },
220
+ /**
221
+ * Get meals by category
222
+ */
223
+ getByCategory(category) {
224
+ return client.get(`/mealdb/category/${encodeURIComponent(category)}`);
225
+ }
226
+ });
227
+
228
+ // src/moviedb.ts
229
+ var moviedbApi = (client) => ({
230
+ /**
231
+ * Discover movies
232
+ */
233
+ discoverMovies(page) {
234
+ const path = page ? `/moviedb/movies/discover/${page}` : "/moviedb/movies/discover";
235
+ return client.get(path);
236
+ },
237
+ /**
238
+ * Search movies by title
239
+ */
240
+ searchMovies(title, year, page) {
241
+ let path = `/moviedb/movies/search/${encodeURIComponent(title)}`;
242
+ if (year) path += `/${encodeURIComponent(year)}`;
243
+ if (page) path += `/${page}`;
244
+ return client.get(path);
245
+ },
246
+ /**
247
+ * Get movie details by ID
248
+ */
249
+ getMovieDetails(movieId) {
250
+ return client.get(`/moviedb/movies/details/${encodeURIComponent(movieId)}`);
251
+ },
252
+ /**
253
+ * Get trending movies
254
+ */
255
+ getTrendingMovies(page) {
256
+ const path = page ? `/moviedb/movies/trending/${page}` : "/moviedb/movies/trending";
257
+ return client.get(path);
258
+ },
259
+ /**
260
+ * Get top-rated movies
261
+ */
262
+ getTopRatedMovies(page) {
263
+ const path = page ? `/moviedb/movies/top-rated/${page}` : "/moviedb/movies/top-rated";
264
+ return client.get(path);
265
+ },
266
+ /**
267
+ * Discover TV shows
268
+ */
269
+ discoverTV(page) {
270
+ const path = page ? `/moviedb/tv/discover/${page}` : "/moviedb/tv/discover";
271
+ return client.get(path);
272
+ },
273
+ /**
274
+ * Search TV shows by title
275
+ */
276
+ searchTV(title, year, page) {
277
+ let path = `/moviedb/tv/search/${encodeURIComponent(title)}`;
278
+ if (year) path += `/${encodeURIComponent(year)}`;
279
+ if (page) path += `/${page}`;
280
+ return client.get(path);
281
+ },
282
+ /**
283
+ * Get TV show details by ID
284
+ */
285
+ getTVDetails(id) {
286
+ return client.get(`/moviedb/tv/details/${encodeURIComponent(id)}`);
287
+ },
288
+ /**
289
+ * Get TV season details
290
+ */
291
+ getTVSeasonDetails(id, seasonNumber) {
292
+ return client.get(`/moviedb/tv/details/${encodeURIComponent(id)}/season/${encodeURIComponent(seasonNumber)}`);
293
+ },
294
+ /**
295
+ * Get TV episode details
296
+ */
297
+ getTVEpisodeDetails(id, seasonNumber, episodeNumber) {
298
+ let path = `/moviedb/tv/details/${encodeURIComponent(id)}/season/${encodeURIComponent(seasonNumber)}/episode`;
299
+ if (episodeNumber) path += `/${encodeURIComponent(episodeNumber)}`;
300
+ return client.get(path);
301
+ },
302
+ /**
303
+ * Get trending TV shows
304
+ */
305
+ getTrendingTV(page) {
306
+ const path = page ? `/moviedb/tv/trending/${page}` : "/moviedb/tv/trending";
307
+ return client.get(path);
308
+ },
309
+ /**
310
+ * Get top-rated TV shows
311
+ */
312
+ getTopRatedTV(page) {
313
+ const path = page ? `/moviedb/tv/top-rated/${page}` : "/moviedb/tv/top-rated";
314
+ return client.get(path);
315
+ }
316
+ });
317
+
318
+ // src/news.ts
319
+ var newsApi = (client) => ({
320
+ /**
321
+ * Search for news articles by term
322
+ */
323
+ search(term) {
324
+ return client.get(`/news/search/${encodeURIComponent(term)}`);
325
+ },
326
+ /**
327
+ * Get headlines by category and country
328
+ */
329
+ getHeadlines(category, country) {
330
+ let path = "/news/headlines";
331
+ if (category) path += `/${encodeURIComponent(category)}`;
332
+ if (country) path += `/${encodeURIComponent(country)}`;
333
+ return client.get(path);
334
+ }
335
+ });
336
+
337
+ // src/newyorktimes.ts
338
+ var newyorktimesApi = (client) => ({
339
+ /**
340
+ * Get archived articles by year and month
341
+ */
342
+ getArchive(year, month) {
343
+ return client.get(`/newyorktimes/archive/${year}/${month}`);
344
+ },
345
+ /**
346
+ * Search articles with optional filters
347
+ */
348
+ searchArticles(q, options) {
349
+ let path = `/newyorktimes/articles/search/${encodeURIComponent(q)}`;
350
+ if (options) {
351
+ const params = new URLSearchParams();
352
+ if (options.fq) params.append("fq", options.fq);
353
+ if (options.begin_date) params.append("begin_date", options.begin_date);
354
+ if (options.end_date) params.append("end_date", options.end_date);
355
+ if (options.facet) params.append("facet", options.facet);
356
+ if (options.facet_fields) params.append("facet_fields", options.facet_fields);
357
+ if (options.facet_filter) params.append("facet_filter", options.facet_filter);
358
+ if (options.sort) params.append("sort", options.sort);
359
+ if (options.fl) params.append("fl", options.fl);
360
+ if (options.page) params.append("page", options.page);
361
+ const queryString = params.toString();
362
+ if (queryString) path += `?${queryString}`;
363
+ }
364
+ return client.get(path);
365
+ },
366
+ /**
367
+ * Get bestseller books by list name
368
+ */
369
+ getBestsellerBooks(listName, options) {
370
+ let path = `/newyorktimes/bestsellers/books/${encodeURIComponent(listName)}`;
371
+ if (options) {
372
+ const params = new URLSearchParams();
373
+ if (options.bestsellers_date) params.append("bestsellers-date", options.bestsellers_date);
374
+ if (options.published_date) params.append("published-date", options.published_date);
375
+ if (options.offset) params.append("offset", options.offset);
376
+ const queryString = params.toString();
377
+ if (queryString) path += `?${queryString}`;
378
+ }
379
+ return client.get(path);
380
+ },
381
+ /**
382
+ * Get bestseller books by date and list name
383
+ */
384
+ getBestsellerBooksByDate(bestsellerDate, listName, offset) {
385
+ let path = `/newyorktimes/bestsellers/books/${encodeURIComponent(bestsellerDate)}/${encodeURIComponent(listName)}`;
386
+ if (offset) {
387
+ path += `?offset=${encodeURIComponent(offset)}`;
388
+ }
389
+ return client.get(path);
390
+ },
391
+ /**
392
+ * Get bestseller list names
393
+ */
394
+ getBestsellerListNames() {
395
+ return client.get("/newyorktimes/bestsellers/books/names");
396
+ },
397
+ /**
398
+ * Get books overview by published date
399
+ */
400
+ getBooksOverview(publishedDate) {
401
+ let path = "/newyorktimes/bestsellers/books/overview";
402
+ if (publishedDate) {
403
+ path += `?published-date=${encodeURIComponent(publishedDate)}`;
404
+ }
405
+ return client.get(path);
406
+ },
407
+ /**
408
+ * Get top 5 bestseller books
409
+ */
410
+ getTop5BestsellerBooks(publishedDate) {
411
+ let path = "/newyorktimes/bestsellers/books/overview/top5";
412
+ if (publishedDate) {
413
+ path += `?published-date=${encodeURIComponent(publishedDate)}`;
414
+ }
415
+ return client.get(path);
416
+ },
417
+ /**
418
+ * Get popular articles based on views
419
+ */
420
+ getPopularViewed(period) {
421
+ return client.get(`/newyorktimes/popular/viewed/${encodeURIComponent(period)}`);
422
+ },
423
+ /**
424
+ * Get popular articles based on shares
425
+ */
426
+ getPopularShared(period) {
427
+ return client.get(`/newyorktimes/popular/shared/${encodeURIComponent(period)}`);
428
+ },
429
+ /**
430
+ * Get popular articles shared via specific social media
431
+ */
432
+ getPopularSharedBySource(period, source) {
433
+ return client.get(`/newyorktimes/popular/shared/${encodeURIComponent(period)}/${encodeURIComponent(source)}`);
434
+ },
435
+ /**
436
+ * Get top stories by section
437
+ */
438
+ getTopStories(section) {
439
+ return client.get(`/newyorktimes/topstories/${encodeURIComponent(section)}`);
440
+ }
441
+ });
442
+
443
+ // src/flixquest.ts
444
+ var flixquestApi = (client) => ({
445
+ getMovieStreamingLinks(tmdbID, provider) {
446
+ const p = provider ?? "showbox";
447
+ return client.get(`/flixquest/movie/${encodeURIComponent(tmdbID)}/${encodeURIComponent(p)}`);
448
+ },
449
+ getTvEpisodeStreamingLinks(tmdbID, season, episode, provider) {
450
+ const p = provider ?? "showbox";
451
+ return client.get(
452
+ `/flixquest/tv/${encodeURIComponent(tmdbID)}/${encodeURIComponent(String(season))}/${encodeURIComponent(String(episode))}/${encodeURIComponent(p)}`
453
+ );
454
+ }
455
+ });
456
+
457
+ // src/googlebooks.ts
458
+ var googlebooksApi = (client) => ({
459
+ search(book) {
460
+ return client.get(`/googlebooks/search/${encodeURIComponent(book)}`);
461
+ },
462
+ getVolume(id) {
463
+ return client.get(`/googlebooks/volumes/${encodeURIComponent(id)}`);
464
+ },
465
+ searchAdvanced(params) {
466
+ const qs = new URLSearchParams();
467
+ qs.set("q", params.q);
468
+ if (params.startIndex !== void 0) qs.set("startIndex", String(params.startIndex));
469
+ if (params.maxResults !== void 0) qs.set("maxResults", String(params.maxResults));
470
+ if (params.orderBy) qs.set("orderBy", params.orderBy);
471
+ if (params.langRestrict) qs.set("langRestrict", params.langRestrict);
472
+ if (params.printType) qs.set("printType", params.printType);
473
+ if (params.projection) qs.set("projection", params.projection);
474
+ return client.get(`/googlebooks/search-advanced/results?${qs.toString()}`);
475
+ }
476
+ });
477
+
478
+ // src/hackernews.ts
479
+ var hackernewsApi = (client) => ({
480
+ newStories(limit) {
481
+ const path = limit ? `/hackernews/newstories?limit=${encodeURIComponent(String(limit))}` : "/hackernews/newstories";
482
+ return client.get(path);
483
+ },
484
+ topStories(limit) {
485
+ const path = limit ? `/hackernews/topstories?limit=${encodeURIComponent(String(limit))}` : "/hackernews/topstories";
486
+ return client.get(path);
487
+ },
488
+ bestStories(limit) {
489
+ const path = limit ? `/hackernews/beststories?limit=${encodeURIComponent(String(limit))}` : "/hackernews/beststories";
490
+ return client.get(path);
491
+ },
492
+ askStories(limit) {
493
+ const path = limit ? `/hackernews/askstories?limit=${encodeURIComponent(String(limit))}` : "/hackernews/askstories";
494
+ return client.get(path);
495
+ },
496
+ showStories(limit) {
497
+ const path = limit ? `/hackernews/showstories?limit=${encodeURIComponent(String(limit))}` : "/hackernews/showstories";
498
+ return client.get(path);
499
+ },
500
+ jobStories(limit) {
501
+ const path = limit ? `/hackernews/jobstories?limit=${encodeURIComponent(String(limit))}` : "/hackernews/jobstories";
502
+ return client.get(path);
503
+ },
504
+ getItem(id) {
505
+ return client.get(`/hackernews/item/${encodeURIComponent(id)}`);
506
+ },
507
+ getUser(id) {
508
+ return client.get(`/hackernews/user/${encodeURIComponent(id)}`);
509
+ },
510
+ updates() {
511
+ return client.get("/hackernews/updates");
512
+ },
513
+ maxItem() {
514
+ return client.get("/hackernews/maxitem");
515
+ }
516
+ });
517
+
518
+ // src/jsonplaceholder.ts
519
+ var jsonplaceholderApi = (client) => ({
520
+ getPosts(page, limit) {
521
+ if (page !== void 0 || limit !== void 0) {
522
+ const p = page ?? 1;
523
+ const l = limit ?? 5;
524
+ return client.get(`/jsonplaceholder/posts/${p}/${l}`);
525
+ }
526
+ return client.get("/jsonplaceholder/posts");
527
+ },
528
+ getPost(id) {
529
+ return client.get(`/jsonplaceholder/post/${encodeURIComponent(String(id))}`);
530
+ },
531
+ getPostComments(id) {
532
+ return client.get(`/jsonplaceholder/post/${encodeURIComponent(String(id))}/comments`);
533
+ },
534
+ getComments() {
535
+ return client.get("/jsonplaceholder/comments");
536
+ },
537
+ getAlbums(page, limit) {
538
+ if (page !== void 0 || limit !== void 0) {
539
+ const p = page ?? 1;
540
+ const l = limit ?? 5;
541
+ return client.get(`/jsonplaceholder/albums/${p}/${l}`);
542
+ }
543
+ return client.get("/jsonplaceholder/albums");
544
+ },
545
+ getAlbum(id) {
546
+ return client.get(`/jsonplaceholder/album/${encodeURIComponent(String(id))}`);
547
+ },
548
+ getAlbumPhotos(id) {
549
+ return client.get(`/jsonplaceholder/album/${encodeURIComponent(String(id))}/photos`);
550
+ },
551
+ getPhotos(page, limit) {
552
+ if (page !== void 0 || limit !== void 0) {
553
+ const p = page ?? 1;
554
+ const l = limit ?? 5;
555
+ return client.get(`/jsonplaceholder/photos/${p}/${l}`);
556
+ }
557
+ return client.get("/jsonplaceholder/photos");
558
+ },
559
+ getPhoto(id) {
560
+ return client.get(`/jsonplaceholder/photo/${encodeURIComponent(String(id))}`);
561
+ },
562
+ getTodos() {
563
+ return client.get("/jsonplaceholder/todos");
564
+ },
565
+ getUsers(page, limit) {
566
+ if (page !== void 0 || limit !== void 0) {
567
+ const p = page ?? 1;
568
+ const l = limit ?? 5;
569
+ return client.get(`/jsonplaceholder/users/${p}/${l}`);
570
+ }
571
+ return client.get("/jsonplaceholder/users");
572
+ },
573
+ getUser(id) {
574
+ return client.get(`/jsonplaceholder/user/${encodeURIComponent(String(id))}`);
575
+ },
576
+ getUserPosts(id) {
577
+ return client.get(`/jsonplaceholder/user/${encodeURIComponent(String(id))}/posts`);
578
+ },
579
+ getUserTodos(id) {
580
+ return client.get(`/jsonplaceholder/user/${encodeURIComponent(String(id))}/todos`);
581
+ },
582
+ getUserAlbums(id) {
583
+ return client.get(`/jsonplaceholder/user/${encodeURIComponent(String(id))}/albums`);
584
+ }
585
+ });
586
+
587
+ // src/restcountries.ts
588
+ var restCountriesApi = (client) => ({
589
+ /**
590
+ * Fetch all countries
591
+ */
592
+ getAll() {
593
+ return client.get("/restcountries/all");
594
+ },
595
+ /**
596
+ * Fetch country by name
597
+ */
598
+ getByName(name) {
599
+ return client.get(`/restcountries/${encodeURIComponent(name)}`);
600
+ },
601
+ /**
602
+ * Fetch country by ISO code
603
+ */
604
+ getByCode(code) {
605
+ return client.get(`/restcountries/code/${encodeURIComponent(code)}`);
606
+ },
607
+ /**
608
+ * Fetch multiple countries by codes (comma-separated)
609
+ */
610
+ getByCodes(codes) {
611
+ return client.get(`/restcountries/codes/${encodeURIComponent(codes)}`);
612
+ },
613
+ /**
614
+ * Fetch countries by currency
615
+ */
616
+ getByCurrency(currency) {
617
+ return client.get(`/restcountries/currency/${encodeURIComponent(currency)}`);
618
+ },
619
+ /**
620
+ * Fetch countries by language
621
+ */
622
+ getByLanguage(language) {
623
+ return client.get(`/restcountries/language/${encodeURIComponent(language)}`);
624
+ },
625
+ /**
626
+ * Fetch countries by capital city
627
+ */
628
+ getByCapital(capital) {
629
+ return client.get(`/restcountries/capital/${encodeURIComponent(capital)}`);
630
+ },
631
+ /**
632
+ * Fetch countries by region
633
+ */
634
+ getByRegion(region) {
635
+ return client.get(`/restcountries/region/${encodeURIComponent(region)}`);
636
+ },
637
+ /**
638
+ * Fetch countries by subregion
639
+ */
640
+ getBySubregion(subregion) {
641
+ return client.get(`/restcountries/subregion/${encodeURIComponent(subregion)}`);
642
+ }
643
+ });
644
+
645
+ // src/tvmaze.ts
646
+ var tvMazeApi = (client) => ({
647
+ /**
648
+ * Search TV shows by name
649
+ */
650
+ searchShows(query) {
651
+ return client.get(`/tvmaze/shows/search/${encodeURIComponent(query)}`);
652
+ },
653
+ /**
654
+ * Get show details by show ID
655
+ */
656
+ getShow(showId) {
657
+ return client.get(`/tvmaze/shows/${showId}`);
658
+ },
659
+ /**
660
+ * Get seasons of a show
661
+ */
662
+ getSeasons(showId) {
663
+ return client.get(`/tvmaze/shows/${showId}/seasons`);
664
+ },
665
+ /**
666
+ * Get episodes of a season
667
+ */
668
+ getSeasonEpisodes(seasonId) {
669
+ return client.get(`/tvmaze/seasons/${seasonId}/episodes`);
670
+ },
671
+ /**
672
+ * Get episode details by episode ID
673
+ */
674
+ getEpisode(episodeId) {
675
+ return client.get(`/tvmaze/episodes/${episodeId}`);
676
+ }
677
+ });
678
+
679
+ // src/weather.ts
680
+ var weatherApi = (client) => ({
681
+ /**
682
+ * Get weather forecast by city/location name
683
+ */
684
+ forecastByLocation(location, days) {
685
+ return client.get(
686
+ `/weather/forecast/${encodeURIComponent(location)}/${days}`
687
+ );
688
+ },
689
+ /**
690
+ * Get weather forecast by latitude & longitude
691
+ */
692
+ forecastByCoords(latitude, longitude) {
693
+ return client.get(
694
+ `/weather/forecast/${latitude}/${longitude}`
695
+ );
696
+ },
697
+ /**
698
+ * Search for a location
699
+ */
700
+ search(location) {
701
+ return client.get(
702
+ `/weather/search/${encodeURIComponent(location)}`
703
+ );
704
+ }
705
+ });
706
+
707
+ // src/reddit.ts
708
+ var redditApi = (client) => ({
709
+ /**
710
+ * Fetch subreddit data
711
+ */
712
+ getSubreddit(subreddit, options) {
713
+ const listing = options?.listing ?? "top";
714
+ const time = options?.time ?? "week";
715
+ const limit = options?.limit ?? 20;
716
+ return client.get(
717
+ `/reddit/${encodeURIComponent(subreddit)}/${listing}/${time}/${limit}`
718
+ );
719
+ }
720
+ });
721
+
722
+ // src/index.ts
723
+ var ApiHubClient = class {
724
+ constructor({ baseUrl }) {
725
+ const client = new HttpClient(baseUrl);
726
+ this.github = githubApi(client);
727
+ this.crypto = cryptoApi(client);
728
+ this.flixquest = flixquestApi(client);
729
+ this.googlebooks = googlebooksApi(client);
730
+ this.hackernews = hackernewsApi(client);
731
+ this.jsonplaceholder = jsonplaceholderApi(client);
732
+ this.youtube = youtubeApi(client);
733
+ this.apicagent = apicagentApi(client);
734
+ this.apotd = apotdApi(client);
735
+ this.bible = bibleApi(client);
736
+ this.chucknorris = chucknorrisApi(client);
737
+ this.randomuser = randomuserApi(client);
738
+ this.lyrics = lyricsApi(client);
739
+ this.mealdb = mealdbApi(client);
740
+ this.moviedb = moviedbApi(client);
741
+ this.news = newsApi(client);
742
+ this.newyorktimes = newyorktimesApi(client);
743
+ this.restcountries = restCountriesApi(client);
744
+ this.tvmaze = tvMazeApi(client);
745
+ this.weather = weatherApi(client);
746
+ this.reddit = redditApi(client);
747
+ }
748
+ };
749
+ // Annotate the CommonJS export names for ESM import in node:
750
+ 0 && (module.exports = {
751
+ ApiHubClient
752
+ });
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "api-hub-client",
3
+ "version": "1.0.0",
4
+ "description": "This is a API Hub client for the API routes",
5
+ "license": "MIT",
6
+ "author": "Biruk Lemma",
7
+ "type": "commonjs",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "test": "echo \"Error: no test specified\" && exit 1",
15
+ "dev": "tsx watch src/index.ts",
16
+ "build": "tsup src/index.ts --dts"
17
+ },
18
+ "devDependencies": {
19
+ "tsup": "^8.5.1",
20
+ "typescript": "^5.9.3"
21
+ }
22
+ }