Socket
Socket
Sign inDemoInstall

@algolia/transporter

Package Overview
Dependencies
Maintainers
3
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/transporter

Promise-based transporter layer with embedded retry strategy.


Version published
Weekly downloads
1.5M
decreased by-0.78%
Maintainers
3
Created
Weekly downloads
 

Package description

What is @algolia/transporter?

@algolia/transporter is a low-level HTTP client for making requests to Algolia's API. It provides a set of utilities to handle retries, timeouts, and other network-related concerns, making it easier to interact with Algolia's services.

What are @algolia/transporter's main functionalities?

Basic Request

This code demonstrates how to create a basic transporter instance and make a GET request to list all indexes in an Algolia application.

const { createTransporter } = require('@algolia/transporter');

const transporter = createTransporter({
  hosts: [{ url: 'https://your-algolia-instance.algolia.net' }],
  headers: { 'X-Algolia-API-Key': 'your-api-key', 'X-Algolia-Application-Id': 'your-app-id' }
});

transporter.read({ method: 'GET', path: '/1/indexes' }).then(response => {
  console.log(response);
});

Handling Retries

This code shows how to configure the transporter to handle retries with specific timeout settings and retry policies.

const { createTransporter } = require('@algolia/transporter');

const transporter = createTransporter({
  hosts: [{ url: 'https://your-algolia-instance.algolia.net' }],
  headers: { 'X-Algolia-API-Key': 'your-api-key', 'X-Algolia-Application-Id': 'your-app-id' },
  timeouts: { connect: 1, read: 2, write: 30 },
  retry: { maxRetries: 3, delay: 1000 }
});

transporter.read({ method: 'GET', path: '/1/indexes' }).then(response => {
  console.log(response);
});

Custom Headers

This example demonstrates how to add custom headers to the transporter instance for making requests.

const { createTransporter } = require('@algolia/transporter');

const transporter = createTransporter({
  hosts: [{ url: 'https://your-algolia-instance.algolia.net' }],
  headers: { 'X-Algolia-API-Key': 'your-api-key', 'X-Algolia-Application-Id': 'your-app-id', 'Custom-Header': 'custom-value' }
});

transporter.read({ method: 'GET', path: '/1/indexes' }).then(response => {
  console.log(response);
});

Other packages similar to @algolia/transporter

Changelog

Source

v4.21.1

  • fix(recommend): RecommendedForYouQuery userToken should be required (#1496) (d20b253), closes #1496

FAQs

Package last updated on 12 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc