0

Get a compute endpoint

by
Published Apr 8, 2025

Retrieves information about the specified compute endpoint. A compute endpoint is a Neon compute instance. You can obtain a `project_id` by listing the projects for your Neon account. You can obtain an `endpoint_id` by listing your project's compute endpoints. An `endpoint_id` has an `ep-` prefix. For information about compute endpoints, see [Manage computes](https://neon.tech/docs/manage/endpoints/).

Script neondb Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Neondb = {
3
	apiKey: string
4
}
5
/**
6
 * Get a compute endpoint
7
 * Retrieves information about the specified compute endpoint.
8
A compute endpoint is a Neon compute instance.
9
You can obtain a `project_id` by listing the projects for your Neon account.
10
You can obtain an `endpoint_id` by listing your project's compute endpoints.
11
An `endpoint_id` has an `ep-` prefix.
12
For information about compute endpoints, see [Manage computes](https://neon.tech/docs/manage/endpoints/).
13

14
 */
15
export async function main(auth: Neondb, project_id: string, endpoint_id: string) {
16
	const url = new URL(
17
		`https://console.neon.tech/api/v2/projects/${project_id}/endpoints/${endpoint_id}`
18
	)
19

20
	const response = await fetch(url, {
21
		method: 'GET',
22
		headers: {
23
			Authorization: 'Bearer ' + auth.apiKey
24
		},
25
		body: undefined
26
	})
27
	if (!response.ok) {
28
		const text = await response.text()
29
		throw new Error(`${response.status} ${text}`)
30
	}
31
	return await response.json()
32
}
33