Starting from RhodeCode version 1.2 a simple API was implemented. There’s a single schema for calling all api methods. API is implemented with JSON protocol both ways. An url to send API request in RhodeCode is <your_server>/_admin/api
All clients need to send JSON data in such format:
{
"api_key":"<api_key>",
"method":"<method_name>",
"args":{"<arg_key>":"<arg_val>"}
}
Note
api_key can be found in your user account page
RhodeCode API will return always a JSON formatted answer:
{
"result": "<result>",
"error": null
}
All responses from API will be HTTP/1.0 200 OK, if there’s an error while calling api error key from response will contain failure description and result will be null.
Pulls given repo from remote location. Can be used to automatically keep remote repos up to date. This command can be executed only using api_key belonging to user with admin rights
INPUT:
api_key : "<api_key>"
method : "pull"
args : {
"repo" : "<repo_name>"
}
OUTPUT:
result : "Pulled from <repo_name>"
error : null
Lists all existing users. This command can be executed only using api_key belonging to user with admin rights.
INPUT:
api_key : "<api_key>"
method : "get_users"
args : { }
OUTPUT:
result: [
{
"id" : "<id>",
"username" : "<username>",
"firstname": "<firstname>",
"lastname" : "<lastname>",
"email" : "<email>",
"active" : "<bool>",
"admin" : "<bool>",
"ldap" : "<ldap_dn>"
},
…
]
error: null
Creates new user in RhodeCode. This command can be executed only using api_key belonging to user with admin rights.
INPUT:
api_key : "<api_key>"
method : "create_user"
args : {
"username" : "<username>",
"password" : "<password>",
"firstname" : "<firstname>",
"lastname" : "<lastname>",
"email" : "<useremail>"
"active" : "<bool> = True",
"admin" : "<bool> = False",
"ldap_dn" : "<ldap_dn> = None"
}
OUTPUT:
result: {
"msg" : "created new user <username>"
}
error: null
Lists all existing users groups. This command can be executed only using api_key belonging to user with admin rights.
INPUT:
api_key : "<api_key>"
method : "get_users_groups"
args : { }
OUTPUT:
result : [
{
"id" : "<id>",
"name" : "<name>",
"active": "<bool>",
"members" : [
{
"id" : "<userid>",
"username" : "<username>",
"firstname": "<firstname>",
"lastname" : "<lastname>",
"email" : "<email>",
"active" : "<bool>",
"admin" : "<bool>",
"ldap" : "<ldap_dn>"
},
…
]
}
]
error : null
Gets an existing users group. This command can be executed only using api_key belonging to user with admin rights.
INPUT:
api_key : "<api_key>"
method : "get_users_group"
args : {
"group_name" : "<name>"
}
OUTPUT:
result : None if group not exist
{
"id" : "<id>",
"name" : "<name>",
"active": "<bool>",
"members" : [
{ "id" : "<userid>",
"username" : "<username>",
"firstname": "<firstname>",
"lastname" : "<lastname>",
"email" : "<email>",
"active" : "<bool>",
"admin" : "<bool>",
"ldap" : "<ldap_dn>"
},
…
]
}
error : null
Creates new users group. This command can be executed only using api_key belonging to user with admin rights
INPUT:
api_key : "<api_key>"
method : "create_users_group"
args: {
"name": "<name>",
"active":"<bool> = True"
}
OUTPUT:
result: {
"id": "<newusersgroupid>",
"msg": "created new users group <name>"
}
error: null
Adds a user to a users group. This command can be executed only using api_key belonging to user with admin rights
INPUT:
api_key : "<api_key>"
method : "add_user_users_group"
args: {
"group_name" : "<groupname>",
"user_name" : "<username>"
}
OUTPUT:
result: {
"id": "<newusersgroupmemberid>",
"msg": "created new users group member"
}
error: null
Lists all existing repositories. This command can be executed only using api_key belonging to user with admin rights
INPUT:
api_key : "<api_key>"
method : "get_repos"
args: { }
OUTPUT:
result: [
{
"id" : "<id>",
"name" : "<name>"
"type" : "<type>",
"description" : "<description>"
},
…
]
error: null
Gets an existing repository. This command can be executed only using api_key belonging to user with admin rights
INPUT:
api_key : "<api_key>"
method : "get_repo"
args: {
"name" : "<name>"
}
OUTPUT:
result: None if repository not exist
{
"id" : "<id>",
"name" : "<name>"
"type" : "<type>",
"description" : "<description>",
"members" : [
{ "id" : "<userid>",
"username" : "<username>",
"firstname": "<firstname>",
"lastname" : "<lastname>",
"email" : "<email>",
"active" : "<bool>",
"admin" : "<bool>",
"ldap" : "<ldap_dn>",
"permission" : "repository_(read|write|admin)"
},
…
{
"id" : "<usersgroupid>",
"name" : "<usersgroupname>",
"active": "<bool>",
"permission" : "repository_(read|write|admin)"
},
…
]
}
error: null
Creates a repository. This command can be executed only using api_key belonging to user with admin rights. If repository name contains “/”, all needed repository groups will be created. For example “foo/bar/baz” will create groups “foo”, “bar” (with “foo” as parent), and create “baz” repository with “bar” as group.
INPUT:
api_key : "<api_key>"
method : "create_repo"
args: {
"name" : "<name>",
"owner_name" : "<ownername>",
"description" : "<description> = ''",
"repo_type" : "<type> = 'hg'",
"private" : "<bool> = False"
}
OUTPUT:
result: None
error: null
Add a user to a repository. This command can be executed only using api_key belonging to user with admin rights. If “perm” is None, user will be removed from the repository.
INPUT:
api_key : "<api_key>"
method : "add_user_to_repo"
args: {
"repo_name" : "<reponame>",
"user_name" : "<username>",
"perm" : "(None|repository_(read|write|admin))",
}
OUTPUT:
result: None
error: null