GitCode REST API
The GitCode API offers powerful features, enabling developers to interact programmatically with resources on GitCode. This documentation will guide you on how to use the GitCode API, covering topics such as making effective API requests, authentication methods, status codes, pagination, path parameters, and more.
Effective API Requests
To make a request to the GitCode API, you must include the api path
and specify the API version. The current available version is
/api/v5.
Here is a basic example of making a request to the GitCode API:
curl "https://api.gitcode.com/api/v5/users/{username}"
Authentication
Most GitCode API requests require authentication, or they will only return public data if no authentication is provided. The documentation for each endpoint will specify whether authentication is required.
You can authenticate to the GitCode API using a Personal Access Token .
If the authentication information is invalid or missing, GitCode will return an error with the status code 401:
{
"message": "401 Unauthorized"
}
PRIVATE-TOKEN
You can authenticate by passing your Personal Access Token in the
PRIVATE-TOKEN header.
Example of the Personal Access Token in the Request Header:
curl --location 'https://api.gitcode.com/api/v5/user' \
--header 'PRIVATE-TOKEN: {your-token}'
access_token
You can authenticate by passing your Personal Access Token in the
access_token query parameter.
Example of the Personal Access Token in the Query:
curl "https://api.gitcode.com/api/v5/users/{username}?access_token={your-token}"
Response Codes
The GitCode API returns different status codes based on the context and operation. This helps you understand what went wrong if a request results in an error.
The following table outlines the general behavior of the GitCode API functions:
Request Type |
Description |
|---|---|
|
Access one or more resources and return the result in JSON format |
|
If the resource is successfully created, returns
|
|
If the resource is successfully accessed or
modified, returns |
|
If the resource is successfully deleted, returns
|
Here are the possible return codes for GitCode API requests:
Response Code |
Description |
|---|---|
|
The |
|
The |
|
The |
|
The server successfully fulfilled the request, but no additional content is sent in the response body |
|
The resource has been moved to a new
URL provided in the |
|
The resource has not been modified since the last request |
|
A required attribute for the API request is missing. For example, the title of an issue is not provided |
|
The user is unauthenticated. A valid user token is required |
|
The request is not allowed. For example, the user is not authorized to delete a project |
|
The resource cannot be accessed. For example, the resource ID cannot be found or the user does not have access to it |
|
The request method is not supported |
|
A conflicting resource already exists. For example, creating a project with an existing name |
|
The request was rejected. This can
occur when trying to delete a resource
that has been modified during the
process, if the
|
|
Request Rejected, Suspected Unsafe |
|
The entity cannot be processed |
|
The user has exceeded the rate limit for the application |
|
The server encountered an error while processing the request |
|
The server cannot handle the request because it is temporarily overloaded |
|
Gateway Timeout: Network Timeout |