# GitLab Integration via LowCodeAPI

## Overview

GitLab is a complete DevOps platform with 288+ API endpoints for managing repositories, CI/CD pipelines, issues, merge requests, users, groups, and more. Automate your development workflows, manage projects, and integrate with your DevOps toolchain.

## Base Endpoint

```
https://api.lowcodeapi.com/gitlab/
```

## Authentication

LowCodeAPI handles authentication automatically. You only need to:

1. **Sign up** at [GitLab](https://gitlab.com)
2. **Create a Personal Access Token** from user settings
3. **Connect your account** in LowCodeAPI dashboard
4. **Use your `api_token`** in all requests

The `api_token` is your LowCodeAPI authentication token. LowCodeAPI will automatically:
- Fetch your GitLab access token from the database
- Apply it as a Bearer token to each request

**Auth Type**: Personal Access Token (Bearer)

**Credential Link**: [https://gitlab.com/-/user_settings/personal_access_tokens](https://gitlab.com/-/user_settings/personal_access_tokens)

## API Categories

- **File Sharing & Collaboration** - Code repositories, version control, and collaboration tools

## Common Endpoints

### Category: Projects

#### List Projects

**Method**: `GET` | **LowCodeAPI Path**: `/v4/projects`

**Full URL**:
```
https://api.lowcodeapi.com/gitlab/v4/projects?api_token={api_token}
```

**Description**: Get a list of projects visible to the authenticated user

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `page` | string | No | Page number |
| `per_page` | string | No | Number of results per page |
| `search` | string | No | Search query |
| `order_by` | string | No | Order by field (id, name, created_at) |
| `sort` | string | No | Sort direction (asc, desc) |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/gitlab/v4/projects?per_page=20&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [https://docs.gitlab.com/api/projects.html#list-all-projects](https://docs.gitlab.com/api/projects.html#list-all-projects)

---

#### Get Project

**Method**: `GET` | **LowCodeAPI Path**: `/v4/projects/id`

**Full URL**:
```
https://api.lowcodeapi.com/gitlab/v4/projects/id?id={id}&api_token={api_token}
```

**Description**: Get a specific project details

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `id` | string | Yes | The ID or URL-encoded path of the project |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/gitlab/v4/projects/id?id=123&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [https://docs.gitlab.com/api/projects.html#get-single-project](https://docs.gitlab.com/api/projects.html#get-single-project)

---

#### Create Project

**Method**: `POST` | **LowCodeAPI Path**: `/v4/projects`

**Full URL**:
```
https://api.lowcodeapi.com/gitlab/v4/projects?api_token={api_token}
```

**Description**: Creates a new project owned by the authenticated user

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `name` | string | Yes | Project name |
| `description` | string | No | Project description |
| `visibility` | string | No | Visibility level (private, internal, public) |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/gitlab/v4/projects?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-new-project",
    "description": "A new GitLab project",
    "visibility": "private"
  }'
```

**Official Documentation**: [https://docs.gitlab.com/api/projects.html#create-project](https://docs.gitlab.com/api/projects.html#create-project)

---

### Category: Issues

#### List Issues

**Method**: `GET` | **LowCodeAPI Path**: `/v4/issues`

**Full URL**:
```
https://api.lowcodeapi.com/gitlab/v4/issues?api_token={api_token}
```

**Description**: Get a list of issues

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `page` | string | No | Page number |
| `per_page` | string | No | Results per page |
| `state` | string | No | Filter by state (opened, closed, all) |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/gitlab/v4/issues?state=opened&per_page=20&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [https://docs.gitlab.com/api/issues.html#list-issues](https://docs.gitlab.com/api/issues.html#list-issues)

---

#### Create Issue

**Method**: `POST` | **LowCodeAPI Path**: `/v4/projects/id/issues`

**Full URL**:
```
https://api.lowcodeapi.com/gitlab/v4/projects/id/issues?id={id}&api_token={api_token}
```

**Description**: Creates a new project issue

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `id` | string | Yes | The ID or URL-encoded path of the project |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `title` | string | Yes | The title of an issue |
| `description` | string | No | The description of an issue |
| `labels` | string | No | Comma-separated label names |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/gitlab/v4/projects/id/issues?id=123&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Bug: Application crashes",
    "description": "Detailed bug description",
    "labels": "bug,critical"
  }'
```

**Official Documentation**: [https://docs.gitlab.com/api/issues.html#create-new-issue](https://docs.gitlab.com/api/issues.html#create-new-issue)

---

### Category: Merge Requests

#### List Merge Requests

**Method**: `GET` | **LowCodeAPI Path**: `/v4/merge_requests`

**Full URL**:
```
https://api.lowcodeapi.com/gitlab/v4/merge_requests?api_token={api_token}
```

**Description**: List all merge requests

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `page` | string | No | Page number |
| `per_page` | string | No | Results per page |
| `state` | string | No | Filter by state (opened, closed, merged, all) |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/gitlab/v4/merge_requests?state=opened&per_page=20&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [https://docs.gitlab.com/api/merge_requests.html#list-merge-requests](https://docs.gitlab.com/api/merge_requests.html#list-merge-requests)

---

#### Create Merge Request

**Method**: `POST` | **LowCodeAPI Path**: `/v4/projects/id/merge_requests`

**Full URL**:
```
https://api.lowcodeapi.com/gitlab/v4/projects/id/merge_requests?id={id}&api_token={api_token}
```

**Description**: Creates a new merge request

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `id` | string | Yes | The ID or URL-encoded path of the project |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `source_branch` | string | Yes | Source branch |
| `target_branch` | string | Yes | Target branch |
| `title` | string | Yes | Title of MR |
| `description` | string | No | Description of MR |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/gitlab/v4/projects/id/merge_requests?id=123&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "source_branch": "feature-branch",
    "target_branch": "main",
    "title": "Add new feature",
    "description": "Implements the requested feature"
  }'
```

**Official Documentation**: [https://docs.gitlab.com/api/merge_requests.html#create-mr](https://docs.gitlab.com/api/merge_requests.html#create-mr)

---

### Category: Pipelines

#### List Pipelines

**Method**: `GET` | **LowCodeAPI Path**: `/v4/projects/id/pipelines`

**Full URL**:
```
https://api.lowcodeapi.com/gitlab/v4/projects/id/pipelines?id={id}&api_token={api_token}
```

**Description**: Get a list of pipelines in a project

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `id` | string | Yes | The ID or URL-encoded path of the project |
| `page` | string | No | Page number |
| `per_page` | string | No | Results per page |
| `status` | string | No | Filter by status |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/gitlab/v4/projects/id/pipelines?id=123&per_page=10&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: [https://docs.gitlab.com/api/pipelines.html#list-project-pipelines](https://docs.gitlab.com/api/pipelines.html#list-project-pipelines)

---

## Usage Examples

### Example 1: Project Management

This example demonstrates managing GitLab projects:

```bash
# Step 1: List all projects you have access to
# No ID required - lists all accessible projects
curl -X GET "https://api.lowcodeapi.com/gitlab/v4/projects?per_page=20&api_token=YOUR_API_TOKEN"

# Step 2: Create a new project
# No ID required - creates a new project and returns project details
curl -X POST "https://api.lowcodeapi.com/gitlab/v4/projects?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-gitlab-project",
    "description": "Built with LowCodeAPI",
    "visibility": "private"
  }'

# Step 3: Get specific project details
# Replace PROJECT_ID with the actual project ID from previous steps
curl -X GET "https://api.lowcodeapi.com/gitlab/v4/projects/id?id=PROJECT_ID&api_token=YOUR_API_TOKEN"
```

### Example 2: Issues and Merge Requests

This example shows working with issues and MRs:

```bash
# Step 1: List open issues
# No ID required - lists all issues across accessible projects
curl -X GET "https://api.lowcodeapi.com/gitlab/v4/issues?state=opened&per_page=10&api_token=YOUR_API_TOKEN"

# Step 2: Create a new issue in a project
# Replace PROJECT_ID with the actual project ID
curl -X POST "https://api.lowcodeapi.com/gitlab/v4/projects/id/issues?id=PROJECT_ID&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Feature request: Dark mode",
    "description": "Add dark mode support to the application",
    "labels": "enhancement,ui"
  }'

# Step 3: List merge requests
# No ID required - lists all MRs across accessible projects
curl -X GET "https://api.lowcodeapi.com/gitlab/v4/merge_requests?state=opened&api_token=YOUR_API_TOKEN"

# Step 4: Create a merge request
# Replace PROJECT_ID with the actual project ID
curl -X POST "https://api.lowcodeapi.com/gitlab/v4/projects/id/merge_requests?id=PROJECT_ID&api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "source_branch": "feature-dark-mode",
    "target_branch": "main",
    "title": "Implement dark mode",
    "description": "Adds dark mode support"
  }'
```

### Example 3: CI/CD Pipeline Management

```bash
# Step 1: List pipelines for a project
# Replace PROJECT_ID with the actual project ID
curl -X GET "https://api.lowcodeapi.com/gitlab/v4/projects/id/pipelines?id=PROJECT_ID&per_page=10&api_token=YOUR_API_TOKEN"

# Step 2: Trigger a new pipeline
# Replace PROJECT_ID and REF with actual values
curl -X POST "https://api.lowcodeapi.com/gitlab/v4/projects/id/pipeline?id=PROJECT_ID&ref=main&api_token=YOUR_API_TOKEN"
```

## Complete Endpoint Reference

For a complete list of all endpoints and their parameters, refer to:
- **OpenAPI Definition**: `https://backend.lowcodeapi.com/gitlab/definition`
- **Official Provider Documentation**: [https://docs.gitlab.com/api/](https://docs.gitlab.com/api/)

## Rate Limits & Best Practices

- **Rate limits**: Based on user tier and plan
- **Best practice**: Use pagination for large result sets
- **Best practice**: Use specific queries to reduce data transfer
- **Best practice**: Cache project and user data

## Error Handling

Standard HTTP status codes apply