GitHub Blobs API

The Blobs API from GitHub — 2 operation(s) for blobs.

Documentation

📖
Documentation
https://docs.github.com/en/rest/apps
📖
Documentation
https://docs.github.com/en/rest/codes-of-conduct/codes-of-conduct
📖
Documentation
https://docs.github.com/en/rest/emojis
📖
Documentation
https://docs.github.com/en/rest/gitignore
📖
Documentation
https://docs.github.com/en/rest/apps/installations
📖
Documentation
https://docs.github.com/en/rest/enterprise-admin
📖
Documentation
https://docs.github.com/en/rest/activity/events
📖
Documentation
https://docs.github.com/en/rest/orgs
📖
Documentation
https://docs.github.com/en/rest/rate-limit
📖
Documentation
https://docs.github.com/en/enterprise-cloud@latest/rest/scim
📖
Documentation
https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api
📖
Documentation
https://docs.github.com/en/rest/teams
📖
Documentation
https://docs.github.com/en/rest/meta/meta
📖
Documentation
https://docs.github.com/en/rest/actions
📖
Documentation
https://docs.github.com/en/rest/branches
📖
Documentation
https://docs.github.com/en/rest/code-scanning
📖
Documentation
https://docs.github.com/en/rest/collaborators
📖
Documentation
https://docs.github.com/en/rest/dependabot
📖
Documentation
https://docs.github.com/en/rest/webhooks
📖
Documentation
https://docs.github.com/en/rest/pulls
📖
Documentation
https://docs.github.com/en/rest/git/tags
📖
Documentation
https://docs.github.com/en/rest/repos/autolinks
📖
Documentation
https://docs.github.com/en/rest/collaborators/invitations

Specifications

Other Resources

OpenAPI Specification

github-blobs-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  version: 1.1.4
  title: github-repos-api Blobs API
  description: 'Use the REST API to create, manage and control the workflow of public and

    private GitHub repositories.'
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
  termsOfService: https://docs.github.com/articles/github-terms-of-service
  contact:
    name: Support
    url: https://support.github.com/contact
servers:
- url: '{protocol}://{hostname}'
  variables:
    hostname:
      description: Self-hosted Enterprise Server hostname
      default: api.github.com
    protocol:
      description: Self-hosted Enterprise Server protocol
      default: https
tags:
- name: Blobs
paths:
  /repos/{owner}/{repo}/git/blobs:
    post:
      summary: GitHub Create Blob
      description: The Create Blob operation in the GitHub Repos API allows you to create a new blob object in a repository's Git database by sending a POST request to /repos/{owner}/{repo}/git/blobs. A blob (binary large object) represents the content of a file in Git's object database without any metadata like filename or directory structure. You must provide the file content and encoding type (typically "utf-8" or "base64") in the request body, and upon successful creation, the API returns the SHA-1 hash of the newly created blob which can then be referenced when creating trees and commits. This is a low-level Git operation typically used when programmatically building commits or when you need fine-grained control over Git objects in a repository.
      tags:
      - Blobs
      operationId: createBlob
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/git/blobs#create-a-blob
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                content:
                  type: string
                  description: The new blob's content.
                encoding:
                  type: string
                  description: The encoding used for `content`. Currently, `"utf-8"` and `"base64"` are supported.
                  default: utf-8
              required:
              - content
            examples:
              default:
                value:
                  content: Content of the blob
                  encoding: utf-8
      responses:
        '201':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/short-blob'
              examples:
                default:
                  $ref: '#/components/examples/short-blob'
          headers:
            Location:
              example: https://api.github.com/repos/octocat/example/git/blobs/3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15
              schema:
                type: string
        '403':
          $ref: '#/components/responses/forbidden'
        '404':
          $ref: '#/components/responses/not_found'
        '409':
          $ref: '#/components/responses/conflict'
        '422':
          $ref: '#/components/responses/validation_failed'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: git
        subcategory: blobs
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /repos/{owner}/{repo}/git/blobs/{file_sha}:
    get:
      summary: GitHub Get Blob
      description: 'The `content` in the response will always be Base64 encoded.


        This endpoint supports the following custom media types. For more information, see "[Media types](https://docs.github.com/enterprise-server@3.9/rest/using-the-rest-api/getting-started-with-the-rest-api#media-types)."


        - **`application/vnd.github.raw+json`**: Returns the raw blob data.

        - **`application/vnd.github+json`**: Returns a JSON representation of the blob with `content` as a base64 encoded string. This is the default if no media type is specified.


        **Note** This endpoint supports blobs up to 100 megabytes in size.'
      tags:
      - Blobs
      operationId: getBlob
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/git/blobs#get-a-blob
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      - name: file_sha
        in: path
        required: true
        schema:
          type: string
        example: abc123def456789012345678901234567890
      - in: header
        name: Authorization
        schema:
          type: string
        example: example_value
      - in: header
        name: X-GitHub-Api-Version
        schema:
          type: string
          default: '2022-11-28'
        example: example_value
      - in: header
        name: Accept
        schema:
          type: string
          default: application/vnd.github+json
        example: example_value
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/blob'
              examples:
                default:
                  $ref: '#/components/examples/blob'
        '403':
          $ref: '#/components/responses/forbidden'
        '404':
          $ref: '#/components/responses/not_found'
        '422':
          $ref: '#/components/responses/validation_failed'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: git
        subcategory: blobs
      security:
      - bearerHttpAuthentication: []
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
components:
  responses:
    forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/basic-error'
    conflict:
      description: Conflict
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/basic-error'
    validation_failed:
      description: Validation failed, or the endpoint has been spammed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/validation-error'
    not_found:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/basic-error'
  schemas:
    blob:
      title: Blob
      description: Blob
      type: object
      properties:
        content:
          type: string
          example: example_value
        encoding:
          type: string
          example: example_value
        url:
          type: string
          format: uri
          example: https://api.github.com/repos/octocat/Hello-World
        sha:
          type: string
          example: abc123def456789012345678901234567890
        size:
          type: integer
          example: 42
        node_id:
          type: string
          example: '12345678'
        highlighted_content:
          type: string
          example: example_value
      required:
      - sha
      - url
      - node_id
      - size
      - content
      - encoding
    validation-error:
      title: Validation Error
      description: Validation Error
      type: object
      required:
      - message
      - documentation_url
      properties:
        message:
          type: string
          example: Example body text
        documentation_url:
          type: string
          example: https://api.github.com/repos/octocat/Hello-World
        errors:
          type: array
          items:
            type: object
            required:
            - code
            properties:
              resource:
                type: string
              field:
                type: string
              message:
                type: string
              code:
                type: string
              index:
                type: integer
              value:
                oneOf:
                - type: string
                - type: integer
                - type: array
                  items:
                    type: string
    basic-error:
      title: Basic Error
      description: Basic Error
      type: object
      properties:
        message:
          type: string
          example: Example body text
        documentation_url:
          type: string
          example: https://api.github.com/repos/octocat/Hello-World
        url:
          type: string
          example: https://api.github.com/repos/octocat/Hello-World
        status:
          type: string
          example: open
    short-blob:
      title: Short Blob
      description: Short Blob
      type: object
      properties:
        url:
          type: string
          example: https://api.github.com/repos/octocat/Hello-World
        sha:
          type: string
          example: abc123def456789012345678901234567890
      required:
      - url
      - sha
  examples:
    short-blob:
      value:
        url: https://api.github.com/repos/octocat/example/git/blobs/3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15
        sha: 3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15
    blob:
      value:
        content: Q29udGVudCBvZiB0aGUgYmxvYg==
        encoding: base64
        url: https://api.github.com/repos/octocat/example/git/blobs/3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15
        sha: 3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15
        size: 19
        node_id: Q29udGVudCBvZiB0aGUgYmxvYg==
  parameters:
    owner:
      name: owner
      description: The account owner of the repository. The name is not case sensitive.
      in: path
      required: true
      schema:
        type: string
    repo:
      name: repo
      description: The name of the repository without the `.git` extension. The name is not case sensitive.
      in: path
      required: true
      schema:
        type: string
  securitySchemes:
    bearerHttpAuthentication:
      description: Bearer Token
      type: http
      scheme: Bearer
externalDocs:
  description: GitHub Enterprise Developer Docs
  url: https://docs.github.com/enterprise-server@3.9/rest/