Endpoint

Get Started

It has never been easier to get Animal Crossing music!

There are no headers required for this API, simply fetch https://ac-api.vercel.app/api/ and you're good to go!

Example:

const getSong = () => {
fetch("https://ac-api.vercel.app/api/")
.then((r) => r.json())
.then(parseResponse)
.then(setResponse);
};
setInterval(getSong, 15 * 1000);

React example:

useEffect(() => {
fetch("https://ac-api.vercel.app/api/").then((r) => r.json());
}, []);
💡

Using SWR for React you can achieve the same thing! If you want to see examples for Next.js you can check the examples or you can look at the usage.

For this API you can use a fetcher function, which is just a wrapper of the native fetch:

const fetcher = (...args) => fetch(...args).then((r) => r.json());

Then you can import useSWR and start using it inside any function components:

import useSWR from "swr";
function Music() {
const { data, error } = useSWR("https://ac-api.vercel.app/api/", fetch);
if (error) return <div>failed to load</div>;
if (!data) return <div>loading...</div>;
// render data
return <audio src={data.music[0].weather[1].rain} controls />;
}

Contribute

Feel free to contribute to this page by adding more examples, you can start by clicking the "Edit this page on GitHub" link below to.