Gogs: REST API

Created on 25 Sep 2015  Â·  50Comments  Â·  Source: gogs/gogs

Currently, the REST API exposed by Gogs, at /api/v1/, is limited. Please provide CRUD (Create, Read, Update, and Delete) methods to manipulate the following models:

  • [x] User
  • [ ] Org
  • [ ] Repo
  • ?Access

Thank you so much in advance!

⛔ do not send pull request 🎯 feature

Most helpful comment

All 50 comments

When do you think to release 0.7.0 ?

@matrixise fairly a long time from now...

i am very interested on these options, basically create users and repos by Rest API, for if more comments on this issue sums more points to make this changes :)

This would be really useful.

+1 thank you

Definitely would be a huge benefit to have the administrative parts of the v3. I'm working on getting a lot of teams migrated to using gogs, and away from old-school manual git on file-system.

+1

Is the current rest api documented anywhere?

+1

These are the apis that we currently need. (we use phantomjs to script the gogs, but if its available as api it would be cool)

all apis are done by admin (using api token)

  • [-] add auth source (we use pam)
  • [x] create user under the auth source
  • [x] add ssh key to user
  • [x] create org
  • [x] create repo under the org (I believe this is already there)
  • [x] create team under the org
  • [x] add user to team
  • [x] remove user from team
  • [x] add repo to team
  • [x] remove repo from team

This one is for easy config manage gogs from ansible.

  • api for /install (we config manage app.ini so most of the fields shown in /install page is from app.ini except admin user name & password)

Are plan to implement issues management routes?

@rogeriolino Those should come with https://github.com/gogits/gogs/issues/809

Thanks for reply me @Unknwon

This migration will include issues API too?

I'm already using Gogs in my work and I'm intending to code a frontend that integrate to gogs issues via API. Providing to my app users a way to report bugs without create a account into Gogs.

Regards.

@renatoaquino

This migration will include issues API too?

I'm planning do migration with APIs, that's more flexible.

I'm already using Gogs in my work and I'm intending to code a frontend that integrate to gogs issues via API. Providing to my app users a way to report bugs without create a account into Gogs.

Though you still need an account to call APIs, just make sure you know this...

@Unknwon

Though you still need an account to call APIs, just make sure you know this...

Right. Internally I'll use an account to do it (make API requests).

@kernel164 https://github.com/gogits/go-gogs-client/wiki/Administration-Users

BTW, I'll try to make an other mirror update release before 0.8, other org-related APIs need to wait until 0.8.x releases. :sweat:

Thank you.

I was proposing gogs instead of gitlab. The only issue that blocks my proposal is gogs missing API support. Hmm.... These api's are high priority for me.

  • create org
  • create team under the org
  • add user to team
  • add repo to team

all api are admin api.

@kernel164 working on that. Note that checklist was already made in your previous comment, commenting duplicated things cause big confusion.

Support of some parts of GitHub API would be nice: https://developer.github.com/v3/
Particularly Commits API: https://developer.github.com/v3/repos/commits/ is useful.

Cool. Thanks.

@kernel164 rest of your requests hopefully can be done before next minor release on this Saturday.

Are these api's "create team under the org, add user to team, add repo to team" planned for next release.

Are these api's "create team under the org, add user to team, add repo to team" planned for next release.

Depends on how much time I get...

Any update on creating issues via API? I'm in the same boat as @rogeriolino. I need an interface for my users to create issues.

@Unknwon This commit mentioned above causes develop branch to not be able to compile:

routers/api/v1/convert/convert.go:200: undefined: gogs.Team
routers/api/v1/convert/convert.go:201: undefined: gogs.Team

@richmahn
you probably haven't pulled in all changes.

git pull --all
go get -u ./...
go build

Ah, right, keep forgetting the go get -u. Sorry about that. Thanks for your help.

@Unknwon i'd like to contribute to issues API implementation, is someone working on it? (I know you have implemented basic issues API functionalities.)

From https://github.com/gogits/go-gogs-client/wiki, there are four things to implement:

  1. assignees

    • from the code, it already implemented in create, edit, and get

    • do we need to list all assignees of a repo's issue? i don't think so

    • any other things to implement?

  2. comments
    still not implemented at all, APIs to implement:

    • GET /api/v1/repos/:username/:reponame/issues/:index/comments to get all comments of an issue

    • POST /api/v1/repos/:username/:reponame/issues/:index/comments to create comment

    • PATCH /api/v1/repos/:username/:reponame/issues/:index/comments to edit comment

  3. labels

    • already implemented in create and get an issue

    • need to implement in edit an issue

    • need POST, GET, and PATCH /api/v1/repos/:username/:reponame/labels to create, get, and edit labels of a repo's issue

  4. milestones

    • already implemented in create, edit, and get an issue

    • need POST, GET, and PATCH /api/v1/repos/:username/:reponame/milestones to create, get, and edit milestones of a repo's issue

I'd like to implement all above points, but i think it is better to start small, implementing a point first. If you are OK then we can continue to other points.

I think comments API is a good start, what do you think?

@iwanbk

I think comments API is a good start, what do you think?

Yes, I think so too.

What about pull requests?

What about pull requests?

@yurivict eventually...

@yurivict @Unknwon
PRs submitted:

I would like to assist with this as well.

I started working on extra labels support before I saw @iwanbk's list, so hopefully my work is not overlapping.

@Unknwon i will work on issue's assignee support, it seems there is no one working on it.

@iwanbk isn't API already supports issue assignee?

@iwanbk isn't API already supports issue assignee?

Yes, issue already has assignee.
But there is also assignee API, see https://developer.github.com/v3/issues/assignees/

@iwanbk Gogs only supports single assignee right now, so I don't think we need that list of APIs at current stage.

Gogs only supports single assignee right now

If you talk about List assignees, it actually list a repo's assigness, not an issue's assignee.

GET /repos/:owner/:repo/assignees

If you think this API is not important right now, i offer my help to other APIs.

How about the Administration API? Organizations and Repositories API seems still not complete.

Another thing to do related REST API is testing code, i don't see any test in the API code.

I think we should write common test code first that the API contributors can use it.

If you talk about List assignees, it actually list a repo's assigness, not an issue's assignee.

@iwanbk oh you're right, I mislead by the page title. Yes, you can implement ones for repository.

This might be the wrong place, but I'll add a few cents. (I can create a separate issue if needed)

It would be fantastic if the organization could also return its owners so we remotely can know what users are allowed to create repos in the organization. At least for the users that are allowed to see this information.

{
  "id": 6,
  "username": "gogs",
  "full_name": "Gogs",
  "avatar_url": "/avatars/6",
  "description": "Gogs(Go Git Service) is a painless self-hosted Git Service.",
  "website": "https://gogs.io",
  "location": "USA"
  "owners": [{"id": 9, "username": "foo",. ..}, {"id": 10, "username": "bar", ...}, ...]
}

.. or at least for an admin endpoint that can fetch info from any organization info. That way we can know remotely what users can create repositories in the organization.. or maybe this is something that should be queried through teams.

Right now when looking at existing repos, I don't know if it's possible to separate a team admin and an owner.

Please add API for POST /api/v1/repos/:owner/:repo/forks. It's very important feature.

is there any chance to collaborate and contribute with this feature?

Since I haven't seen it mentioned here, I'd like to add:

  • [ ] Releases

That is, I'd like to be able to draft a release, including file attachments, using the API. It would be very convenient (e.g. as part of a CI job that builds packages (windows .exe, macOS .dmg et.c.)) to create a draft release using the REST API and attach those files.

Hello, are there plans to add support for the https://developer.github.com/v3/git/ api?

We would really love to see support for querying our repositories.

Thank you so much for gogs btw. :)

@0maxxam0 has funded $20.00 to this issue.


Org and team management endpoints are currently available only for site admins (under the /admin path). I think these should be made available for all org owners.

I can prepare a PR if you agree.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Overv picture Overv  Â·  47Comments

lommes picture lommes  Â·  45Comments

fruitloop picture fruitloop  Â·  61Comments

hauleth picture hauleth  Â·  67Comments

unknwon picture unknwon  Â·  82Comments