Skip to content

superagentvsbuzz

MIT 180 16 16,610
41.1 million (month) Aug 22 2011 10.1.1(2024-10-22 17:26:05 ago)
1,924 2 11 MIT
Nov 11 2011 8.4 thousand (month) 1.3.0(2024-09-23 13:16:34 ago)

superagent is an HTTP client library for Node.js that provides a simple, flexible, and powerful API for making HTTP requests. It supports all major HTTP methods, and has a clean and easy-to-use interface for handling responses and errors.

what differentiates superagent from other http clients is its simple declarative API.

Buzz is a lightweight PHP library for issuing HTTP requests. It is built on top of the PHP curl extension and is designed to be easy to use and flexible.

While buzz isn't as feature rich as other clients it still supports http2 and is relatively easy to use.

Highlights


declarativeproxypopular
http2uses-curl

Example Use


```javascript const superagent = require('superagent'); // superagent supports both Promises and async/await superagent.get('https://httpbin.org/get') .then(res => console.log(res.text)) .catch(err => console.error(err)); const response = superagent.get('https://httpbin.org/get') // post requests: superagent.post('https://httpbin.org/post').send({ name: 'John Doe' }) // setting proxy superagent.get('https://httpbin.org/ip').proxy('http://proxy.example.com:8080') // settings headers and proxies superagent.get('https://httpbin.org/headers').set('Cookie', 'myCookie=123').set('X-My-Header', 'myValue') ```
```php use Buzz\Client\Curl; use Buzz\Message\Request; use Buzz\Message\Response; $client = new Curl(); // GET request $request = new Request('GET', 'http://httpbin.org/get'); $response = new Response(); $client->send($request, $response); echo $response->getContent(); //POST request $request = new Request('POST', '/api/resource', 'http://example.com'); $request->setContent(json_encode(['name' => 'John Doe'])); // we can also add headers or cookies: $request->addHeader('Content-Type: application/json'); $request->addHeader('Cookie: name=foobar'); $response = new Response(); $client->send($request, $response); echo $response->getContent(); // Buzz also supports http2 (see the 2.0 parameter) $response = $client->sendRequest( new Request('GET', 'https://http2.golang.org/serverpush', [], null, '2.0') ); ```

Alternatives / Similar


Was this page helpful?