MCPcopy
hub / github.com/gcui-art/suno-api / sunoApi

Function sunoApi

src/lib/SunoApi.ts:852–870  ·  view source on GitHub ↗
(cookie?: string)

Source from the content-addressed store, hash-verified

850}
851
852export const sunoApi = async (cookie?: string) => {
853 const resolvedCookie = cookie && cookie.includes('__client') ? cookie : process.env.SUNO_COOKIE; // Check for bad `Cookie` header (It's too expensive to actually parse the cookies *here*)
854 if (!resolvedCookie) {
855 logger.info('No cookie provided! Aborting...\nPlease provide a cookie either in the .env file or in the Cookie header of your request.')
856 throw new Error('Please provide a cookie either in the .env file or in the Cookie header of your request.');
857 }
858
859 // Check if the instance for this cookie already exists in the cache
860 const cachedInstance = cache.get(resolvedCookie);
861 if (cachedInstance)
862 return cachedInstance;
863
864 // If not, create a new instance and initialize it
865 const instance = await new SunoApi(resolvedCookie).init();
866 // Cache the initialized instance
867 cache.set(resolvedCookie, instance);
868
869 return instance;
870};

Callers 12

POSTFunction · 0.90
GETFunction · 0.90
GETFunction · 0.90
GETFunction · 0.90
POSTFunction · 0.90
POSTFunction · 0.90
POSTFunction · 0.90
POSTFunction · 0.90
GETFunction · 0.90
GETFunction · 0.90
POSTFunction · 0.90
POSTFunction · 0.90

Calls 2

getMethod · 0.80
initMethod · 0.80

Tested by

no test coverage detected