Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@octokit/endpoint

Package Overview
Dependencies
Maintainers
4
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit/endpoint

Turns REST API endpoints into generic request options

  • 10.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11M
increased by3.68%
Maintainers
4
Weekly downloads
 
Created

What is @octokit/endpoint?

The @octokit/endpoint npm package is designed to convert GitHub API endpoint options into the URL and headers format that the GitHub REST API expects. It's part of the Octokit suite of libraries which are used to interact with the GitHub API in a more convenient and structured way. This package is particularly useful for developers who need to make custom requests to the GitHub API beyond what higher-level Octokit libraries provide, allowing for detailed control over the request parameters and headers.

What are @octokit/endpoint's main functionalities?

Creating a custom GitHub REST API endpoint

This code sample demonstrates how to create a custom endpoint for fetching issues from a GitHub repository. You specify the HTTP method, the URL pattern, and any necessary headers. The `owner` and `repo` parameters are used to fill in the URL pattern.

{
  "method": "GET",
  "url": "/repos/{owner}/{repo}/issues",
  "headers": {
    "accept": "application/vnd.github.v3+json"
  },
  "owner": "octokit",
  "repo": "endpoint.js"
}

Converting endpoint options to request URL and headers

This example shows how to use the @octokit/endpoint package to convert endpoint options into a format that can be used to make an HTTP request. It includes the method, URL, headers, and other parameters like `title` for the body of the request.

const { endpoint } = require('@octokit/endpoint');
const options = endpoint({
  method: 'POST',
  url: '/repos/{owner}/{repo}/issues',
  headers: {
    accept: 'application/vnd.github.v3+json'
  },
  owner: 'octokit',
  repo: 'endpoint.js',
  title: 'New issue title'
});
console.log(options); // Logs the URL and headers object ready for the request

Other packages similar to @octokit/endpoint

Keywords

FAQs

Package last updated on 16 Apr 2024

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc