Edits history of script submission #9343 for ' Information about your account calls quota (webscrapingai)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Webscrapingai = {
    	apiKey: string
    }
    /**
     * Information about your account calls quota
     * Returns information about your account, including the remaining API credits quota, the next billing cycle start time, and the remaining concurrent requests. The response is in JSON format.
     */
    export async function main(auth: Webscrapingai) {
    	const url = new URL(`https://api.webscraping.ai/account`)
    
    	url.searchParams.append('api_key', auth.apiKey)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 581 days ago