Skip to main content
Deno 2 is finally here 🎉️
Learn more

Decurl

Curl bindings for Deno.

The goal of this library is not to provide an ergonomic layer on top of Curl, but to provide a 1:1 usage and feature parity with Curl with a few convenient helpers.

import Decurl, { globalInit, globalCleanup } from 'https://deno.land/x/decurl/decurl.ts'

globalInit()

using decurl = new Decurl()

decurl.setSslVerifypeer(0)
decurl.setUrl('https://example.com')

const curlCode = decurl.perform()
const responseCode = decurl.getResponseCode()
const response = decurl.getWriteFunctionData()

if (response) {
  console.log(new TextDecoder().decode(response))
}

console.log(responseCode)
console.log(curlCode)

globalCleanup()

Run with deno run -A --unstable.

More examples in the tests folder.

Requirements

  • Deno >= 1.37.1[1]
  • Curl >= 7.73.0[2]

[1] You can use older versions of Deno as well, but then you will have to call the method Decurl.cleanup() manually because you won’t be able to use using.

[2] On Windows you probably won’t need to install Curl as Decurl will download and cache libcurl.dll automatically on first execution.

Roadmap

  • Async operations.