0

Get your API keys

by
Published Oct 17, 2025

Get the API keys for your ReadMe project.

Script readme Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Get your API keys
4
 * Get the API keys for your ReadMe project.
5
 */
6
export async function main(
7
	auth: RT.Readme,
8
	subdomain: string,
9
	page?: string | undefined,
10
	per_page?: string | undefined
11
) {
12
	const url = new URL(`https://api.readme.com/v2/projects/${subdomain}/apikeys`)
13
	for (const [k, v] of [
14
		['page', page],
15
		['per_page', per_page]
16
	]) {
17
		if (v !== undefined && v !== '') {
18
			url.searchParams.append(k, v)
19
		}
20
	}
21
	const response = await fetch(url, {
22
		method: 'GET',
23
		headers: {
24
			Authorization: 'Bearer ' + auth.apiKey
25
		},
26
		body: undefined
27
	})
28
	if (!response.ok) {
29
		const text = await response.text()
30
		throw new Error(`${response.status} ${text}`)
31
	}
32
	return await response.json()
33
}
34