0

I can browse the public snippets of a project without authenticating, for example: https://gitlab.com/Boiethios/someproject/snippets.

I thus expect to access this information through a public API. However, the V4 API does not allow to do so: GET https://gitlab.com/api/v4/projects/6165269/snippets returns a 401.

How can I do that?

Boiethios
  • 38,438
  • 19
  • 134
  • 183

1 Answers1

0

The newest gitlab API uses GraphQL.

To get the snippets of a project, the following request can do the job:

query {
  project(fullPath: "username_or_group/projectname") {
    snippets {
      nodes {
        fileName,
        title,
        blob {
          rawPath
        }
        # You can query some other fields you want
      }
    }
  }
}

The request can be tested here.

The request must be posted as a body to the url: https://gitlab.com/api/graphql.

Boiethios
  • 38,438
  • 19
  • 134
  • 183