//native
type Klaviyo = {
apiKey: string;
};
/**
* Get List
* Get a list with the given list ID.*Rate limits*:Burst: `75/s`Steady: `700/m`Rate limits when using the `additional-fields[list]=profile_count` parameter in your API request:Burst: `1/s`Steady: `15/m`To learn more about how the `additional-fields` parameter impacts rate limits, check out our [Rate limits, status codes, and errors](https://developers.klaviyo.com/en/v2024-10-15/docs/rate_limits_and_error_handling) guide.
*/
export async function main(
auth: Klaviyo,
id: string,
additional_fields_list_: string | undefined,
fields_flow_: string | undefined,
fields_list_: string | undefined,
fields_tag_: string | undefined,
include: string | undefined,
revision: string,
) {
const url = new URL(`https://a.klaviyo.com/api/lists/${id}`);
for (const [k, v] of [
["additional-fields[list]", additional_fields_list_],
["fields[flow]", fields_flow_],
["fields[list]", fields_list_],
["fields[tag]", fields_tag_],
["include", include],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
revision: revision,
"Accept": "application/vnd.api+json",
Authorization: "Klaviyo-API-Key " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago