rimgo/api/f.ts

27 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-10-08 07:38:43 +00:00
export const fetchUserInfo = async (userID: string): Promise<UserResult> => {
// https://api.imgur.com/account/v1/accounts/hughjaniss?client_id=${CLIENT_ID}
2021-11-25 12:50:55 +00:00
const response = await get(
2021-10-08 07:38:43 +00:00
`https://api.imgur.com/account/v1/accounts/${userID.toLowerCase()}?client_id=${CONFIG.imgur_client_id}&include=`,
);
return JSON.parse(response.body);
}
2021-10-08 06:45:56 +00:00
export const fetchUserPosts = async (userID: string, sort: Sorting = 'newest'): Promise<Post[]> => {
2021-10-07 17:29:02 +00:00
/* eslint-disable max-len */
// https://api.imgur.com/3/account/mombotnumber5/submissions/0/newest?album_previews=1&client_id=${CLIENT_ID}
2021-11-25 12:50:55 +00:00
const response = await get(
2021-10-08 07:38:43 +00:00
`https://api.imgur.com/3/account/${userID.toLowerCase()}/submissions/0/${sort}?album_previews=1&client_id=${CONFIG.imgur_client_id}`,
2021-10-08 06:45:56 +00:00
);
return JSON.parse(response.body).data;
/* eslint-enable max-len */
}
export const fetchTagPosts = async (tagID: string, sort: Sorting = 'viral'): Promise<TagResult> => {
/* eslint-disable max-len */
// https://api.imgur.com/3/account/mombotnumber5/submissions/0/newest?album_previews=1&client_id=${CLIENT_ID}
2021-11-25 12:50:55 +00:00
const response = await get(
2021-10-08 06:45:56 +00:00
`https://api.imgur.com/3/gallery/t/${tagID.toLowerCase()}/${sort}/week/0?client_id=${CONFIG.imgur_client_id}`,
2021-10-07 17:29:02 +00:00
);
return JSON.parse(response.body).data;
/* eslint-enable max-len */
2022-01-18 23:31:26 +00:00
}