1. Packages
  2. Packages
  3. Github Provider
  4. API Docs
  5. getRestApi
Viewing docs for GitHub v5.26.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
github logo
Viewing docs for GitHub v5.26.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi

    Use this data source to retrieve information about a GitHub resource through REST API.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Github = Pulumi.Github;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Github.GetRestApi.Invoke(new()
        {
            Endpoint = "repos/example_repo/git/refs/heads/main",
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-github/sdk/v5/go/github"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := github.GetRestApi(ctx, &github.GetRestApiArgs{
    			Endpoint: "repos/example_repo/git/refs/heads/main",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.github.GithubFunctions;
    import com.pulumi.github.inputs.GetRestApiArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var example = GithubFunctions.getRestApi(GetRestApiArgs.builder()
                .endpoint("repos/example_repo/git/refs/heads/main")
                .build());
    
        }
    }
    
    import * as pulumi from "@pulumi/pulumi";
    import * as github from "@pulumi/github";
    
    const example = github.getRestApi({
        endpoint: "repos/example_repo/git/refs/heads/main",
    });
    
    import pulumi
    import pulumi_github as github
    
    example = github.get_rest_api(endpoint="repos/example_repo/git/refs/heads/main")
    
    variables:
      example:
        fn::invoke:
          Function: github:getRestApi
          Arguments:
            endpoint: repos/example_repo/git/refs/heads/main
    

    Using getRestApi

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getRestApi(args: GetRestApiArgs, opts?: InvokeOptions): Promise<GetRestApiResult>
    function getRestApiOutput(args: GetRestApiOutputArgs, opts?: InvokeOptions): Output<GetRestApiResult>
    def get_rest_api(endpoint: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetRestApiResult
    def get_rest_api_output(endpoint: Optional[pulumi.Input[str]] = None,
                     opts: Optional[InvokeOptions] = None) -> Output[GetRestApiResult]
    func GetRestApi(ctx *Context, args *GetRestApiArgs, opts ...InvokeOption) (*GetRestApiResult, error)
    func GetRestApiOutput(ctx *Context, args *GetRestApiOutputArgs, opts ...InvokeOption) GetRestApiResultOutput

    > Note: This function is named GetRestApi in the Go SDK.

    public static class GetRestApi 
    {
        public static Task<GetRestApiResult> InvokeAsync(GetRestApiArgs args, InvokeOptions? opts = null)
        public static Output<GetRestApiResult> Invoke(GetRestApiInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetRestApiResult> getRestApi(GetRestApiArgs args, InvokeOptions options)
    public static Output<GetRestApiResult> getRestApi(GetRestApiArgs args, InvokeOptions options)
    
    fn::invoke:
      function: github:index/getRestApi:getRestApi
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Endpoint string
    REST API endpoint to send the GET request to.
    Endpoint string
    REST API endpoint to send the GET request to.
    endpoint String
    REST API endpoint to send the GET request to.
    endpoint string
    REST API endpoint to send the GET request to.
    endpoint str
    REST API endpoint to send the GET request to.
    endpoint String
    REST API endpoint to send the GET request to.

    getRestApi Result

    The following output properties are available:

    Body Dictionary<string, object>
    A map of response body.
    Code int
    A response status code.
    Endpoint string
    Headers Dictionary<string, object>
    A map of response headers.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    A response status string.
    Body map[string]interface{}
    A map of response body.
    Code int
    A response status code.
    Endpoint string
    Headers map[string]interface{}
    A map of response headers.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    A response status string.
    body Map<String,Object>
    A map of response body.
    code Integer
    A response status code.
    endpoint String
    headers Map<String,Object>
    A map of response headers.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    A response status string.
    body {[key: string]: any}
    A map of response body.
    code number
    A response status code.
    endpoint string
    headers {[key: string]: any}
    A map of response headers.
    id string
    The provider-assigned unique ID for this managed resource.
    status string
    A response status string.
    body Mapping[str, Any]
    A map of response body.
    code int
    A response status code.
    endpoint str
    headers Mapping[str, Any]
    A map of response headers.
    id str
    The provider-assigned unique ID for this managed resource.
    status str
    A response status string.
    body Map<Any>
    A map of response body.
    code Number
    A response status code.
    endpoint String
    headers Map<Any>
    A map of response headers.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    A response status string.

    Package Details

    Repository
    GitHub pulumi/pulumi-github
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the github Terraform Provider.
    github logo
    Viewing docs for GitHub v5.26.0 (Older version)
    published on Monday, Mar 9, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.