Nuxt module to talk to APIs you don't control, with generated type-safe composables and a server proxy that keeps credentials off the client.
useFetch and $fetchnpx nuxt module add api-party
Add Nuxt API Party to your Nuxt configuration and describe your first API under the apiParty module option:
// `nuxt.config.ts`
export default defineNuxtConfig({
modules: ['nuxt-api-party'],
apiParty: {
endpoints: {
jsonPlaceholder: {
url: process.env.JSON_PLACEHOLDER_API_BASE_URL!,
// Global headers sent with each request
headers: {
Authorization: `Bearer ${process.env.JSON_PLACEHOLDER_API_TOKEN}`
}
}
}
}
})
If you were to call your API jsonPlaceholder, the generated composables are:
$jsonPlaceholder – Returns the response data, similar to $fetchuseJsonPlaceholderData – Returns multiple values similar to useFetchUse these composables in your templates or components:
<script setup lang="ts">
const { data, refresh, error, status, clear } = await useJsonPlaceholderData('posts/1')
</script>
<template>
<h1>{{ data?.title }}</h1>
<pre>{{ JSON.stringify(data, undefined, 2) }}</pre>
</template>
!TIP You can connect as many APIs as you want, just add them to the
endpointsobject.
The documentation covers the OpenAPI integration, caching and every module option.
corepack enablepnpm installpnpm run dev:preparepnpm run devMIT License © 2022-PRESENT Johann Schopplich and © 2025-PRESENT Matthew Messinger