← All procedures

gh.api

Call the GitHub API and give the parsed JSON. A method other than GET can change or delete data

CLI
Package
@procedures/gh · README
Path
["gh","api"]
CLI
mark gh api --endpoint <string>
As data
{"$proc":["gh","api"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/gh/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["gh","api"], { endpoint: "<endpoint>" });
console.log(JSON.stringify(result));

From the command line

$ mark gh api --endpoint <string>

As data, in a program

{ "$proc": ["gh", "api"], "input": { "endpoint": "<endpoint>" } }

Input

FieldTypeRequiredDefaultDescription
repostringnoThe repository as owner/name (default: the repository of the folder)
cwdstringnoThe folder where gh runs
timeoutMsintegernoThe time limit of the command, in milliseconds
endpointstringyesThe endpoint, for example repos/{owner}/{repo}/pulls or graphql
method"GET" | "POST" | "PUT" | "PATCH" | "DELETE"noThe HTTP method (default GET)
fieldsobjectnoThe parameters: a string goes as -f, another value as -F. GET sends them in the query
bodyanynoA JSON body, sent with --input from a temporary file
paginatebooleannoGet all the pages. The pages of an array become one array

Output

FieldTypeRequiredDefaultDescription
dataanyyesThe parsed JSON of the response (null when it is empty)
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "repo": {
        "description": "The repository as owner/name (default: the repository of the folder)",
        "type": "string",
        "pattern": "^[\\w.-]+\\/[\\w.-]+$"
      },
      "cwd": {
        "description": "The folder where gh runs",
        "type": "string"
      },
      "timeoutMs": {
        "description": "The time limit of the command, in milliseconds",
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "endpoint": {
        "type": "string",
        "minLength": 1,
        "description": "The endpoint, for example repos/{owner}/{repo}/pulls or graphql"
      },
      "method": {
        "description": "The HTTP method (default GET)",
        "type": "string",
        "enum": [
          "GET",
          "POST",
          "PUT",
          "PATCH",
          "DELETE"
        ]
      },
      "fields": {
        "description": "The parameters: a string goes as -f, another value as -F. GET sends them in the query",
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {
          "type": [
            "string",
            "number",
            "boolean",
            "null"
          ]
        }
      },
      "body": {
        "description": "A JSON body, sent with --input from a temporary file"
      },
      "paginate": {
        "description": "Get all the pages. The pages of an array become one array",
        "type": "boolean"
      }
    },
    "required": [
      "endpoint"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "data": {
        "description": "The parsed JSON of the response (null when it is empty)"
      }
    },
    "required": [
      "data"
    ],
    "additionalProperties": false
  }
}